Pod networking
How a packet gets from one pod to another, and where to look when it does not.
Updated
Kubernetes requires that every pod can reach every other pod without NAT. How that is achieved is left to the CNI plugin.
The model
- Each pod gets its own IP address and network namespace.
- Containers in a pod share that namespace and talk over
localhost. - Nodes route pod CIDRs to each other, directly or through an overlay.
Same node
A veth pair connects the pod namespace to a bridge or to the host routing table. Traffic between two pods on one node never leaves the host.
Across nodes
Overlay
Packets are encapsulated (VXLAN, Geneve) and sent to the destination node, which unwraps them. Works on any network, costs some MTU and CPU.
Native routing
Pod CIDRs are advertised to the underlying network, for example over BGP. No encapsulation, but the network must accept the routes.
Checks
kubectl get pods -o wide
kubectl exec -it debug -- ip route
kubectl exec -it debug -- ping -M do -s 1472 10.244.2.15
The last command tests the path MTU; a failure with a large payload and success with a small one points to an MTU mismatch on an overlay.