0
0
Kubernetesdevops~10 mins

Why Kubernetes networking matters - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a Kubernetes Service that exposes a Pod on port 80.

Kubernetes
kubectl expose pod my-pod --port=[1]
Drag options to blanks, or click blank then click option'
A443
B80
C22
D8080
Attempts:
3 left
💡 Hint
Common Mistakes
Using port 443 which is for HTTPS, not HTTP.
Using port 22 which is for SSH.
2fill in blank
medium

Complete the command to list all Services in the default namespace.

Kubernetes
kubectl get [1]
Drag options to blanks, or click blank then click option'
Anodes
Bpods
Cservices
Ddeployments
Attempts:
3 left
💡 Hint
Common Mistakes
Listing pods instead of services.
Listing nodes which are cluster machines.
3fill in blank
hard

Fix the error in the Service YAML to correctly specify the target port.

Kubernetes
spec:
  ports:
  - port: 80
    targetPort: [1]
Drag options to blanks, or click blank then click option'
A80
BservicePort
Chttp
DnodePort
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'http' which is not a valid port number here.
Confusing servicePort and nodePort.
4fill in blank
hard

Fill both blanks to create a NetworkPolicy that allows traffic only from pods with label 'app=frontend' to pods with label 'app=backend'.

Kubernetes
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: allow-frontend
spec:
  podSelector:
    matchLabels:
      app: [1]
  ingress:
  - from:
    - podSelector:
        matchLabels:
          app: [2]
Drag options to blanks, or click blank then click option'
Abackend
Bfrontend
Cdatabase
Dcache
Attempts:
3 left
💡 Hint
Common Mistakes
Reversing the labels for source and destination pods.
Using unrelated labels like 'database' or 'cache'.
5fill in blank
hard

Fill all three blanks to define a Service of type NodePort exposing port 80 and targeting port 8080 on pods labeled 'app=web'.

Kubernetes
apiVersion: v1
kind: Service
metadata:
  name: web-service
spec:
  type: [1]
  selector:
    app: [2]
  ports:
  - port: [3]
    targetPort: 8080
Drag options to blanks, or click blank then click option'
AClusterIP
Bweb
C80
DNodePort
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'ClusterIP' which is internal only.
Mismatching selector labels.
Wrong port numbers.