Skip to content
Visual explainer 3h to learn 4 steps

Pod networking & CNI

Explain the Kubernetes network model and confirm the CNI is healthy.

By Invicly Tech, , in Kubernetes Administrator (CKA). About 9 minutes to read.

Topic 18 of 33

In short

Kubernetes gives every Pod its own IP, and every Pod can reach every other Pod without NAT. The cluster does not implement this itself; a CNI plugin such as Calico, Cilium or Flannel wires up Pod interfaces and routes. If the CNI is broken, Pods stay ContainerCreating and nodes go NotReady.

Explained simply

In Kubernetes every Pod gets its own IP address, like a small computer on the network. Any Pod can talk to any other Pod using that IP, even if they run on different machines. Nobody has to map ports or translate addresses in between.

Kubernetes sets this rule but does not build the network itself. A plugin does, following a standard called CNI (Container Network Interface). Popular plugins are Calico, Cilium and Flannel. You install one right after kubeadm init, and until you do, nodes stay NotReady.

Inside a Pod, all containers share one network. They see the same IP and can reach each other on localhost, just like programs on one laptop. A tiny hidden container (often called the pause container) holds that shared network open for the Pod.

Pod IPs change every time a Pod is recreated, so apps should never hard-code them. For a stable address you put a Service in front, which is the next topic.

Press Play on a diagram to walk through it one step at a time.

FlowPod-to-Pod across nodes
  1. 1
    Pod A eth0

    Sends to Pod B's IP.

  2. 2
    veth pair

    Connects the Pod namespace to the node.

  3. 3
    Node A routing

    CNI routes or encapsulates by Pod CIDR.

  4. 4
    Network or overlay

    Direct routes, VXLAN or eBPF.

  5. 5
    Node B to Pod B

    Delivered through Pod B's veth.

LayersThe networking stack of one Pod
  1. 1
    Containers

    Share one IP; talk over localhost

  2. 2
    Pod network namespace

    Held open by the pause container

  3. 3
    eth0 inside the Pod

    One end of the veth pair

  4. 4
    veth on the node

    Connected to a bridge or routes

  5. 5
    Node routing or overlay

    Set up by the CNI plugin

  6. 6
    Physical network

    Carries traffic between nodes

In depth

What happens when a Pod gets its network

The kubelet asks the container runtime (containerd or CRI-O) to create a Pod sandbox. The runtime creates a new network namespace, which is an isolated copy of the network stack, then runs the CNI plugin named in the first config file (by name order) in /etc/cni/net.d, with the ADD command. The plugin binary comes from /opt/cni/bin.

The plugin creates a veth pair, a virtual cable with one end inside the Pod (eth0) and one end on the node. Its IPAM part (IP address management) picks a free IP from the node's range, then it sets routes so traffic can leave. When the Pod is deleted, the runtime calls the plugin again with DEL to release the IP. If any of this fails, the Pod stays ContainerCreating with a FailedCreatePodSandBox event.

SequenceWiring up one Pod
kubelet
containerd
CNI plugin
Node kernel
  1. 1RunPodSandbox (CRI call)
    kubelet to containerd: RunPodSandbox (CRI call)
  2. 2Create network namespace
    containerd to Node kernel: Create network namespace
  3. 3CNI ADD with netns and config
    containerd to CNI plugin: CNI ADD with netns and config
  4. 4Create veth pair, assign IP, add routes
    CNI plugin to Node kernel: Create veth pair, assign IP, add routes
  5. 5Result: Pod IP
    CNI plugin to containerd: Result: Pod IP
  6. 6Sandbox ready, start containers
    containerd to kubelet: Sandbox ready, start containers

Pod CIDR, Service CIDR and where to find them

Three address ranges must not overlap: the node network (your VMs), the Pod CIDR and the Service CIDR. With kubeadm you set the Pod range with kubeadm init --pod-network-cidr, for example 10.244.0.0/16, and the Service range defaults to 10.96.0.0/12.

The controller manager can slice the Pod range into one block per node (a /24 by default for IPv4) and write it to node.spec.podCIDR. Some plugins ignore that and run their own IPAM, such as Calico IP pools or Cilium's cluster pool, so the real source of truth is the plugin's own config. To read the cluster values, look at the static Pod manifests: --cluster-cidr in kube-controller-manager.yaml and --service-cluster-ip-range in kube-apiserver.yaml.

  • grep cluster-cidr /etc/kubernetes/manifests/kube-controller-manager.yaml
  • grep service-cluster-ip-range /etc/kubernetes/manifests/kube-apiserver.yaml
  • kubectl get nodes -o custom-columns=NAME:.metadata.name,CIDR:.spec.podCIDR

Same node versus different nodes

On the same node, traffic between two Pods never leaves the machine. Some plugins connect all veths to a Linux bridge (Flannel uses one called cni0); others, like Calico, use plain routes, one per Pod IP.

Across nodes there are two styles. Routed (or native) mode sends packets with their real Pod IPs, and the underlying network must know which node owns which Pod range; Calico can share these routes with BGP on TCP port 179. Overlay mode wraps each packet inside another packet addressed node to node, usually VXLAN on UDP port 8472 for Flannel and Cilium. Overlays work on any network but add about 50 bytes per packet, so the Pod MTU must be smaller than the node MTU, or large requests mysteriously hang.

CompareRouted versus overlay networking
Routed (native)
  • Packets keep Pod IPs
  • Network must know Pod routes
  • No extra header, full MTU
  • Calico BGP, cloud VPC routes
Overlay (VXLAN)
  • Packets wrapped node to node
  • Works on any flat network
  • About 50 bytes overhead
  • Flannel default, Cilium option

Checking that the CNI is healthy

Start with the nodes: a node without a working CNI reports Ready False with a message like container runtime network not ready, cni plugin not initialized. Next, list the plugin Pods in kube-system (or their own namespace, such as calico-system or kube-flannel). They are usually a DaemonSet, so there should be one Ready Pod per node.

Then test the data path: run two Pods on different nodes and ping or wget between their IPs. If same-node works but cross-node fails, suspect the overlay ports being blocked by a firewall or cloud security group, or an MTU mismatch. Remember that kube-proxy is not involved in Pod-to-Pod traffic at all; it only handles Service IPs.

  • ls /etc/cni/net.d /opt/cni/bin on the node
  • kubectl get ds -A | grep -Ei 'calico|cilium|flannel'
  • ip route on a node shows the Pod routes the plugin added

Learn it in 4 short steps

About 45m each. Track them with a timer in your plan.

  1. 1
    Explain the Kubernetes network model~45m
  2. 2
    Trace Pod-to-Pod traffic~45m
  3. 3
    Check CNI Pods and configuration~45m
  4. 4
    Find Pod CIDR settings~45m

Key points

  • Each node usually gets a Pod CIDR slice from the cluster Pod range.
  • CNI config lives in /etc/cni/net.d and plugin binaries in /opt/cni/bin.
  • Pod IPs are ephemeral; use Services for stable addresses.
  • Flannel does not enforce NetworkPolicies; Calico and Cilium do.

Key terms

Tap a card to flip it. 0/5 known

Examples

bash
kubectl get pods -n kube-system -o wide | grep -Ei "calico|cilium|flannel"
ls /etc/cni/net.d/
kubectl get nodes -o jsonpath='{.items[*].spec.podCIDR}'
kubectl -n kube-system get cm kubeadm-config -o yaml | grep -i subnet
kubectl get pods -o wide   # Pod IPs and nodes

Proving Pod-to-Pod traffic across nodes

Step 1: start two Pods pinned to different nodes with nodeName overrides. Step 2: read their IPs with -o wide. Step 3: from Pod a, fetch a page from Pod b's IP directly, with no Service. Step 4: if it times out but works when both Pods are on one node, the cross-node path (overlay ports, routes or MTU) is broken.

bash
kubectl run a --image=busybox:1.36 --overrides='{"apiVersion":"v1","spec":{"nodeName":"node01"}}' -- sleep 3600
kubectl run b --image=nginx:1.27 --overrides='{"apiVersion":"v1","spec":{"nodeName":"node02"}}'
kubectl get pods a b -o wide
B_IP=$(kubectl get pod b -o jsonpath='{.status.podIP}')
kubectl exec a -- wget -qO- -T 3 http://$B_IP | head -4
kubectl exec a -- ip addr show eth0

A fresh cluster where every node is NotReady

After kubeadm init and join, kubectl get nodes shows NotReady and the CoreDNS Pods are Pending. Step 1: describe a node and read the Ready condition message about the CNI. Step 2: check /etc/cni/net.d on the node; it is empty. Step 3: install a CNI plugin whose Pod range matches --pod-network-cidr. Step 4: watch the nodes turn Ready and CoreDNS start.

bash
kubectl get nodes
kubectl describe node cp1 | grep -i 'network'
ls /etc/cni/net.d/              # empty: no plugin installed
kubectl apply -f https://github.com/flannel-io/flannel/releases/latest/download/kube-flannel.yml
kubectl get nodes -w
kubectl -n kube-system get pods -l k8s-app=kube-dns

Quick reference

  • Network model: every Pod has its own IP and reaches every other Pod without NAT
  • CNI config: /etc/cni/net.d (first file wins); binaries: /opt/cni/bin
  • kubeadm init --pod-network-cidr=10.244.0.0/16 sets the Pod range (Flannel's default)
  • kubeadm's default Service range is 10.96.0.0/12
  • VXLAN overlays use UDP 8472 (Flannel, Cilium); Calico BGP uses TCP 179
  • Containers in one Pod share the network namespace and use localhost
  • kube-proxy handles Service IPs only, never plain Pod-to-Pod traffic

Common mistakes

  • Confusing the Pod CIDR with the Service CIDR.
  • Choosing a Pod CIDR that overlaps the node network.

Quick quiz

Pick an answer to see if you're right and why.

Question 1

1Two containers in the same Pod need to talk. Which address should one use to reach the other?

Question 2

2Pods on the same node can talk, but Pods on different nodes cannot. What is the least likely cause?

Question 3

3Which component calls the CNI plugin when a Pod is created?

Question 4

4Where do you read the Service IP range on a kubeadm control plane node?

0/4 answered

Practice exercises

Try each one yourself first. Use the hint if you get stuck, then compare with the solution.

  1. Exercise 1easy

    Find which CNI plugin your cluster uses and the Pod IP of every Pod in kube-system.

  2. Exercise 2medium

    Write the cluster's Pod CIDR and Service CIDR into /opt/cidrs.txt, one per line.

  3. Exercise 3hard

    On a node, find the veth interface that belongs to a given Pod.

Check yourself

Answer in your head, reveal, then be honest with yourself.

Feel confident about this topic?

Frequently asked questions

Which CNI plugin should I use?
For learning, Flannel is simplest but does not enforce NetworkPolicies. Calico and Cilium both enforce policies and are common in production; pick one and learn its basic checks.
Can Pods talk to each other across namespaces?
Yes. Namespaces do not isolate network traffic by themselves. Use NetworkPolicies if you need to block it.
Why is my Pod stuck in ContainerCreating with a sandbox error?
The CNI plugin failed to set up the Pod network, often because the plugin is not installed, its Pods are crashing, or it has run out of IPs. Read the Pod events and the CNI Pod logs.
ShareXLinkedInWhatsApp