Kube Proxy in Kubernetes
Kube Proxy is a lightweight process that runs on every node in a Kubernetes cluster.
Its main responsibility is to enable Service networking by configuring network rules that forward traffic from a Service to its backend Pods.
Why Do We Need Services?
Pod IPs can change when Pods are recreated, so applications should not depend directly on Pod IPs.
Instead, a Service provides a stable endpoint:
Web Pod
│
│ connect to DB Service
▼
DB Service
│
│ forwards traffic
▼
DB Pod
A Service is a virtual entity that provides a stable IP/endpoint for accessing Pods.
How Kube Proxy Works
Kube Proxy watches for Services and their backend Pods and configures network rules on the node.
For example:
Service IP
10.96.0.12
│
│ Kube Proxy rules
▼
Pod IP
10.32.0.15
When traffic is sent to the Service IP, Kube Proxy’s network rules redirect the traffic to an appropriate backend Pod.
One common mechanism is iptables.
Important
Kube Proxy runs on every node, so traffic can be routed to Services regardless of which node the request originates from.
Kube Proxy Deployment
With kubeadm, Kube Proxy is typically deployed as a DaemonSet.
A DaemonSet ensures that a Kube Proxy Pod runs on every node:
Cluster
│
┌─────────┼─────────┐
▼ ▼ ▼
Node 1 Node 2 Node 3
│ │ │
kube-proxy kube-proxy kube-proxy
Verify Kube Proxy
Check Kube Proxy Pods:
kubectl get pods -n kube-system
Check the Kube Proxy DaemonSet:
kubectl get daemonset -n kube-system
Kube Proxy vs Kubelet
| Component | Responsibility |
|---|---|
| Kubelet | Manages Pods and containers on a node |
| Kube Proxy | Handles Service networking and traffic forwarding |
| Kube Scheduler | Decides which node should run a Pod |
Key Takeaway
Kube Proxy = Service networking on each node.
It runs on every node and configures network rules to forward traffic from Kubernetes Services to their backend Pods.