Network plugins implement the Container Network Interface (CNI) in Kubernetes, providing the crucial ability for pods to communicate with each other across nodes. They're responsible for the "plumbing" that enables network connectivity in your cluster.
Core responsibilities of network plugins:
Pod Networking:
- Assign IP addresses to pods
- Create virtual interfaces for containers
- Establish routes between pods across different nodes
- Implement the Kubernetes networking model
Network Policy Enforcement (in many plugins):
- Implement Kubernetes NetworkPolicy resources
- Provide pod-level firewalling
- Control ingress/egress traffic at the pod level
Cross-Node Communication:
- Create overlay networks or configure underlay networks
- Handle encapsulation/decapsulation of packets
- Manage routing tables and rules
The Kubernetes networking model requires that:
- All pods can communicate with all other pods without NAT
- All nodes can communicate with all pods without NAT
- A pod sees itself with the same IP that others see it with
Popular network plugins:
Calico:
- Uses BGP routing or VXLANs (configurable)
- Strong focus on security with rich network policy features
- Good performance with minimal overlay overhead in BGP mode
- Scales to very large deployments
Cilium:
- Uses eBPF for high-performance networking
- Advanced security with Layer 7 filtering (HTTP/gRPC/etc.)
- Built-in observability features
- Layer 4 load balancing
Flannel:
- Simpler implementation, easy to set up
- Uses overlay networks (typically VXLAN)
- Good for getting started, fewer advanced features
Weave Net:
- Creates a virtual network that connects containers across nodes
- Handles network partitions well
- Includes encryption options
AWS VPC CNI (Amazon EKS):
- Gives pods IPs directly from the VPC
- Native AWS networking performance
- No overlay overhead
Azure CNI (AKS):
- Similar to AWS CNI but for Azure
Antrea:
- Based on Open vSwitch
- Good integration with VMware environments
How network plugins work:
Installation: The plugin is deployed as a DaemonSet (runs on every node)
Configuration: The kubelet is configured to use a specific CNI plugin
Pod Creation: When a pod is created, kubelet asks the CNI plugin to set up networking
Address Allocation: The plugin assigns an IP from its managed pool
Interface Creation: Virtual interfaces are created and connected
Routing: Routes are established to enable cross-node communication
Example: How traffic flows between pods on different nodes with an overlay network:
Pod A (10.244.1.2) on Node 1 → Pod B (10.244.2.3) on Node 2
1. Pod A sends packet to 10.244.2.3
2. Packet hits Node 1's routing table
3. CNI plugin encapsulates packet (e.g., VXLAN)
4. Encapsulated packet sent to Node 2's physical IP
5. Node 2 receives and decapsulates packet
6. Packet delivered to Pod B's network namespace
Network plugins essentially create a flat network where all pods can reach each other, regardless of which node they're on. The specific implementation details vary significantly between plugins, with different performance, security, and feature trade-offs.