Cloud Native 8 min read

How Kubernetes Assigns IPs to Pods: Flannel, CNI, and CRI Explained

This article explains how Kubernetes ensures each Pod gets a unique IP address by detailing the roles and interactions of Flannel, CNI plugins, the CRI, and the kube‑controller‑manager, and shows the configuration steps needed for container runtimes like containerd.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
How Kubernetes Assigns IPs to Pods: Flannel, CNI, and CRI Explained

Kubernetes requires each Pod to have a unique IP address for communication. This article explains how Pods obtain IPs, focusing on the interaction of network components such as CNI plugins, the CRI, and the kube‑controller‑manager, using Flannel as the network provider and containerd as the container runtime.

Container Network Basics

On a single host, containers communicate via a Linux Bridge and veth pairs: one end of the veth resides in the container’s network namespace, the other connects to the host’s bridge, which also holds an IP address acting as a gateway for Pod traffic.

Across multiple hosts, Flannel uses VXLAN packet encapsulation over UDP to route traffic between Pods on different nodes.

CRI and CNI Overview

The Container Runtime Interface (CRI) allows kubelet to use different container runtimes. CNI (Container Network Interface) provides a plugin framework for configuring Pod networks. Both are invoked during Pod creation.

Node IPAM Controller

When the nodeipam controller is enabled via the --controllers flag, the kube‑controller‑manager assigns each node a dedicated subnet (podCIDR) from the cluster CIDR, ensuring unique Pod IPs. Nodes receive their podCIDR on first registration; changes require node re‑registration.

Flannel Configuration

Flannel’s daemon (flanneld) creates a VXLAN device on each node, retrieves network metadata from the API server, and generates CNI configuration files (e.g., /etc/cni/net.d/10-flannel.conflist). It assigns routes so Pods can reach each other by IP.

Interaction Between Components

When a Pod is scheduled, kubelet calls the container runtime (containerd) via the CRI plugin, which then invokes the appropriate CNI plugin (Flannel). Flannel may call the Bridge CNI plugin, which creates a Linux bridge (cni0) and veth pairs, and finally the host‑local IPAM plugin supplies IP addresses, storing allocation data under /var/lib/cni/networks/<network-name=cni0>/<ip>.

Summary

The kube‑controller‑manager allocates non‑overlapping podCIDRs to nodes, enabling unique IP assignment for every Pod. Administrators configure kubelet, container runtime, and network provider, distribute CNI plugins to nodes, and rely on the CRI‑CNI interaction to provision Pod networking.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

KubernetesCNIPod IPcontainer-runtimeFlannelNetwork Plugins
MaGe Linux Operations
Written by

MaGe Linux Operations

Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.