Day 32/40 — Kubernetes Networking Explained | Container Network Interface (CNI)
Overview
Video 32 of the Certified Kubernetes Administrator (CKA) 2024 series. A collaboration with Saiyam Pathak (@kubesimplify) explaining how Kubernetes networking works under the hood — from Pod-to-Pod communication to the role of the Container Network Interface (CNI) and popular plugins.
Why Kubernetes Networking Is Different
Docker uses a single-host bridge network by default. Kubernetes must solve multi-node networking: every Pod gets a unique IP across the entire cluster, and any Pod must be able to reach any other Pod directly — regardless of which node they run on.
The CNI Specification
CNI (Container Network Interface) is a standardized specification (not a specific tool) that defines how container runtimes — like containerd or CRI-O — should configure network interfaces for Pods. Key responsibilities:
- IP Address Management (IPAM): Allocate unique Pod IPs within the cluster CIDR
- Network Interface Creation: Create virtual interfaces (veth pairs) connecting the Pod namespace to the node
- Routing / Overlay Setup: Ensure cross-node Pod-to-Pod traffic can flow (via overlay tunnels, BGP, or direct routing)
How CNI Works in Practice
- kubelet calls the CNI plugin (a binary in
/opt/cni/bin) every time a Pod is created. - The CNI plugin reads its configuration from
/etc/cni/net.d. - It allocates an IP address, creates the
vethpair, and sets up routes. - For cross-node traffic, CNI plugins use one of:
- Overlay networks (VXLAN, IPIP) — encapsulate packets for tunneling across nodes
- BGP / direct routing — advertise Pod routes to the underlying network (Calico)
- eBPF — kernel-level packet forwarding (Cilium)
Popular CNI Plugins
| Plugin | Model | Policy Support | Best For |
|---|---|---|---|
| Flannel | VXLAN overlay | ❌ No | Simple clusters, learning, no policy needs |
| Calico | BGP + optional VXLAN | ✅ Yes (L3/L4) | Production, default on GKE, policy-rich environments |
| Cilium | eBPF-based | ✅ Yes (L3/L4/L7 + DNS-aware) | Advanced security, observability, service mesh |
| Weave Net | Overlay | ⚠️ Deprecated | Legacy only; unreliable on K8s 1.30+ |
| AWS VPC CNI | AWS native ENIs | ✅ Yes (with add-on) | EKS workloads needing native VPC IPs |
| Azure CNI | Azure VNet | ✅ Yes | AKS with Azure Network Policy |
CNI and Network Policies
NetworkPolicies are not enforced by Kubernetes itself — they are enforced by the CNI plugin. If your CNI does not support policies (e.g., Flannel, kindnet), NetworkPolicy objects exist but have zero effect. Calico and Cilium are the go-to choices for policy-enabled clusters.
CNI on kubeadm Clusters
After kubeadm init, the cluster has no functional Pod network until a CNI is installed. Steps:
- Run
kubeadm initwith--pod-network-cidrmatching the CNI’s default pool. - Install the CNI (e.g., Calico manifests or Helm chart).
- Wait for CNI Pods to become Ready.
- Join worker nodes.
Trap: If
--pod-network-cidrmismatches the CNI’s default IP pool, nodes stayNotReadyand CoreDNS hangs inContainerCreating.
Key Takeaways
- CNI is a specification, not a product — plugins implement it.
- kubelet calls the CNI plugin for every Pod creation/deletion.
- CNI plugins handle IP allocation, veth creation, and cross-node routing.
- Flannel is simple but lacks policies; Calico is the production default; Cilium is the future with eBPF.
- NetworkPolicies require a policy-capable CNI — always verify plugin support before relying on them for security.
See Also
Wiki Concepts
- Kubernetes CNI — primary deep-dive on CNI specification, plugins, and architecture
- Kubernetes Network Policies — policy enforcement depends on CNI support
- Kubeadm Cluster Setup — CNI installation as part of cluster bootstrapping
- Kubernetes DaemonSet — CNI agents run as DaemonSets
- Kubernetes Architecture — kubelet and container runtime interaction with CNI
- Kubernetes Services — Service networking built on top of CNI-provided Pod connectivity
- CoreDNS — cluster DNS; CNI must be ready before CoreDNS Pods can start
- Why Kubernetes? — pluggable networking as a core K8s strength
- Networking Concepts Index — domain landing page
Related Sources
- 40 — Understanding CoreDNS In Kubernetes — cluster DNS prerequisite
- 40 — Kubernetes Network Policies Explained — policy design depends on CNI
- 40 — Setup a Multi Node Kubernetes Cluster Using Kubeadm — CNI installation step
Creator / Entity
- Tech Tutorials with Piyush — CKA 2024 series creator
- Saiyam Pathak — CNI and cloud-native educator (@kubesimplify)