Interview Prep/Networking/Kubernetes Networking

When do you use a headless service?

IntermediateScenarioKubernetes Networking
Answer

Situation read → It returns pod IPs instead of a virtual IP.

What I'd do →

  1. Set clusterIP: None in the Service
  2. DNS returns A records for each ready pod, and for StatefulSets stable names like db-0.db.prod.svc.cluster.local
  3. Use it for databases, Kafka or any client-side discovery
  4. Check with nslookup db.prod.svc.cluster.local
  5. Clients must handle multiple records and reconnect on changes

Why → No virtual IP means no load balancing by kube-proxy; the client sees the real endpoints.

Interview tip → Say StatefulSets need it for stable network identity.

All Networking questions Roadmap: Networking for DevOps

More on Kubernetes Networking