KB: Kubernetes finding Networking (or CNI Plugin)
By default the kubelet looks into /etc/cni/net.d to discover the CNI plugins. This will be the same on every controlplane and worker nodes.Default Behavior of
Default Behavior of kubelet and CNI Plugins:
Location of CNI Configuration:
- By default, the
kubeletlooks in/etc/cni/net.dfor the CNI configuration files. This is where the CNI plugin's configuration files (like10-weave.conf,10-calico.conf, etc.) are stored. - If this directory contains valid configuration files, the
kubeletuses the plugin(s) specified there.
- By default, the
Location of CNI Plugin Executables:
- The actual CNI binaries (executables) are typically stored in
/opt/cni/binby default. These binaries implement the networking logic (e.g., Calico, Weave Net, Flannel).
- The actual CNI binaries (executables) are typically stored in
Consistency Across Nodes:
- The
/etc/cni/net.ddirectory must have consistent CNI configurations across all control plane and worker nodes. This ensures that all nodes in the cluster handle pod networking in a consistent manner. - Similarly, the required binaries (in
/opt/cni/bin) must also be installed on all nodes.
- The
Important Points:
- No Default CNI Plugin: Kubernetes does not come with a built-in CNI plugin. You must install one manually or use the one provided by your Kubernetes distribution (e.g., Calico, Flannel, Weave Net, etc.).
- Environment-Dependent Paths:
- While
/etc/cni/net.dand/opt/cni/binare the defaults, these paths can vary based on how Kubernetes was installed (e.g., kubeadm, a managed Kubernetes service like EKS/AKS/GKE, or a custom setup). - You can override these defaults using the
--cni-conf-dirand--cni-bin-dirflags in thekubeletconfiguration.
- While
Verification:
You can verify the CNI plugin configuration on a node:
- Check the
kubeletlogs for references to CNI: - Look at the contents of
/etc/cni/net.d: - Ensure the CNI binaries exist in
/opt/cni/bin:
Conclusion:
Typical Kubernetes setup where the kubelet indeed looks for CNI configurations in /etc/cni/net.d, and this path must be consistent across all nodes. However, paths can differ in custom setups, so always check your cluster’s specific configuration.
Comments
Post a Comment