0
0
Kubernetesdevops~10 mins

Service discovery via DNS 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 define a Kubernetes Service that uses DNS for service discovery.

Kubernetes
apiVersion: v1
kind: Service
metadata:
  name: my-service
spec:
  selector:
    app: my-app
  ports:
  - protocol: TCP
    port: 80
    targetPort: [1]
Drag options to blanks, or click blank then click option'
A8080
B3000
C443
D80
Attempts:
3 left
💡 Hint
Common Mistakes
Using a port number that does not match the pod's container port.
Confusing port and targetPort.
2fill in blank
medium

Complete the command to get the DNS name of a service in the default namespace.

Kubernetes
kubectl get svc [1] -o jsonpath='{.spec.clusterIP}'
Drag options to blanks, or click blank then click option'
Adefault
Bmy-service
Ckube-dns
Dmy-pod
Attempts:
3 left
💡 Hint
Common Mistakes
Using pod names instead of service names.
Using namespace names instead of service names.
3fill in blank
hard

Fix the error in the DNS query command to resolve the service name inside a pod.

Kubernetes
nslookup [1].default.svc.cluster.local
Drag options to blanks, or click blank then click option'
Akube-system
Bmy-pod
Cmy-service
Dlocalhost
Attempts:
3 left
💡 Hint
Common Mistakes
Using pod names instead of service names in DNS queries.
Using incorrect namespaces.
4fill in blank
hard

Fill both blanks to create a headless service for DNS-based service discovery.

Kubernetes
apiVersion: v1
kind: Service
metadata:
  name: headless-service
spec:
  clusterIP: [1]
  selector:
    app: my-app
  ports:
  - port: 80
    targetPort: [2]
Drag options to blanks, or click blank then click option'
Anull
B8080
C80
D0.0.0.0
Attempts:
3 left
💡 Hint
Common Mistakes
Using a normal cluster IP instead of null for headless services.
Mismatching the target port with the container port.
5fill in blank
hard

Fill all three blanks to create a DNS SRV record query for a service in Kubernetes.

Kubernetes
dig +short SRV _[1]._tcp.[2].svc.[3]
Drag options to blanks, or click blank then click option'
Ahttp
Bmy-service
Ccluster.local
Ddefault
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing service name with namespace.
Using wrong cluster domain.
Omitting the underscore prefix in SRV queries.