Skip to main content
Course/Config & Health/DNS & CoreDNS
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 domain

Examples:

  • my-api.default.svc.cluster.local β€” full form
  • my-api.default β€” works due to search domains
  • my-api β€” works within the same namespace

Search Domains Enable Short Names

From a pod in namespace frontend:

  • backend-svc resolves (search appends frontend.svc.cluster.local)
  • backend-svc.backend resolves cross-namespace (search appends svc.cluster.local)
  • backend-svc.backend.svc.cluster.local β€” always works

Pod DNS Policy

PolicyBehavior
ClusterFirst (default)Cluster DNS first, then upstream
DefaultNode's /etc/resolv.conf (no cluster DNS)
NoneCustom β€” must set dnsConfig
ClusterFirstWithHostNetFor hostNetwork pods