Pod IP and the veth Pair
Inside a Pod the network interface has an address, yet it is only one end of a virtual cable, and the end on the Node has none. How does a packet cross the cable, and why does the IP belong to the Pod, not a container?
Play the animation 5 steps, animated, plays on a computer or a tablet
Pod IP and the veth Pair, step by step
-
One CNI ADD made this and exited, leaving a single virtual link with two ends: eth0 stands inside the Pod network namespace and vethb3f8a2c7 stands in the Node root namespace. The @if2 after the host side name is the index of the other end.
Play from step 1 -
Of the two ends only the Pod end is configured with an address: inside the namespace eth0 carries 10.244.1.5/24, and the host end carries none. An address belongs to a network namespace rather than to a cable or to a container, so the thing that has an address here is the Pod.
Play from step 2 -
The app sends, and the packet goes out eth0 because on the usual plugins that is the one interface in this namespace facing outward. It enters one end of the pair and leaves the other with no lookup and no decision in between, since a veth pair is a point to point link.
Play from step 3 -
The host end is put under cni0 as a bridge port, which is what master cni0 means. A port does not answer for anything, so it needs no address of its own, and the frame lands on the bridge rather than in the Node routing table. The address on this side belongs to cni0 instead, at 10.244.1.1.
Play from step 4 -
The runtime created this namespace, pause holds it and app joined it, so both of them stand on that one eth0 and answer on that one address. A second container does not bring a second pair and a second address with it. The unit the pair and the address are allocated to is the Pod.
Play from step 5