Kubernetes DNS Deep Dive: CoreDNS, ndots, and Debugging Resolution Failures#
DNS problems are responsible for a disproportionate number of Kubernetes debugging sessions. The symptoms are always vague – timeouts, connection refused, “could not resolve host” – and the root causes range from CoreDNS being down to a misunderstood setting called ndots.
How Pod DNS Resolution Works#
When a pod makes a DNS query, it goes through the following chain:
- The application calls
getaddrinfo()or equivalent. - The system resolver reads
/etc/resolv.confinside the pod. - The query goes to the nameserver specified in
resolv.conf, which is CoreDNS (reachable via thekube-dnsService inkube-system). - CoreDNS resolves the name – either from its internal zone (for cluster services) or by forwarding to upstream DNS.
Every pod’s /etc/resolv.conf looks something like this: