Skip to content
LF Cert Trainer

Lesson 111 · Section 9: Networking

Lesson 111: Pod Networking: one flat network for every Pod

Kubernetes ships no Pod network, only rules: every Pod gets its own IP, and all Pods reach each other on any node without NAT. This lesson builds such a network by hand with bridges, veth pairs and routes, then shows how that script becomes a CNI plugin. · 17 min read · 4 min video

1/10Pod Networking
0:00 / 3:49

Narrated by the local narrator voice. Keys: Space plays and pauses, J and L step, C captions, F full screen.

What this lesson is about

The Cluster Networking lesson ended with four problems. This lesson solves the second one: Pod to Pod. It is the layer everything else stands on. Services, DNS, Ingress and network policies all assume that any Pod can already reach any other Pod by its address.

Kubernetes has a surprising position here: it does not include a Pod network. It defines what the network must do and expects you to install something that does it. To understand what that "something" has to achieve, this lesson builds a working Pod network from the pieces you already know (namespaces, veth pairs, bridges, routes) and then turns the result into a CNI plugin.

The model

The documentation calls it the Kubernetes network model:

  1. Each Pod gets its own unique, cluster-wide IP address. All containers of the Pod share it.
  2. All Pods can communicate with all other Pods, on the same node or on different nodes, directly, without proxies or address translation (NAT).
  3. Agents on a node (the kubelet, system daemons) can communicate with all Pods on that node.
The rules of the Pod networknode01node02same nodeby Pod IP, no NATnode to PodPod A10.244.1.2Pod B10.244.1.3kubeletprobes its PodsPod C10.244.2.2
The rules of the Pod network. Kubernetes does not say how to build the network. It says what must be true: every Pod has its own address, Pods reach Pods on any node by that address without NAT, and the node's own agents reach its Pods.

Parts:

  • Pod A (10.244.1.2), in node01
  • Pod B (10.244.1.3), in node01
  • kubelet (probes its Pods), in node01
  • Pod C (10.244.2.2), in node02

Connections:

  • Pod A and Pod B: same node
  • Pod A and Pod C: by Pod IP, no NAT
  • kubelet to Pod B: node to Pod

Compare this with Docker on a single host, where containers on different hosts needed published ports. The model removes all of that. A Pod behaves like a small virtual machine on one big flat network:

  • A program can listen on its natural port (80, 5432) in every Pod, because each Pod has its own address.
  • The address a Pod sees as its own is the address others use to reach it. Nothing is rewritten in between.
  • No Pod needs to know which node another Pod runs on.

What the model leaves open is how this is built, which address range is used and how nodes are connected. Those are the plugin's choices.

One Pod, one namespace

The unit that gets an address is the Pod, not the container. When a Pod starts, the container runtime first creates the Pod sandbox: a network namespace, held open by a tiny container that runs the pause image. The CNI plugin wires that namespace. Then every container of the Pod is started inside it.

One Pod, one network namespacePod webjoinscallshaspause containerowns the namespacenginxlistens on :80log agentcurl localhost:80eth010.244.1.2
One Pod, one network namespace. The pause container owns the Pod's namespace and its eth0. Every other container of the Pod joins that namespace, so they share one address and reach each other on localhost.

Parts:

  • pause container (owns the namespace), in Pod web
  • nginx (listens on :80), in Pod web
  • log agent (curl localhost:80), in Pod web
  • eth0 (10.244.1.2), in Pod web

Connections:

  • nginx to pause container: joins
  • log agent to nginx: calls
  • pause container to eth0: has

The consequences:

  • Containers of one Pod reach each other on localhost.
  • They share one set of ports. Two containers in the same Pod cannot both listen on port 80.
  • If an application container crashes and restarts, the Pod keeps its address, because the pause container and the namespace stay. The address only changes when the Pod is replaced.

Building a Pod network by hand

Take a cluster with two worker nodes on the node network 192.168.1.0/24 and the Pod range 10.244.0.0/16:

NodeNode addressIts slice of the Pod rangeBridge address
node01192.168.1.1110.244.1.0/2410.244.1.1
node02192.168.1.1210.244.2.0/2410.244.2.1

Step 1: a bridge on each node

Each node gets a bridge, the local network of its Pods. Each bridge gets a different subnet, because Pod addresses must be unique across the cluster.

# on node01
ip link add cni0 type bridge
ip link set cni0 up
ip addr add 10.244.1.1/24 dev cni0

# on node02
ip link add cni0 type bridge
ip link set cni0 up
ip addr add 10.244.2.1/24 dev cni0

Step 2: connect each Pod

For every new Pod, with its namespace path in $NETNS:

ip link add veth-a type veth peer name veth-a-br      # a virtual cable
ip link set veth-a-br master cni0 up                  # one end into the bridge

ip link set veth-a netns "$NETNS" name eth0           # the other end into the Pod, as eth0
ip -n "$NETNS" addr add 10.244.1.2/24 dev eth0        # a free address from this node's slice
ip -n "$NETNS" link set eth0 up
ip -n "$NETNS" route add default via 10.244.1.1       # the bridge is the gateway

After this, all Pods of node01 reach each other through the bridge, and the node reaches them because it has an address on the same bridge. Rules 1 and 3 hold, and rule 2 holds within one node.

Step 3: connect the nodes

A Pod on node01 pings 10.244.2.2. The packet follows the Pod's default route to the bridge, and then node01 must forward it. It has no route for 10.244.2.0/24, so the packet goes to the default gateway and is lost. Each node needs to know where the other slices are:

# on node01
ip route add 10.244.2.0/24 via 192.168.1.12

# on node02
ip route add 10.244.1.0/24 via 192.168.1.11
Two nodes, one Pod networknode01node02veth, default route10.244.2.0/24 via .12to .12arrives10.244.2.0/24 is localvethPod A10.244.1.2cni010.244.1.1/24eth0192.168.1.11Node network192.168.1.0/24eth0192.168.1.12cni010.244.2.1/24Pod C10.244.2.2
Two nodes, one Pod network. Each node has a bridge with its own slice of the Pod range. A route on every node sends the other node's slice to that node's address, so the Pod's packet arrives unchanged.

Parts:

  • Pod A (10.244.1.2), in node01
  • cni0 (10.244.1.1/24), in node01
  • eth0 (192.168.1.11), in node01
  • Node network (192.168.1.0/24)
  • eth0 (192.168.1.12), in node02
  • cni0 (10.244.2.1/24), in node02
  • Pod C (10.244.2.2), in node02

Connections:

  • Pod A to cni0: veth, default route
  • cni0 to eth0: 10.244.2.0/24 via .12
  • eth0 to Node network: to .12
  • Node network to eth0: arrives
  • eth0 to cni0: 10.244.2.0/24 is local
  • cni0 to Pod C: veth

Now the packet from Pod A to Pod C travels: veth, bridge on node01, route to 192.168.1.12, across the node network, bridge on node02, veth, Pod C. Source and destination address are the Pod addresses the whole way. That is rule 2.

With more nodes the number of routes grows: every node needs one route per other node. You can put them on each node, or put all of them on the router of the node network, if all nodes use it as their gateway. Either way, the separate /24 bridges now act as one network, 10.244.0.0/16.

Step 4: automate it

Typing step 2 for every Pod is impossible in a cluster where Pods come and go every minute. Put it in a script:

#!/bin/sh
# net-script.sh <ADD|DEL> <container-id> <netns-path>
case "$1" in
  ADD)
    # create the veth pair
    # attach one end to cni0
    # move the other end into the namespace as eth0
    # choose a free IP from this node's slice and assign it
    # bring the interfaces up, add the default route
    ;;
  DEL)
    # delete the veth pair
    # give the IP address back
    ;;
esac

This is where the previous lessons meet. A program that connects a namespace on ADD, cleans up on DEL and follows the CNI conventions for parameters and output is a CNI plugin. The container runtime is configured with the directory of plugin binaries and the directory of network configuration, and for each Pod sandbox it creates, it runs the plugin:

  1. kubelet asks the runtime for a sandbox
  2. Runtime creates the network namespace
  3. Runtime runs the CNI plugin with ADD
  4. Plugin wires eth0 and returns the IP
  5. kubelet reports the IP in the Pod status
A new Pod gets its address

The lesson CNI in Kubernetes shows the directories and the configuration on a real node. The lesson after it looks at how a plugin chooses free addresses.

How real plugins connect the nodes

Steps 1, 2 and 4 look much the same in most plugins. Step 3 is where they differ, because static routes typed by hand do not scale and do not work on every network.

Two ways to carry Pod traffic between nodessendssosendssoDirect routinga route per nodePacket unchangedfrom Pod IP to Pod IPNeedsroutes on the networkOverlayVXLAN, IP-in-IPPacket wrappedouter: node IPsWorks anywhereabout 50 bytes of MTU
Two ways to carry Pod traffic between nodes. Direct routing sends the Pod's packet as it is and needs a network that accepts the routes. An overlay wraps it in a packet between node addresses and works on any network, at the price of a smaller MTU.

Parts:

  • Direct routing (a route per node)
  • Packet unchanged (from Pod IP to Pod IP)
  • Needs (routes on the network)
  • Overlay (VXLAN, IP-in-IP)
  • Packet wrapped (outer: node IPs)
  • Works anywhere (about 50 bytes of MTU)

Connections:

  • Direct routing to Packet unchanged: sends
  • Packet unchanged to Needs: so
  • Overlay to Packet wrapped: sends
  • Packet wrapped to Works anywhere: so
ApproachHow a packet crosses nodesNeedsExamples
Direct routingUnchanged. Each node has a route per other node's slice, maintained by the pluginNodes on the same layer 2 network, or a network that learns the routes (BGP, cloud route tables)Flannel host-gw, Calico with BGP, cloud provider plugins
OverlayWrapped ("encapsulated") in a packet from node address to node address, unwrapped on arrivalOnly that nodes reach each other, plus an open tunnel portFlannel VXLAN, Calico VXLAN or IP-in-IP, Cilium VXLAN or Geneve

An overlay does not break rule 2. The wrapping happens between the nodes. The Pods at both ends see the original packet with Pod addresses, and no address is translated.

Under the hood · What an overlay costs, and how nodes get their slices

MTU. The wrapper needs space. VXLAN adds 50 bytes, so on a network with an MTU of 1500 the Pod interfaces get 1450. Plugins set this themselves. When the MTU is wrong, small requests work and large transfers hang, which is one of the more confusing network faults.

Where the slices come from. With kubeadm init --pod-network-cidr=10.244.0.0/16, the controller manager runs with --allocate-node-cidrs=true and gives each node a slice in spec.podCIDR:

kubectl get nodes -o custom-columns=NAME:.metadata.name,PODCIDR:.spec.podCIDR
NAME           PODCIDR
controlplane   10.244.0.0/24
node01         10.244.1.0/24
node02         10.244.2.0/24

Flannel reads these slices. Calico and Cilium by default manage their own address pools and ignore spec.podCIDR, so in such clusters the Pod addresses on a node need not match that field.

No bridge at all. A bridge per node is the classic design, and it is what the reference bridge plugin and Flannel build. Calico instead gives each Pod a /32 route on the node and no bridge. Cilium attaches eBPF programs to the Pod's veth. The rules of the model are the same. Only the wiring differs.

Using it

Example · Verify the model on a running cluster

Start two Pods and force them onto different nodes, then test by Pod address.

kubectl run pod-a --image=nginx:1.29-alpine --overrides='{"spec":{"nodeName":"node01"}}'
kubectl run pod-c --image=nginx:1.29-alpine --overrides='{"spec":{"nodeName":"node02"}}'
kubectl get pods -o wide
NAME    READY   STATUS    RESTARTS   AGE   IP           NODE
pod-a   1/1     Running   0          20s   10.244.1.2   node01
pod-c   1/1     Running   0          15s   10.244.2.2   node02
kubectl exec pod-a -- wget -qO- -T 2 http://10.244.2.2 | head -n 4       # Pod to Pod, across nodes
ssh node02 curl -s -o /dev/null -w '%{http_code}\n' http://10.244.2.2    # node to its own Pod
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
200

Each Pod has its own address from its node's slice, the Pods reach each other across nodes on port 80 without any port mapping, and the node reaches its Pod.

Example · Prove that there is no NAT between Pods

nginx logs the address of each client. Call pod-c from pod-a and read the log:

kubectl exec pod-a -- wget -qO- http://10.244.2.2 >/dev/null
kubectl logs pod-c --tail=1
10.244.1.2 - - [02/Dec/2026:14:31:07 +0000] "GET / HTTP/1.1" 200 615 "-" "Wget" "-"

The server sees 10.244.1.2, the real address of pod-a, not a node address. That is the "without NAT" rule, and it is what makes network policies and access logs meaningful.

Example · See the shared namespace of a multi-container Pod

apiVersion: v1
kind: Pod
metadata:
  name: web
spec:
  containers:
    - name: nginx
      image: nginx:1.29-alpine
    - name: tools
      image: busybox:1.37
      command: ["sleep", "3600"]
kubectl apply -f web.yaml
kubectl exec web -c tools -- wget -qO- http://localhost:80 | grep title
kubectl exec web -c nginx -- hostname -i
kubectl exec web -c tools -- hostname -i
<title>Welcome to nginx!</title>
10.244.1.5
10.244.1.5

The tools container reaches nginx on localhost, and both containers report the same address: one namespace, one eth0.

Example · Troubleshoot: Pods on different nodes cannot reach each other

pod-a reaches Pods on node01 but times out for 10.244.2.2. Work along the path of the packet.

kubectl get pods -o wide                         # 1. addresses and nodes: is the target Running?
ssh node01 ip route get 10.244.2.2               # 2. does node01 know the way?
ssh node01 sysctl net.ipv4.ip_forward            # 3. may node01 forward?
ssh node02 ip route get 10.244.1.2               # 4. the way back
kubectl get pods -A -o wide | grep -iE 'flannel|calico|cilium|weave'   # 5. is the plugin running on both nodes?
10.244.2.2 via 192.168.1.1 dev eth0 src 192.168.1.11 uid 0

Step 2 answers with the default gateway instead of node02 or a tunnel interface: node01 has no route for node02's slice. The plugin's Pod on one of the two nodes is not doing its job. Look at that Pod (kubectl logs, kubectl describe), and check that the plugin's ports are open between the nodes.

Example · Troubleshoot: Pods stuck in ContainerCreating

kubectl describe pod web | tail -n 4
Events:
  Type     Reason                  Age   From     Message
  Warning  FailedCreatePodSandBox  12s   kubelet  Failed to create pod sandbox: rpc error: ... plugin type="flannel" failed (add): failed to find plugin "flannel" in path [/opt/cni/bin]

The scheduler placed the Pod, the runtime created the sandbox and called the plugin, and the ADD failed. The message names the reason: the binary is missing on that node. Other frequent messages are network plugin is not ready: cni config uninitialized (no configuration in /etc/cni/net.d, the node is also NotReady) and failed to allocate for range (the node's slice has no free address left).

Tricks

Common mistakes

  • Expecting a Pod network right after kubeadm init. There is none until you install a CNI plugin. Nodes are NotReady and CoreDNS is Pending until then.
  • Thinking each container has its own IP. The Pod has it. Containers of a Pod share the namespace, the address and the port space.
  • Running two containers of one Pod on the same port. The second one fails with address already in use.
  • Storing Pod IPs in configuration. A Pod's address is stable only for the life of that Pod. Use a Service for anything lasting.
  • Giving all nodes the same Pod subnet. Addresses repeat and routing between nodes is impossible. Each node needs its own slice.
  • Blaming the application when only cross-node traffic fails. Check forwarding, routes and the plugin's ports between nodes.
  • Believing an overlay means NAT. Encapsulation keeps the Pod addresses intact. The receiving Pod still sees the sender's Pod IP.

Recap

  • Kubernetes defines the Pod network model and ships no implementation: every Pod has a unique IP, all Pods reach each other on any node without NAT, and node agents reach their Pods.
  • A Pod is one network namespace, held by the pause container and shared by all its containers.
  • On each node a plugin connects Pods with veth pairs, usually to a bridge with the node's own slice of the Pod range.
  • Between nodes, traffic travels by direct routes or through an overlay tunnel. Both keep the Pod addresses.
  • The steps are automated in a CNI plugin, which the container runtime runs with ADD and DEL for each Pod.
  • Troubleshoot by comparing same-node and cross-node traffic, and read FailedCreatePodSandBox events for plugin errors.

Official docs

Quiz: check what you learned

5 questions on this lesson · about 3 min · instant feedback. Missed questions come back in your review queue.

Sign in to take the quiz and keep your score.

Discussion

Learners ask and answer questions here. Sign in to read and join the discussion.