Proxy Modes and Strategies
Proxy Mode Overview
Kubernetes supports three distinct proxy modes, each with unique characteristics and performance implications for network routing and service discovery.
Userspace Proxy Mode
The oldest proxy mode with direct kernel interaction:
graph LR
A[Client Request] --> B[Userspace Proxy]
B --> C[Service Endpoint]
B --> D[Pod Selection]
Performance characteristics:
- Lowest performance
- High CPU overhead
- Suitable for legacy systems
IPTables Proxy Mode
Default and most commonly used proxy mode:
Feature |
Description |
Routing Method |
NAT-based |
Performance |
Medium |
Kernel Interaction |
Directly uses iptables rules |
## Check iptables rules
sudo iptables -t nat -L KUBE-SERVICES
IPVS Proxy Mode
Advanced proxy mode with superior performance:
graph TD
A[Load Balancer] --> B{IPVS}
B --> C[Service Endpoint 1]
B --> D[Service Endpoint 2]
B --> E[Service Endpoint 3]
Key advantages:
- Highest performance
- Supports multiple load balancing algorithms
- Kernel-level routing
Ubuntu 22.04 IPVS Configuration
## Enable IPVS modules
sudo modprobe ip_vs
sudo modprobe ip_vs_rr
sudo modprobe ip_vs_wrr
sudo modprobe ip_vs_sh
## Verify IPVS modules
lsmod | grep ip_vs