Q: What is kube-proxy, how does it handle Service routing, and what are the differences between iptables, IPVS, and eBPF mode?
Deep architectural explanation of how kube-proxy programs node-level networking to route ClusterIP service traffic to backend Pods using iptables, IPVS, and modern eBPF.
Want to master this scenario in a live sandbox? KodeKloud's CKA & CKAD Hands-On Certification Track covers this exact problem with hands-on terminal drills.
🛠️ Production Runbook & Step-by-Step Resolution
Direct Answer: kube-proxy is a network proxy that runs on each worker node in a Kubernetes cluster. It does not actually proxy traffic in user-space anymore; instead, it watches the Kubernetes API server for Service and EndpointSlice changes and programs kernel packet forwarding rules.
iptables Mode Mechanics & O(n) Scaling Limits
In iptables mode, kube-proxy creates chains in the NAT table. For every Service, it adds sequential rules using the statistic module for random load balancing. However, iptables evaluates rules sequentially—in clusters with 5,000+ services, packet evaluation overhead causes severe CPU spikes and latency.
iptables -t nat -L KUBE-SERVICES -n -v
iptables -t nat -L KUBE-SVC-XYZ -n -v
IPVS Mode & O(1) Hash Table Routing
IPVS (IP Virtual Server) is a transport-layer load balancer built into the Linux kernel. It uses hash tables (O(1) lookup complexity) that maintain consistent throughput regardless of whether the cluster has 10 services or 50,000 services.
eBPF (Cilium / Kube-Proxy Replacement)
Modern CNI solutions like Cilium completely replace kube-proxy using eBPF programs attached to Linux socket layers (sockops) and tc (traffic control), bypassing the entire netfilter/iptables subsystem for near-native wire speeds.
- kube-proxy watches Services and EndpointSlices to program Linux kernel forwarding tables.
- iptables mode: uses sequential rule evaluation; fine for small clusters but suffers O(n) latency at scale.
- IPVS mode: uses in-kernel hash tables with O(1) lookup performance for enterprise-scale clusters.
- eBPF mode (Cilium): bypasses iptables/netfilter completely at the socket layer for maximum throughput.
Senior hiring managers and bar raisers evaluate how you prioritize during outages. Avoid these common anti-patterns:
-
Configuring Service selector labels that mismatch underlying Pod manifest metadata
A typo in
spec.selectorcauses the Service endpoints list (kubectl get endpoints) to remain empty, resulting in503 Service Unavailableor timeouts. -
Omitting explicit ingressClassName specifications when running multiple ingress controllers
Without an explicit
ingressClassName, ingress resources are either ignored or picked up unpredictably by competing controllers. -
Depleting worker node subnet IP address allocations under VPC CNI or Azure CNI
Direct VPC pod networking allocates real subnet IPs; failing to monitor IP pools causes new pods to stay stuck indefinitely in
ContainerCreating. - Attempting network triage without inspecting kubectl describe service and EndpointSlice resources in k8s-kube-proxy-internals-iptables-ipvs-ebpf Verifying EndpointSlice population immediately determines whether a connectivity failure is caused by pod labeling, readiness probes, or routing.