Skip to main content

CNI

CNI (Container Network Interface) is the standard that lets Kubernetes delegate pod networking to plugins such as Calico, Cilium, and Flannel. Without a working CNI plugin, nodes stay NotReady and pods cannot get IP addresses or talk to each other.

What CNI does

Kubernetes defines the networking rules (every pod gets its own IP and can reach every other pod) but ships no implementation. When the kubelet creates a pod sandbox, it calls the CNI plugin binary, which allocates an IP, creates a virtual ethernet (veth) pair connecting the pod to the node, and sets up routing.

sequenceDiagram participant K as Kubelet participant R as Runtime participant C as CNI plugin K->>R: Create pod sandbox R->>C: ADD network C->>C: Assign IP and veth C-->>R: Return pod IP R-->>K: Sandbox ready

Choosing a plugin

Plugin Strength
Calico Network policy, BGP routing
Cilium eBPF dataplane, deep observability, optional kube-proxy replacement
Flannel Simple overlay, no network policy support

Network policies are only enforced if the CNI supports them. On a CNI without support, NetworkPolicy objects are accepted but ignored.

Inspecting CNI on a node

Bash
ls /etc/cni/net.d/ # CNI configuration files
ls /opt/cni/bin/ # plugin binaries
kubectl get nodes -o jsonpath='{.items[*].spec.podCIDR}'

Troubleshooting

Symptom Likely cause Fix
Nodes NotReady, pods ContainerCreating No CNI installed or config missing Install a CNI, check /etc/cni/net.d
Sandbox creation fails CNI binary missing Check /opt/cni/bin
Cross-node pod traffic fails Routing or overlay broken Check CNI agent pods in kube-system
Remember

A fresh kubeadm cluster has no CNI. The control plane runs, but application pods will not start until you install one.

Common Mistake

Swapping CNIs on a live cluster. Existing pod networking breaks. Plan migrations carefully, ideally with a rebuilt or drained node pool.

Security

Without a policy-capable CNI and default-deny policies, any pod can reach any other pod in the cluster.

Frequently Asked Questions

Why does Kubernetes not include built-in networking?

Needs vary widely: simple flat networking, policy enforcement, datacenter BGP integration, eBPF performance. A pluggable interface lets each environment choose the implementation that fits.

What does a missing CNI look like?

Nodes show NotReady with a network plugin not ready message, and pods hang in ContainerCreating or Pending. kubectl describe node and describe pod show the error.

Does the CNI replace kube-proxy?

Not by default, but eBPF-based CNIs such as Cilium can replace kube-proxy entirely. Enable that mode before removing the kube-proxy DaemonSet.

Found a mistake, an outdated step or a broken link?