CKAD — Kubernetes DNS

less than 1 minute read

DNS in Kubernetes

Kubernetes runs a DNS server (CoreDNS) that automatically creates DNS records for Services.

DNS Record Format

Resource DNS Name
Service (same namespace) <service-name>
Service (different namespace) <service-name>.<namespace>
Service (fully qualified) <service-name>.<namespace>.svc.cluster.local
Pod <pod-ip-dashed>.<namespace>.pod.cluster.local

Examples

# From a Pod in the 'default' namespace

# Access a Service in the same namespace
curl http://web

# Access a Service in the 'production' namespace
curl http://web.production

# Fully qualified domain name
curl http://web.production.svc.cluster.local

# DNS resolution
kubectl run test --image=busybox:1.36 --rm -it -- nslookup web
# Expected:
# Name:      web.default.svc.cluster.local
# Address:   10.96.45.12

Exam tip: When accessing Services across namespaces, use <service>.<namespace> format. You rarely need the full .svc.cluster.local suffix.


Next: Endpoints & Headless Services →

Updated: