0
0
Kubernetesdevops~10 mins

Pod-to-Pod communication in Kubernetes - Interactive Code Practice

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

Complete the code to create a Pod that listens on port 80.

Kubernetes
apiVersion: v1
kind: Pod
metadata:
  name: my-pod
spec:
  containers:
  - name: web
    image: nginx
    ports:
    - containerPort: [1]
Drag options to blanks, or click blank then click option'
A443
B8080
C22
D80
Attempts:
3 left
💡 Hint
Common Mistakes
Using port 8080 instead of 80
Using port 443 which is for HTTPS
Using port 22 which is for SSH
2fill in blank
medium

Complete the command to check the IP address of a Pod named 'my-pod'.

Kubernetes
kubectl get pod my-pod -o [1]
Drag options to blanks, or click blank then click option'
Ajsonpath='{.status.phase}'
Bwide
Cjsonpath='{.status.podIP}'
Dyaml
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'wide' which shows more info but not just the IP
Using 'yaml' which outputs full YAML
Using jsonpath for phase instead of podIP
3fill in blank
hard

Fix the error in the Service definition to expose port 80 correctly.

Kubernetes
apiVersion: v1
kind: Service
metadata:
  name: my-service
spec:
  selector:
    app: my-app
  ports:
  - protocol: TCP
    port: [1]
    targetPort: 8080
Drag options to blanks, or click blank then click option'
A8080
B80
C22
D443
Attempts:
3 left
💡 Hint
Common Mistakes
Setting port to 8080 which is the container port, not the service port
Using port 22 or 443 which are for SSH and HTTPS
4fill in blank
hard

Fill both blanks to create a NetworkPolicy that allows ingress only from Pods with label 'role=frontend'.

Kubernetes
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: allow-frontend
spec:
  podSelector: {}
  ingress:
  - from:
    - podSelector:
        matchLabels:
          [1]: [2]
Drag options to blanks, or click blank then click option'
Arole
Bfrontend
Capp
Dbackend
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'app' instead of 'role' as label key
Using 'backend' instead of 'frontend' as label value
5fill in blank
hard

Fill all three blanks to create a ConfigMap with keys 'host' and 'port'.

Kubernetes
apiVersion: v1
kind: ConfigMap
metadata:
  name: service-config
data:
  [1]: example.com
  [2]: "[3]"
Drag options to blanks, or click blank then click option'
Ahost
Bport
Chttp
Dprotocol
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up keys and values
Not quoting the port value as a string