"Service is up, pods are Running and Ready, nothing can reach it." Service api declares port: 80 and targetPort: 8080; kubectl get endpointslices -l kubernetes.io/service-name=api lists the pod IPs. From a debug pod, curl http://<pod-ip>:3000/healthz returns 200, but curl http://api:80/healthz is refused instantly. Where is the bug?
-
targetPortdoes not match the port the process listens on: kube-proxy DNATs the connection to<pod-ip>:8080, nothing listens there, and the pod's kernel answers the SYN with a reset. The Service layer worked (DNS resolved, kube-proxy translated the address); the refusal comes from the pod's own TCP stack because the target port is closed. - The pods are not Ready yet, so kube-proxy rejects connections until the readiness probe passes. The EndpointSlice lists the pod IPs, which means they are Ready; not-Ready pods would be absent from the slice and the refusal would then come from kube-proxy's no-endpoints rule instead.
- The Service needs
type: NodePortbefore another pod can reach it. ClusterIP is reachable from every pod in the cluster; NodePort only adds a per-node port for traffic that arrives from outside the pod network. - kube-proxy is not running on the node, so the ClusterIP has no rules and the kernel refuses the connection. Without rules the SYN would be routed to a virtual address nobody owns and hang until timeout; an instant refusal means a rule matched and something actively rejected it.
targetPort points at a port nobody listens on, so the pod's own kernel refuses the connection; make targetPort match the listening port.
A Service has three layers: the name resolves to a ClusterIP, kube-proxy DNATs the ClusterIP and port to a pod IP and targetPort, and a process on the pod must listen on that targetPort. Here the first two layers demonstrably worked, so the refusal is the pod's kernel resetting a SYN to a closed port. The interview signal is separating the layers with the evidence given (pod curl works, endpoints populated, refusal is instant) instead of restarting components.
Hearing 'connection refused' and reaching for kube-proxy or a restart. Refused means something answered — the pod's kernel or kube-proxy's REJECT rule; a broken dataplane makes connections hang, it does not fail fast.