DNS and CoreDNS
Why DNS Was Born
Picture a bustling city. Every house has a street address, but people don’t memorize numbers they use names. Without a directory, finding someone would be impossible. Kubernetes faced the same challenge: pods and services have IPs that change frequently.
DNS (Domain Name System) was born as the phonebook of Kubernetes, translating service names into IP addresses so workloads can find each other.
CoreDNS – Cluster Phonebook
- Definition: CoreDNS is the default DNS server in Kubernetes.
- Key Features:
- Resolves service names to cluster IPs.
- Supports custom DNS entries.
- Extensible with plugins (logging, forwarding, caching).
Analogy: CoreDNS is like the city’s central directory office, ensuring everyone can find each other by name instead of numbers.
DNS Works in Kubernetes
- Service Discovery: Pods query DNS to resolve service names.
- ClusterIP Services: DNS maps service names to stable IPs.
- External Names: DNS can map internal services to external endpoints.
- Pod DNS Policies: Control how pods resolve names (cluster‑first vs host).
Analogy: DNS is like asking the phonebook for a friend’s number so you don’t need to memorize it.
Global Context
- Enterprises: Use CoreDNS for service discovery across microservices.
- Cloud Providers: Managed Kubernetes services ship with CoreDNS pre‑configured.
- Community: CoreDNS is a CNCF project, widely adopted as the backbone of Kubernetes DNS.
Hands‑On Exercise
- Reflect: How does CoreDNS act as the phonebook, ensuring pods and services can always find each other?
Add a custom DNS entry (ConfigMap):
apiVersion: v1
kind: ConfigMap
metadata:
name: coredns
namespace: kube-system
data:
Corefile: |
.:53 {
forward . 8.8.8.8
log
}
kubectl apply -f coredns-config.yaml
Test DNS resolution inside a pod:
kubectl run -i --tty dns-test --image=busybox -- /bin/sh
nslookup kubernetes.default
Verify CoreDNS deployment:
kubectl get pods -n kube-system -l k8s-app=kube-dns
The Hacker’s Notebook
- DNS is the phonebook for mapping names to IPs.
- CoreDNS is the directory office for managing lookups inside the cluster.
- Lesson for engineers: Don’t hard‑code IPs and use DNS for flexibility.
- Hacker’s mindset: Treat DNS as your discovery engine. With CoreDNS, you can scale services without breaking connections.

Updated on Dec 30, 2025