containerd Looks for CNI Plugins in One Directory, So a Path Mismatch Blocks Pod Networking
A Container Network Interface (CNI) plugin is not an API in the cluster: it's an executable on each node. When a pod starts, the container runtime creates its network namespace, then runs the CNI binaries to give it an IP and routes. The runtime only looks in one configured directory, so a plugin installed somewhere else simply doesn't exist for it.
The Handoff
- A new node joins as
NotReady: it has no pod network yet. - Installing a CNI such as Flannel or Calico puts a config file in
/etc/cni/net.d/and binaries on each node. - For each pod, the runtime (see kubelet Depends on containerd Through the CRI Socket) executes the plugin named in the config, which assigns an IP from the pod CIDR and wires the namespace to the node.
The Debian Path Mismatch
| Component | Expects or installs CNI binaries in |
|---|---|
| Upstream installers (kube-flannel, Cilium, the reference plugins) | /opt/cni/bin/ |
Debian's containerd package and its containernetworking-plugins |
/usr/lib/cni/ |
When they disagree, pods stay in ContainerCreating with cni plugin not initialized or failed to find plugin "flannel". With Cilium, the first symptom is CoreDNS stuck in ContainerCreating right after the install, while the node already shows Ready.
Fix: Point containerd at the Upstream Directory
Set the directory in /etc/containerd/config.toml, CRI plugin section, then restart containerd (running containers keep going):
[plugins."io.containerd.grpc.v1.cri".cni]
bin_dir = "/opt/cni/bin"
Check the result with sudo containerd config dump | grep bin_dir, not by reading config.toml: a drop-in merged after the main file can set its own bin_dir. The NVIDIA toolkit's 99-nvidia.toml carries a full copy of the CRI section, so it silently undid this fix on the GPU node (see containerd Merges Drop-in Files Through imports, So config dump Shows the Real Config).
The Symlink Workaround Is a Snapshot
A symlink also bridges the gap: the runtime opens the path it expects and lands on the real file.
sudo ln -sf /opt/cni/bin/cilium-cni /usr/lib/cni/cilium-cni
It's fine as an immediate fix for one plugin. As the standing fix it fails later: ln -sf /opt/cni/bin/* /usr/lib/cni/ links only the plugins present when it runs. Cilium installs cilium-cni when its agent starts, after node provisioning, so the link didn't exist and CoreDNS couldn't get a network. Prefer bin_dir: it covers plugins installed tomorrow too.
References
- Kubernetes MOC - hub for Kubernetes notes.
- containerd Merges Drop-in Files Through imports, So config dump Shows the Real Config - why
config.tomlalone can't prove the fix. - When Kubelet Dies Silently - the incident where the symlink was first used.
- Kubernetes documentation: Network Plugins - how runtimes call CNI plugins.
- CNI specification - plugins as executables and chained configs.
- ln(1) man page - symbolic links and
-f.
Review cards
Flashcard Why does a path mismatch between the CNI plugin directory and the container runtime block pod networking?
The container runtime only looks in one configured directory for CNI plugins, so if a plugin is installed elsewhere, it won't be found and the pod will fail to get network configuration.
Flashcard Where does containerd look for CNI plugin binaries, and why does it fail on Debian?
In bin_dir, in the CRI plugin's cni section of /etc/containerd/config.toml. Debian's package uses /usr/lib/cni while upstream installers put plugins in /opt/cni/bin.