kindnet
Here is how kindnet satisfies the two main CNI plugin requirements:
- Reachability is established by installing one static route per peer Node with NextHops pointing to the internal Node IPs. These routes get checked every 10 seconds to detect if there were any changes.
- Connectivity is established by a mix of reference CNI plugins –
ptpis used to create veth links,host-localto allocate IPs andportmapto configure port mappings. The configuration file gets generated by each of thekindnetddaemons on startup.
The diagram below shows how a fully converged routing table will look like:
Lab
This plugin is built into the Lab cluster by default, so the only thing required is to bring up the Lab environment
Here’s how to validate and verify the above diagram in the Lab environment, using the second Node as an example:
- Pod IP and default route
Pod IP should have a /24 subnet mask (same as PodCIDR) and the default route pointing to the first IP of that subnet.
Note
Note how the Pod routing is set up so that all the traffic, including the intra-subnet Pod-to-Pod communication, is sent over the same next-hop. This allows for all Pods to be interconnected via L3 without relying on a bridge or ARP for neighbor discovery.
- Node routing table
It should contain one /32 host-route per local Pod and one /24 per peer node.
- PodCIDR gateway
One notable thing is that the root namespace side of all veth links has the same IP address:
They each act as the default gateway for their peer Pods and don’t have to be attached to a bridge.
A day in the life of a Packet
Let’s track what happens when Pod-1 tries to talk to Pod-3.
Note
We’ll assume that the ARP and MAC tables are converged and fully populated.
- Pod-1 wants to send a packet to
10.244.0.5. Its network stack looks up the routing table to find the NextHop IP:
- The packet is sent down the veth link and pops out in the root network namespace of the host, which repeats the lookup:
- The packet gets L2-switches by the
kindbridge and enters the control-plane’s root network namespace:
- Finally, the packet arrives in the Pod-3’s network namespace where it gets processed by the local network stack:
SNAT functionality
In addition to the main CNI functionality, kindnet also sets up a number of IP masquerade (Source NAT) rules. These rules allow Pods to access the same networks as the hosting Node (e.g. Internet). The new KIND-MASQ-AGENT chain is inserted into the NAT’s POSTROUTING chain and includes a special RETURN rule to exclude all traffic in the cluster-cidr range (10.244.0.0/16):
Caveats and Gotchas
- Assumes all Nodes are in the same L2 domain.
- Relies on host-local, ptp, portmap and loopback reference plugins.