What is a headless Service and where do you use it?
BeginnerScenarioServices, Ingress and DNS
Answer
Situation read → A StatefulSet needs stable DNS names for each pod.
What I'd do →
- Set
clusterIP: Noneon the Service - Reference it as
serviceNamein the StatefulSet - Each pod gets
pod-0.svc.ns.svc.cluster.local - Verify with
nslookup svcwhich returns pod IPs rather than a virtual IP - Use for databases, Kafka, and clients that do their own load balancing
Why → A headless Service skips the virtual IP and returns DNS A records of the pods, giving stable identities.
Interview tip → Mention that gRPC clients need headless or a mesh because ClusterIP balances per connection.
More on Services, Ingress and DNS
A Service has no endpoints. How do you find out why?BeginnerWhen do you use ClusterIP, NodePort, LoadBalancer and ExternalName?BeginnerTraffic to a Service works from some pods but times out from others. How do you debug it?AdvancedYou want to expose three HTTP services under one hostname with different paths. How?Intermediateingress-nginx returns 404 for a new host. What do you check?Intermediateingress-nginx returns 502 or 503 intermittently. What are the likely reasons?Intermediate