How do you debug "pod cannot reach service" in Kubernetes?
AdvancedProductionKubernetes & Service Networking in Production
Answer
Check in order: pod resolves the Service name, Service has endpoints (kubectl get endpointslices), selector labels match pod labels, targetPort is correct, readiness passes, NetworkPolicy permits the flow, kube-proxy or Cilium programmed rules, and the destination app listens on 0.0.0.0.
kubectl run net --rm -it --image=nicolaka/netshoot -- bash
nslookup web.shop; curl -sv web.shop:80
kubectl get endpoints web -n shop
Empty endpoints is the most common cause.
More on Kubernetes & Service Networking in Production
How do you expose an application on Kubernetes to the internet in production?BeginnerALB IP mode versus instance mode on EKS: which should you use?IntermediateHow do you achieve graceful pod shutdown with no dropped requests?AdvancedHow do readiness, liveness and startup probes interact with traffic?BeginnerHow do you design default-deny NetworkPolicies without breaking DNS?IntermediateHow do you scale CoreDNS and avoid DNS becoming an outage source?Advanced