DNS resolution failure in pods
Name resolution inside pods fails or takes seconds. The errors depend on the client: could not resolve host, no such host, Temporary failure in name resolution, or dial udp 10.96.0.10:53: i/o timeout.
Diagnose in order
Section titled “Diagnose in order”-
Is CoreDNS healthy?
kubectl -n kube-system get pods -l k8s-app=kube-dnsand their logs. (CoreDNS keeps thekube-dnslabel.) -
Does it fail everywhere or in one namespace? Test from a pod in a healthy namespace and in the affected one:
Terminal window kubectl -n <ns> run dnstest --rm -it --restart=Never --image=busybox:1.36 -- nslookup kubernetes.default -
One namespace only: look for NetworkPolicies there that block egress to
kube-systemon port 53:kubectl get networkpolicy -n <ns>. -
Slow, not failing: check
/etc/resolv.confin the pod forndots:5, and compare timings forexample.comversusexample.com.(with the trailing dot).
Usual causes
Section titled “Usual causes”| Symptom | Cause |
|---|---|
| Fails everywhere, CoreDNS pods crashing | CoreDNS misconfiguration (Corefile), or a forwarding loop to itself |
| Fails in one namespace only | Egress NetworkPolicy without a DNS allow rule |
i/o timeout to the DNS Service IP |
kube-proxy or CNI not forwarding to CoreDNS pods |
| Internal names fine, external names fail | Upstream resolvers unreachable from CoreDNS |
| Everything slow | ndots:5 causing several failed lookups per external name, or CoreDNS under-scaled |
Fix the layer that fails. For policies, add an egress rule to CoreDNS on UDP and TCP port 53. For slowness, set dnsConfig.options ndots: 2 on workloads that call external names, and scale CoreDNS with the cluster.
Read next: Services, DNS, and kube-proxy and Network policies.