Interview Prep/Kubernetes/Services, Ingress and DNS

A pod cannot resolve `my-svc` but can reach the pod IP. What do you test first?

BeginnerScenarioServices, Ingress and DNS
Answer

Situation read → DNS lookups fail inside the cluster.

What I'd do →

  1. kubectl exec -it app -- nslookup my-svc and cat /etc/resolv.conf
  2. kubectl get pods -n kube-system -l k8s-app=kube-dns
  3. kubectl logs -n kube-system -l k8s-app=kube-dns
  4. Try the FQDN my-svc.default.svc.cluster.local
  5. Test from a different namespace, since short names only resolve within the same namespace

Why → The resolv.conf search path includes the pod namespace, so cross-namespace calls need svc.namespace.

Interview tip → Mention ndots:5 and its effect on lookup volume.

All Kubernetes questions Roadmap: Kubernetes networking, storage & scaling

More on Services, Ingress and DNS