DNS & Service Discovery
Service Discovery Matters
Picture a massive city with thousands of restaurants. Without a directory or GPS, finding the right place would be impossible. Kubernetes clusters face the same challenge: with hundreds or thousands of pods and services, how do workloads find each other reliably?
DNS and Service Discovery were born to solve this problem. They act as the address book and GPS of Kubernetes, ensuring pods and services can communicate without hard‑coding IPs.
DNS System in Kubernetes
- CoreDNS: The default DNS server in Kubernetes, deployed as a cluster add‑on.
- Automatic Records: Every service gets a DNS name (
service-name.namespace.svc.cluster.local). - Pod Resolution: Pods can resolve services by name, eliminating the need for static IPs.
- Namespace Awareness: DNS records are scoped to namespaces, preventing conflicts.
Analogy: DNS is like the phone directory of a city - you don’t memorize numbers, you just look up names.
Service Discovery in Action
- Internal Discovery: Pods use DNS names to connect to services inside the cluster.
- External Discovery: Ingress and LoadBalancers extend DNS to the outside world.
- Dynamic Updates: As pods scale up or down, DNS records remain stable.
- Integration: Service discovery integrates with microservices, APIs, and CI/CD pipelines.
Analogy: Service discovery is like GPS navigation - no matter how roads change, you always reach the right destination.
Global Context
- Enterprises: Rely on DNS for microservice communication across thousands of pods.
- Cloud Providers: Managed Kubernetes services integrate DNS with cloud DNS systems for hybrid workloads.
- Community: DNS and service discovery are foundational topics in Kubernetes education worldwide.
Hands‑On Exercise
- Reflect: How does DNS ensure pods can find services without relying on IP addresses?
Resolve the service from another pod:
kubectl run test --rm -it --image=busybox -- /bin/sh
nslookup web
wget -qO- web:80
Deploy a service:
kubectl create deployment web --image=nginx
kubectl expose deployment web --port=80 --type=ClusterIP
The Hacker’s Notebook
- DNS is the directory - mapping service names to IPs.
- Service discovery is GPS - ensuring workloads always find the right destination.
- Lesson for engineers: Don’t hard‑code IPs - use service names for resilience.
- Hacker’s mindset: Treat DNS as your invisible ally. With it, you can scale microservices without breaking communication.

Updated on Dec 29, 2025