Sub topic 13
How kube-proxy turns a Service IP into a Pod IP
This chapter assumes you can read kubectl get and describe output, know what a Pod IP and a ClusterIP are, and have read the chapter on Endpoints and EndpointSlices. It explains the last step before traffic reaches a Pod, and how to tell whether that step is the problem.
A Service IP is not on any interface
A ClusterIP such as 10.96.14.20 is not assigned to a network card, and no process listens on it. It is a virtual IP. Nothing answers a ping to it, and that is normal.
Rewrite rules on each node make the virtual IP work. When a Pod sends a packet to the Service IP and port, a rule on that node replaces the destination with the IP and port of one ready backend Pod. This is destination NAT (network address translation). The reply is translated back, so the client believes it is talking to the Service.
What kube-proxy does
kube-proxy is a component that runs on every node, usually as a DaemonSet in kube-system. It does not forward packets itself. It watches the API server for Services and EndpointSlices, and it programs the node's packet-handling rules to match.
The rules change whenever the set of ready endpoints changes. This is why a Pod that fails its readiness probe stops receiving traffic within a few seconds.
Proxy modes
| Mode | How it works | Notes |
|---|---|---|
| iptables | Chains of rules in the kernel pick a backend at random | Default on most Linux clusters |
| IPVS | A kernel load balancer with a hash table of backends | Scales better with many Services |
| nftables | Same idea as iptables, using the newer nftables framework | Available in recent Kubernetes versions |
Some CNI plugins, such as Cilium, can replace kube-proxy entirely. In that case there is no kube-proxy Pod, and you debug with that plugin's own tools.
Checking kube-proxy
Start by confirming it runs on every node and has no errors.
kubectl -n kube-system get pods -l k8s-app=kube-proxy -o wide
kubectl -n kube-system logs -l k8s-app=kube-proxy --tail=50
kubectl -n kube-system get configmap kube-proxy -o yamlThe ConfigMap shows the configured mode. Some distributions label or name the Pods differently, so adjust the selector if the first command returns nothing.
If you have shell access to a node, you can look at the rules directly. For the iptables mode, search for your Service name:
sudo iptables-save | grep 'default/web'You should see entries that mention the Service, with one rule per backend Pod. If the Service has no ready endpoints, the rules typically reject traffic instead, and clients see an immediate "connection refused".
Symptoms that point to kube-proxy
Suspect kube-proxy only after the earlier layers pass. Check that DNS resolves, the selector matches, the endpoints are listed, and the ports match.
- Connecting to a Pod IP directly works, but connecting to the Service IP fails.
- The Service works from some nodes and not others. This suggests kube-proxy is unhealthy on the failing nodes.
- Endpoints changed, but traffic still goes to old Pods. Rules are stale, which can happen if kube-proxy is crashing or cannot reach the API server.
Exercise
From a debug Pod, wget http://10.244.1.7:80 succeeds, but wget http://10.96.14.20:8080 to the Service fails, and kubectl get endpointslices shows 10.244.1.7:80 as ready. DNS is not involved. Which component do you check next, and why?
Show answer
Check kube-proxy on the node where the debug Pod runs. The backend Pod works and the endpoint is registered, so the fault is likely in the translation from Service IP to Pod IP. Look at the kube-proxy Pod status and logs on that node, and compare with another node to see whether the failure is node-specific.