Wiring a Pod via CNI
A new Pod starts with only a loopback, and a moment later it has an address, a route and a working interface. Who sets it all up for the Pod, in what order, and who takes it apart again when the Pod is deleted?
Play the animation 6 steps, animated, plays on a computer or a tablet
Wiring a Pod via CNI, step by step
-
The Kubelet asks the CRI runtime (here containerd) for a Pod sandbox. The runtime first creates the Pod network namespace, with loopback only and no Pod IP, runs the plugin chain inside that same RunPodSandbox call, and only then starts the pause container in it.
Play from step 1 -
The runtime, not the Kubelet, reads the plugin list from /etc/cni/net.d and runs the first plugin as a plain executable. It gets CNI_COMMAND=ADD, the sandbox namespace path and CNI_IFNAME=eth0 in its environment, and the network config on stdin.
Play from step 2 -
The bridge plugin does not hand out addresses itself. Its config names the IPAM plugin host-local, and bridge runs it as its delegate. The host-local plugin picks 10.244.1.5 from the range of this Node and returns it to the caller.
Play from step 3 -
The runtime then runs the next plugin in the list. It passes the previous result in as prevResult, so portmap adds to what bridge already produced instead of starting over. That ordered list is what the word chain means here.
Play from step 4 -
The last plugin prints one result on stdout: the interfaces the chain made, the addresses on them, the routes and the DNS. The one inside the sandbox namespace comes up as eth0 carrying 10.244.1.5, and the operation finishes as ADD ok.
Play from step 5 -
Only now does the Kubelet start the app containers. They join the namespace that is already wired, so all of them answer on that one Pod IP. On delete the runtime runs the same list with CNI_COMMAND=DEL, in reverse order, and each plugin releases what it made.
Play from step 6