How does a pod find another service by name?
BeginnerScenarioKubernetes Networking
Answer
Situation read → CoreDNS gives every Service a DNS name.
What I'd do →
- The name is
<service>.<namespace>.svc.cluster.local, and within the same namespace<service>is enough - The pod's
/etc/resolv.confpoints to the CoreDNS ClusterIP and has search domains - Test:
kubectl exec -it pod -- nslookup my-svc.prod - Headless services return pod IPs directly
Why → Search domains in resolv.conf allow short names to expand to the full service FQDN.
Interview tip → Mention cross-namespace needs at least svc.namespace.
More on Kubernetes Networking
Explain the Kubernetes networking model in one minute.BeginnerClusterIP, NodePort and LoadBalancer: when do you use each?BeginnerService versus Ingress: what is the difference?BeginnerWhat does a CNI plugin do and which ones do you know?BeginnerHow do you reach a pod from your laptop for debugging without exposing it?BeginnerBy default, can any pod talk to any other pod, and how do you change that?Beginner