Skip to main content

kube-proxy

kube-proxy is the network component that runs on every Kubernetes node and programs iptables, IPVS, or nftables rules so traffic sent to a Service's virtual IP is load balanced across its backend pods.

What kube-proxy does

A ClusterIP is virtual: no interface owns it. kube-proxy watches Services and EndpointSlices through the API server and writes rules on each node that rewrite the Service IP to a real pod IP. It is not in the data path itself, it only configures the kernel.

flowchart TD A["API server
Services and endpoints"] -->|"watch"| K["kube-proxy
on each node"] K -->|"writes rules"| R["iptables or IPVS"] P["Pod calls ClusterIP"] --> R R -->|"rewrites to"| B["Backend pod IP"] classDef api fill:#475569,color:#ffffff classDef proxy fill:#326CE5,color:#ffffff classDef data fill:#DBEAFE,color:#1E293B class A api class K proxy class P,R,B data

Modes

Mode Characteristics
iptables Default. Rule chains are scanned linearly, fine for most clusters
IPVS Hash-table lookups, scales better, more balancing algorithms
nftables Newer kernel-based mode, an alternative to iptables

Check and switch mode

Bash
kubectl get pods -n kube-system -l k8s-app=kube-proxy -o wide
kubectl logs -n kube-system <kube-proxy-pod> | grep -i proxier
YAML
apiVersion: kubeproxy.config.k8s.io/v1alpha1
kind: KubeProxyConfiguration
mode: "ipvs"
ipvs:
scheduler: "rr"

After changing the ConfigMap, restart the DaemonSet with kubectl rollout restart daemonset kube-proxy -n kube-system. IPVS needs the ip_vs kernel modules loaded.

What it does not do

  • DNS resolution (CoreDNS)
  • Ingress routing (the Ingress controller)
  • NetworkPolicy enforcement (the CNI)
  • Pod-to-pod routing across nodes (the CNI)

Troubleshooting

Symptom Likely cause Fix
ClusterIP times out kube-proxy not running on that node Check its pod and logs
IPVS not activating Kernel modules missing Load ip_vs modules
NodePort unreachable externally Firewall blocks port range Open 30000-32767
Common Mistake

Removing kube-proxy when adopting Cilium without enabling its kube-proxy replacement first. All Service IPs stop working.

Security

Anyone with root on a node can alter the rules and redirect Service traffic. Protect node access and audit changes.

Frequently Asked Questions

What is the practical difference between iptables and IPVS mode?

iptables walks rule chains, so processing time grows with the number of Services. IPVS uses hash tables for near constant lookup and offers more balancing algorithms, so it is preferred at large scale.

Does kube-proxy handle pod networking?

No. Pod-to-pod connectivity is the CNI's job. kube-proxy only maps Service virtual IPs to pod IPs.

Can I run without kube-proxy?

Yes, if your CNI, such as Cilium, provides a kube-proxy replacement using eBPF. Enable it before removing kube-proxy.

Found a mistake, an outdated step or a broken link?