You created a headless service but your pods are not reachable via DNS. What is a likely cause?
medium📝 Troubleshoot Q14 of 15
Kubernetes - Services
You created a headless service but your pods are not reachable via DNS. What is a likely cause?
AYou forgot to set clusterIP: None in the service spec
BYour pods do not have matching labels for the service selector
CYou used type: LoadBalancer instead of clusterIP: None
DYou exposed the service with NodePort instead of ClusterIP
Step-by-Step Solution
Solution:
Step 1: Check service selector and pod labels
If pods do not match the service selector labels, the service cannot route traffic to them.
Step 2: Verify clusterIP and service type correctness
clusterIP: None is required for headless service; type LoadBalancer or NodePort changes service behavior but won't cause DNS pod reachability issues if labels match.
Final Answer:
Your pods do not have matching labels for the service selector -> Option B
Quick Check:
Selector mismatch = pods unreachable [OK]
Quick Trick:Check pod labels match service selector [OK]
Common Mistakes:
Ignoring pod labels and selector mismatch
Confusing service type with label issues
Assuming NodePort affects headless DNS reachability
Master "Services" in Kubernetes
9 interactive learning modes - each teaches the same concept differently