As asked
A pod tries to resolve the hostname 'myservice'. Walk through the full DNS resolution path: what is in /etc/resolv.conf, how does the search domain list affect which queries go to CoreDNS, and what is the ndots setting and why does it cause extra DNS lookups?
Sample answer outline
The pod's /etc/resolv.conf is injected by kubelet and contains the CoreDNS ClusterIP as the nameserver and search domains: [namespace].svc.cluster.local, svc.cluster.local, cluster.local, plus any host search domains. With ndots:5 (the default), a hostname with fewer than 5 dots is first tried against each search domain before being tried as an absolute name. So 'myservice' generates 3-4 DNS queries before resolving. For external hostnames like 'example.com' (1 dot, less than 5), the same behavior applies, creating extra latency. Mitigation: use FQDN (trailing dot), lower ndots, or use autopath in CoreDNS.
Expect these follow-ups
- What is CoreDNS autopath and how does it reduce the number of DNS queries for service resolution?
- How do you diagnose DNS resolution failures in a pod? Which tools and commands do you use?