I have a question about CKA Mock Exam 2, question no 7: I am able to get the ser . . .

kmkale:
I have a question about CKA Mock Exam 2, question no 7:
I am able to get the service name resolution working, but the pod name resolution does not work.
Here are the steps I took to solve the question and verify:

  1. Command used to create the pod: k run nginx-resolver --image=nginx --port=80
  2. Command used to expose pod: k expose po nginx-resolver --name=nginx-resolver-service --port=80 --target-port=80
  3. Command used to check dns lookup for service works from inside the cluster: k run bb --image=busybox:1.28 --restart=Never -it --rm -- nslookup nginx-resolver-service > /root/CKA/nginx.svc
Output: controlplane $ cat /root/CKA/nginx.svc
  Server:    10.96.0.10
  Address 1: 10.96.0.10 kube-dns.kube-system.svc.cluster.local

  Name:      nginx-resolver-service
  Address 1: 10.100.196.52 nginx-resolver-service.default.svc.cluster.local
  pod "bb" deleted
  1. Command used to check Pod dns lookup works from inside the cluster: k run bb --image=busybox:1.28 --restart=Never -it --rm -- nslookup nginx-resolver > /root/CKA/nginx.pod
Output:
/root/CKA/nginx.pod
  controlplane $ cat /root/CKA/nginx.pod
  Server:    10.96.0.10
  Address 1: 10.96.0.10 kube-dns.kube-system.svc.cluster.local

  nslookup: can't resolve 'nginx-resolver'
  pod "bb" deleted

What could be the problem with service dns resolution works but pod dns resolution fails?

Vinay M Athreyas:
I was practicing this today, for pod resolution I guess you need to use IP, eg: 10-10-10-10.<namespace>.pod

Vinay M Athreyas:
you would need to replace . by - in IPs

kmkale:
Sorry but this page https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/ says I should be able to resolve by pod name within the namespace

kmkale:
e.g. In summary, a pod in the _test_ namespace can successfully resolve either data.prod or data.prod.cluster.local.

kmkale:
But here https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/#pods they talk about ip address as you rightly pointed out. I am confused :disappointed:

Vinay M Athreyas:
Isn’t the dns-pod-service is referring about service name resolution :slightly_smiling_face: