A StatefulSet's Pods cannot resolve each other: `nslookup kafka-1.kafka-headless` returns `NXDOMAIN`.
IntermediateTroubleshootingServices, DNS, Ingress and NetworkPolicy
Answer
Likely causes → Per-Pod DNS records exist only when the StatefulSet serviceName matches an existing headless Service (clusterIP: None) whose selector matches the Pods. Also, by default only Ready Pods get records, which breaks cluster bootstrap where peers must find each other before ready.
Diagnose →
kubectl get sts kafka -o jsonpath='{.spec.serviceName}{"\n"}'
kubectl get svc kafka-headless -o jsonpath='{.spec.clusterIP} {.spec.selector}{"\n"}'
Fix → Create the headless Service with the same name as serviceName, and for peer discovery during startup set:
spec:
clusterIP: None
publishNotReadyAddresses: true
Prevent → Template the StatefulSet and its headless Service together.
More on Services, DNS, Ingress and NetworkPolicy
`curl http://orders.shop.svc.cluster.local` hangs, and `kubectl get endpointslices -l kubernetes.io/service-name=orders` shows `ENDPOINTS <unset>`.BeginnerEndpoints exist, but `curl orders:80` returns `Connection refused`.BeginnerA Service works when you curl the Pod IP but times out on the ClusterIP from every node.IntermediateInside a Pod, `nslookup orders` returns `;; connection timed out; no servers could be reached`.BeginnerCoreDNS Pods are in CrashLoopBackOff with `[FATAL] plugin/loop: Loop (127.0.0.1:41823 -> :53) detected for zone "."`.IntermediateCalls to `api.stripe.com` from Pods are slow, and CoreDNS logs show `api.stripe.com.payments.svc.cluster.local`, `api.stripe.com.svc.cluster.local` … all `NXDOMAIN`.Intermediate