8/945 min
Config & Health
DNS & CoreDNS
How Kubernetes DNS works, the FQDN format, CoreDNS configuration, and how to debug DNS failures.
intermediate45 minRead β Lab β Quiz β Practice
π§ Brain Warm-Up
π§ Brain Warm-Up: When a pod in namespace "frontend" tries to connect to "backend-svc", how does it know which IP to use? There is no /etc/hosts entry. Think about how DNS is injected into pods before reading.
How Kubernetes DNS Works
Every pod gets /etc/resolv.conf injected with:
nameserver 10.96.0.10 β CoreDNS ClusterIP search default.svc.cluster.local svc.cluster.local cluster.local options ndots:5
CoreDNS is a pod running in kube-system that handles DNS for the cluster.
FQDN Format
<service>.<namespace>.svc.cluster.local
β β β
svc name namespace cluster domainExamples:
my-api.default.svc.cluster.localβ full formmy-api.defaultβ works due to search domainsmy-apiβ works within the same namespace
Search Domains Enable Short Names
From a pod in namespace frontend:
backend-svcresolves (search appendsfrontend.svc.cluster.local)backend-svc.backendresolves cross-namespace (search appendssvc.cluster.local)backend-svc.backend.svc.cluster.localβ always works
Pod DNS Policy
| Policy | Behavior |
|---|---|
ClusterFirst (default) | Cluster DNS first, then upstream |
Default | Node's /etc/resolv.conf (no cluster DNS) |
None | Custom β must set dnsConfig |
ClusterFirstWithHostNet | For hostNetwork pods |