CoreDNS
CoreDNS is the default DNS server in Kubernetes. It runs as a Deployment in kube-system and resolves Service and pod names, such as orders-service.production.svc.cluster.local, to cluster IPs so workloads can find each other by name.
How resolution works
Every pod's /etc/resolv.conf points to the CoreDNS Service IP, and includes search domains so short names work within the same namespace.
orders-service"] -->|"DNS query"| D["CoreDNS
kube-system"] D -->|"lookup"| K["Kubernetes API
Services and endpoints"] D -->|"returns ClusterIP"| P D -->|"external names"| U["Upstream DNS"] classDef pod fill:#475569,color:#ffffff classDef dns fill:#DBEAFE,color:#1E293B classDef ext fill:#EDE9FE,color:#1E293B class P pod class D dns class K,U ext
Name format
<service>.<namespace>.svc.cluster.localpayments-service.production.svc.cluster.localpostgres-0.postgres.production.svc.cluster.local (StatefulSet pod)Within a namespace, payments-service works. Across namespaces use at least payments-service.production.
Corefile
data: Corefile: | .:53 { errors health ready kubernetes cluster.local in-addr.arpa ip6.arpa { pods insecure fallthrough in-addr.arpa ip6.arpa } prometheus :9153 forward . /etc/resolv.conf cache 30 loop reload loadbalance }Debugging
kubectl get pods -n kube-system -l k8s-app=kube-dnskubectl logs -n kube-system -l k8s-app=kube-dns --tail=50kubectl run dns-debug --image=busybox:1.36 -it --rm -n production -- nslookup kubernetes.default| Symptom | Likely cause | Fix |
|---|---|---|
| Lookups time out | CoreDNS pods unhealthy | Check pods and logs |
| Cross-namespace short name fails | Resolves in own namespace only | Add the namespace to the name |
| Slow external lookups | ndots:5 search expansion |
Use trailing-dot FQDNs or tune ndots |
RememberIf CoreDNS fails, service discovery fails cluster-wide. Run multiple replicas and consider NodeLocal DNSCache for large clusters.
Common MistakeTreating DNS failures as network problems. Many mystery connectivity errors are name resolution failures.
Frequently Asked Questions
What breaks if CoreDNS goes down?
Anything that connects by service name, which is nearly everything. Workloads using raw IPs keep working, but that is rare. Running several replicas and a PodDisruptionBudget reduces the risk.
Why are external DNS lookups slow in pods?
The default ndots:5 setting makes the resolver try several search-domain variants before the real name, multiplying queries. Fully qualified names with a trailing dot, or a lower ndots, avoid this.
How do I customise DNS for one domain?
Add a server block to the Corefile with a forward directive for that domain, such as an internal corporate zone, and let the reload plugin pick it up.