Networking
CNI
Container Network Interface plugins, checking and installing CNI, pod CIDR configuration.
Check CNI
cat /var/lib/kubelet/config.yaml | grep containerRuntimeEndpoint
CNI supported plugins path
ls /opt/cni/bin
Check configured CNI Plugin
ls /etc/cni/net.d/
# or check the pods
kubectl get pods -A
Install CNI (ex. Calico)
Docs -> Link
-
Install CRDs and Operators
kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.31.4/manifests/tigera-operator.yaml -
Download Custom Resource manifest
curl https://raw.githubusercontent.com/projectcalico/calico/v3.31.4/manifests/custom-resources.yaml -O -
Edit
custom-resources.yamland update the cidrapiVersion: operator.tigera.io/v1 kind: Installation metadata: name: default spec: # Configures Calico networking. calicoNetwork: ipPools: - name: default-ipv4-ippool blockSize: 26 cidr: x.x.x.x/16 # CHANGE ME encapsulation: VXLANCrossSubnet natOutgoing: Enabled nodeSelector: all() -
Apply manifest
kubectl apply -f custom-resources.yaml
Delete CNI
After removing all k8s resources:
rm /etc/cni/net.d/<cni-conflist>
Check Pod CIDR
kubectl cluster-info dump | grep -m 1 cluster-cidr
# or per-node
kubectl get nodes -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.spec.podCIDR}{"\n"}{end}'
Notes
- Not all CNI support
Network Policies(Flannel does NOT, Calico and Weave do)