Diagnose and tune cluster DNS

DevOps, Hands On30 minutesFreeSteps checked 23 November 2026By Cloud Hands On

In this task you'll find out why name lookups inside the cluster are slow or failing, and fix them.

Pods find services by name through CoreDNS, which runs as pods in kube-system. A service api in namespace shop is api.shop.svc.cluster.local. Each pod's /etc/resolv.conf lists search domains and options ndots:5.

With ndots:5, any name with fewer than 5 dots (such as api.payments-provider.example) is first tried with every search domain added, so one external lookup can become several failed queries. Fixes: use full names ending in a dot, lower ndots in the pod's dnsConfig, run more CoreDNS replicas, or use NodeLocal DNSCache so each node answers from a cache.

Example. Harbourline Design's API made 6 DNS queries for every call to its payment provider, and CoreDNS hit its CPU limit at peak. Setting ndots: 2 in the deployment's dnsConfig cut it to 1 query, and timeouts stopped.

Before you start

You need: Docker Desktop and kind on your computer (both free). Time: 30 minutes.

Where to look

  1. Terminal
  2. kubectl

Steps

  1. Start a debug pod: kubectl run dns --image=busybox:1.36 -it --rm -- sh.
  2. Inside it, read cat /etc/resolv.conf, then try nslookup kubernetes.default.
  3. Check CoreDNS: kubectl get pods -n kube-system -l k8s-app=kube-dns and kubectl logs -n kube-system -l k8s-app=kube-dns.
  4. Add dnsConfig: options: { name: ndots, value: "2" } to a test pod and compare its resolv.conf.

Commands

kubectl run dns --image=busybox:1.36 -it --rm --restart=Never -- nslookup kubernetes.default
kubectl get pods -n kube-system -l k8s-app=kube-dns
kubectl logs -n kube-system -l k8s-app=kube-dns --tail=20

Watch out for

Cost
Free on kind. On AKS, change CoreDNS through the coredns-custom ConfigMap, not the main one, which AKS overwrites.
Security
DNS reveals every service name: network policies should still limit who can talk to what.
Common mistakes
Editing the main CoreDNS ConfigMap on AKS, and blaming the app before checking CoreDNS's own logs and CPU.

Clean up

The debug pod deletes itself (--rm). Delete any test pods.

Words to know

CoreDNS
The DNS server inside the cluster that answers service and pod name lookups.
ndots
How many dots a name needs before it's looked up as-is, before trying the search domains.
NodeLocal DNSCache
A DNS cache on every node, which reduces load on CoreDNS and lookup time.

Tick off each step and track your progress in the guide.

Open this task in DevOps, Hands On

Keep going