Every Pod gets an IP from the cluster's Pod range. When the Pod is deleted, the IP is released. A Deployment that replaces a Pod gives the replacement a new IP.
10:00 market-web-7c-abc 10.42.0.8 Running
10:05 market-web-7c-abc deleted
10:05 market-web-7c-xyz 10.42.0.14 Running <- new Pod, new IPA client that stored 10.42.0.8 is now talking to nothing.
Service
A is an object with three parts:
Service market-web
clusterIP: 10.96.248.109 stable virtual IP, allocated once
selector: app=market-web which Pods are behind it
ports: 80 -> 80 port on the IP -> targetPort on the PodThe cluster IP never changes for the life of the Service. DNS gives the Service a name. Clients use the name; the Pods behind it can come and go.
Endpoints
The endpoints controller keeps a second object, with the same name, listing every ready Pod that matches the selector:
Endpoints market-web
10.42.0.8:80
10.42.0.9:80
10.42.0.10:80Delete a Pod and its address leaves this list. Create one and it joins. kubectl get endpoints is how you check whether a Service is pointing at anything.
kube-proxy
Each node runs kube-proxy. It watches Services and Endpoints and programs the node's packet rules so that a packet addressed to 10.96.248.109:80 is rewritten to one of the endpoint addresses.
client Pod ──▶ 10.96.248.109:80 (ClusterIP)
│ kube-proxy rewrites the destination
├──▶ 10.42.0.8:80
├──▶ 10.42.0.9:80
└──▶ 10.42.0.10:80No proxy process sits in the data path. The rewrite happens in the kernel.