Full lesson
Explore the full explanation, examples, and visuals at your own pace.
Part 1
Your request never names the Pod. The client only knows one address, 34.1.2.3 on port 80. It sends GET /cart there, to the cloud load balancer. The load balancer then forwards it to a healthy node's NodePort, 31080. Here that's node-a, at 10.0.1.5. So where does the Pod come in?
One Service, four addresses
Our cart-svc Service carries four addresses. The external IP, 34.1.2.3 on port 80, is what the internet uses, via the cloud LB. Under it sits NodePort 31080, then the ClusterIP, 10.96.40.12, for in-cluster apps. Only the Endpoints row holds real Pod IPs. Everything above it is a stable key that kube-proxy rules rewrite.
kube-proxy writes the map
Who writes these rules? That's kube-proxy, which runs on every node. It watches the API server for Services like cart-svc and their endpoints, then programs DNAT rules into the node's iptables. When endpoints change, it rewrites those rules. But in the default iptables mode, packets never pass through kube-proxy itself. The kernel does the forwarding.
ClusterIP: a rule, not a machine
No machine owns 10.96.40.12. It's just a match key. A packet to that ClusterIP address, or to the node's port 31080, jumps into the same cart-svc chain. That chain picks an endpoint at random, fifty percent each, and rewrites the destination to a Pod IP like 10.244.2.8.
Step 3: DNAT lands on a Pod
The request reaches node-a on port 31080, and the iptables rule matches it. DNAT rewrites the destination to 10.244.2.8, port 8080, which is cart-pod-1. That address lives on node-b, so the Pod network carries the packet there. On the way back, conntrack reverses the rewrite for the client.
Endpoints follow the Pods
The table lists the endpoints behind cart-svc. Both Pods are ready, so both get traffic. Now cart-pod-1 crashes. Row one now shows its replacement, cart-pod-3, at 10.244.3.5. The control plane updates the endpoints, and kube-proxy rewrites the rules on each node. Only ready Pods are listed. The Service itself never changes.
Why clients skip Pod IPs
Clients skip Pod IPs for three reasons. They change whenever a Pod is replaced. The Pod network is usually cluster-internal, so the internet can't reach it. And with several replicas, clients need one stable address that spreads requests across them.
- Pod IPs change on every replacement
- Pod network is cluster-internal
- Replicas need one shared address
Direct vs through the Service
With Pod IP direct, the client sends GET /cart to 10.244.2.8, and it's unroutable from outside, so it never arrives. Even if it did, that address goes stale after rescheduling. Via Service, the client hits 34.1.2.3:80, the cart-svc rules apply DNAT, and the request lands on a ready Pod.
Stable Service addresses are rewrite rules pointing at ever-changing Pod IPs.
Stable Service addresses are rewrite rules pointing at ever-changing Pod IPs. The external IP, the NodePort, and the ClusterIP are keys; only the Pod IP is a real destination. So when traffic fails, check the Service's endpoints first, because empty endpoints break every hop after them.