QA
Intermediate LevelDocker & Deployment

What is a Container Network Interface (CNI) plugin in Kubernetes?

❓ Interview Prompt: Explain CNI specification, pod IP allocation, overlay networking (VXLAN/IPIP), and the difference between Flannel, Calico, and Cilium eBPF.

CNI (Container Network Interface) is a specification and set of libraries for configuring network interfaces in Linux containers. Kubernetes delegates all Pod networking to a CNI plugin.

What CNI Does:

When a Pod is created on a node, kubelet calls the CNI plugin which:

1
Creates a veth pair (virtual ethernet cable) connecting the pod to the host network.
2
Assigns a unique IP address to the pod from the cluster's CIDR range.
3
Configures routes so the pod can reach other pods on other nodes.
4
On pod deletion, tears down the network interface and releases the IP.

CNI Plugin Comparison:

| Plugin | Networking | NetworkPolicy | Performance | Notes |

|---|---|---|---|---|

| Flannel | VXLAN overlay | ❌ No | Medium | Simple, widely used, no NetworkPolicy enforcement |

| Calico | IPIP/BGP | ✅ Yes | High | Popular for NetworkPolicy, uses BGP routing |

| Cilium | eBPF-native | ✅ Yes | Very High | eBPF bypasses iptables, service mesh capabilities |

| Weave | VXLAN mesh | ✅ Yes | Medium | Easy setup, auto-discovery |

Cilium's eBPF Advantage:

Traditional CNIs configure Linux iptables for routing (O(N) rule lookup). Cilium uses eBPF programs attached directly to kernel socket hooks — O(1) routing, 30%+ throughput improvement.

Code Implementation Example

bash
# Install Cilium CNI in a new cluster
helm repo add cilium https://helm.cilium.io/
helm install cilium cilium/cilium \
  --namespace kube-system \
  --set kubeProxyReplacement=true  # replace kube-proxy with eBPF!

# Verify Cilium is running
cilium status --wait

# Show pod networking (veth pairs and IPs)
kubectl exec -n kube-system -it cilium-xxxxx -- cilium endpoint list

# Observe network traffic in real-time (eBPF powered!)
cilium monitor --type drop   # see dropped packets

# Test cross-node pod connectivity
kubectl run test-a --image=alpine --rm -it -- sh
# Inside: ping <pod-IP-on-another-node>  ← should work via CNI overlay
💡Cilium CNI with eBPF kube-proxy replacement: O(1) routing, NetworkPolicy enforcement, real-time monitoring.
🎯 Interview Key Takeaway

CNI plugins handle pod IP allocation and cross-node routing. Choose Cilium for maximum performance (eBPF bypasses iptables) + NetworkPolicy enforcement in production clusters.

#Kubernetes#CNI#Cilium#eBPF#Networking#Intermediate
Back to all Docker & Deployment Questions→

More Docker & Deployment Interview Questions

Beginner LevelDocker & Deployment

How do Docker Multi-Stage Builds minimize image size and improve security?

Beginner LevelDocker & Deployment

What is the difference between a Docker Container and a Virtual Machine (VM)?

Beginner LevelDocker & Deployment

What is the difference between a Docker Image and a Docker Container?