Network
Cilium and eBPF
Identity instead of IPs
The same cluster, its network rebuilt on Cilium: flannel, Calico and kube-proxy replaced by one DaemonSet and a set of eBPF programs loaded into each node's kernel. Pods keep plain IPs and the tunnel still costs its bytes per packet - what changes is who enforces policy (maps, not chains) and what a packet carries: the Pod's labels, as a number, ride along with it.
- Replaces
- flannel · Calico · kube-proxy
- Data path
- eBPF at every veth · maps, not iptables chains
- Identity
- labels → a number · rides the tunnel
- Tunnel
- Geneve · UDP 6081 · +50 B, like VXLAN
Read the whole lesson as text
1. New plumbing
This cluster grew up on flannel for connectivity, Calico for policy and kube-proxy for Services. Rebuilt on Cilium, all three go: one cilium-agent Pod per node, and a set of eBPF programs the agent compiles and loads into each kernel. An eBPF program is a small, verified piece of code the kernel runs on an event - here, on every packet that crosses a Pod's veth. The agent does the watching and the writing; the programs do the forwarding, the rewriting and the dropping. kube-proxy was deleted outright.
- You install one thing: a DaemonSet that puts an agent on every node.
- The DaemonSet is stored, and the usual machinery starts one agent Pod per node.
- node-1's agent starts in the host network namespace and opens its watches.
- node-2's agent does the same, independent of its neighbor.
- The agent compiles the datapath and loads it: programs at every veth, a tunnel device, and a fistful of maps.
- node-2 gets the same programs - and loses its old plumbing.
2. An identity, not an IP
web-…-kq9tw starts on node-1 and containerd calls the CNI plugin as always - except the plugin, cilium-cni, hands the work to the agent. The agent wires the veth and does something flannel never did: it gives the Pod's set of labels a number. If any Pod in the cluster already has exactly these labels, it reuses that number; if not, it allocates a new one. For app=web the number is 15361. The identity, not the IP, is what policy will be written against. The agent records the pairing in a map every program can read: 10.244.1.12 → identity 15361, reachable over the tunnel at 10.0.1.11.
- The kubelet sees the new Pod and asks for a sandbox, as in every lesson before.
- containerd invokes the CNI plugin - which is now the agent itself.
- The labels get a number - identity 15361. Policy will be checked against this, never against IPs.
- The identity is posted to the API, and every other agent's watch delivers it.
3. Policy in a map
The NetworkPolicy from the last lesson still exists, unchanged - app:api allows ingress from app:web on TCP 8080. Calico translated those labels into IP sets and iptables chains on every node. The agent on node-2 does something smaller: it computes the verdict table for the api Pod's veth - identity 15361 → TCP 8080 → allow - and writes it into one BPF map. The kernel does the rest.
- node-2's agent hears about the same policy and compiles its half of it.
- The whole policy becomes one entry in a map beside the api Pod's veth.
- A fourth web Pod appears on node-1 - and node-2's kernel doesn't change at all.
- The only write anywhere is a routing fact: this new IP also belongs to 15361.
4. Out through the veth
kq9tw curls the api Pod directly, as in the policy lesson: 10.244.1.12 → 10.244.2.19:8080. The SYN leaves the container and the first thing it meets is not a bridge port but the agent's program on the veth. It checks egress - no egress policy selects kq9tw, allow - then asks the ipcache about the destination: 10.244.2.19 is identity 16001, on the far side of the tunnel. So the program hands the packet to the cilium_geneve device for the trip: Geneve this time, UDP 6081. The 24-bit network ID in the header, which flannel set to 1 for every packet, now carries kq9tw's own identity: 15361.
- The SYN's first stop is a program on the veth - not a bridge port, not an iptables chain.
- The map answers in one lookup: that address is identity 16001, across the tunnel on node-2.
- The packet is wrapped in Geneve, and the header's network ID is kq9tw's identity.
- To the underlay it's one ordinary UDP packet - port 6081 instead of 8472, nothing else new.
5. Across the underlay
One plain UDP packet between the two nodes. Everything Cilium computed - verdict, tunnel, identity - travels inside it; the network between the nodes learns nothing. Routers between the nodes only read the outer header, exactly as under flannel. The difference is the number in the VNI field.
- One UDP packet crosses the underlay, carrying the sender's identity in its 24-bit VNI.
6. The verdict on arrival
node-2's tunnel program unwraps the packet and reads the VNI: source identity 15361. It doesn't ask the API server, an IP set, or any other node - the label came with the packet. One more hop to the api Pod's veth, where the program does the entire policy check: look up (identity 15361, TCP, 8080) in the map. The entry says ALLOW. The SYN crosses into the Pod's namespace about 0.4 ms after connect().
- The tunnel program unwraps and reads the identity straight out of the VNI.
- At the api Pod's veth, the entire policy is one lookup - and the entry says allow.
- The SYN crosses into the Pod and the connection begins - indistinguishable from the flannel cluster.
- The SYN-ACK rides back with api's own identity in the VNI.
7. The drop, rediscovered
busybox tries the same call - and its labels map to identity 46321, which no rule mentions. The trip is identical until the last lookup: map[(46321, TCP, 8080)] isn't there. No rule matched, nothing fell through - the miss itself is the verdict, the default deny. The SYN dies at the veth, before the Pod's namespace; TCP retransmits, curl times out. The same silence as the Calico drop, arrived at without a single iptables chain.
- busybox's SYN takes the identical road, carrying a different number.
- The lookup misses. In a map, that is the whole verdict.
- The packet dies at the veth, and the app hears silence until curl gives up.
8. Services without kube-proxy
One kube-proxy job is left: turning Service addresses into Pod addresses. With kube-proxy deleted, the agent's programs do it, and the cleverest one isn't on any network device. When busybox connects to the web Service - 10.96.120.15:80 - a BPF hook on the connect() call itself looks up the backends, picks one at random - this time web-…-kq9tw, which happens to be on this node - and rewrites the socket's destination to 10.244.1.12:8080 before a single packet exists. The ClusterIP packet is never built.
- The tables kube-proxy maintained are gone - no chain walks for anything anymore.
- The connect() call itself is intercepted; the socket is pointed at a local Pod before any packet exists.
- One plain packet between two Pods on one node - that's the whole Service call.
Summary
Cilium's bet: the kernel can run the whole network if you can program it. The agent turns labels into identities, identities into map entries, and loads small verified programs at every veth and tunnel device. Packets carry their Pod's identity across the tunnel, so policy is one hash lookup anywhere in the cluster - no IP sets, no chain walks, nothing to rewrite when Pods move. Services become map lookups too - sometimes before a packet even exists.
Next lesson: Service mesh with Istio