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 kubelet and CNI Plugins:

  1. Location of CNI Configuration:

    • By default, the kubelet looks in /etc/cni/net.d for the CNI configuration files. This is where the CNI plugin's configuration files (like 10-weave.conf, 10-calico.conf, etc.) are stored.
    • If this directory contains valid configuration files, the kubelet uses the plugin(s) specified there.
  2. Location of CNI Plugin Executables:

    • The actual CNI binaries (executables) are typically stored in /opt/cni/bin by default. These binaries implement the networking logic (e.g., Calico, Weave Net, Flannel).
  3. Consistency Across Nodes:

    • The /etc/cni/net.d directory 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.

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.d and /opt/cni/bin are 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-dir and --cni-bin-dir flags in the kubelet configuration.

Verification:

You can verify the CNI plugin configuration on a node:

  1. Check the kubelet logs for references to CNI:
    journalctl -u kubelet | grep CNI
  2. Look at the contents of /etc/cni/net.d:
    ls -l /etc/cni/net.d
  3. Ensure the CNI binaries exist in /opt/cni/bin:
    ls -l /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

Popular posts from this blog

Electron Process Execution Failure with FSLogix

KB: Kube-proxy vs CNI Plugin

KB: Azure ACA Container fails to start (no User Assigned or Delegated Managed Identity found for specified ClientId)