✦ For everyone, free.

Practical knowledge for real and everyday life

Home

Kubernetes kube-proxy Data Plane

Kubernetes kube-proxy Data Plane enables efficient network communication within clusters by managing service traffic routing and load balancing at the data plane level.

Kubernetes kube-proxy Data Plane refers to the specific implementation of Service traffic forwarding provided by the kube-proxy component, the reference data plane agent that runs on every node in most Kubernetes distributions and translates the cluster's declared Service and EndpointSlice state into actual node-level packet forwarding rules.


Role Within the Cluster

Watching API State

kube-proxy runs as a long-lived process on each node, maintaining a watch connection to the Kubernetes API server for Service and EndpointSlice objects. Whenever these objects change, whether a new Service is created, endpoints are added or removed, or a Service's configuration changes, kube-proxy recalculates the forwarding rules it needs to program on its local node.

Node-Local Scope

Each kube-proxy instance is only responsible for the node it runs on; it has no authority over or visibility into forwarding rules on other nodes. This design means Service routing correctness depends on every node's kube-proxy independently converging on a consistent view of cluster state, rather than any single component coordinating forwarding decisions cluster-wide.


Backend Modes

userspace Mode (Legacy)

The original kube-proxy implementation ran an actual userspace proxy process that accepted connections on behalf of each Service and forwarded them to a chosen backend, requiring every packet to traverse the kernel-to-userspace boundary twice. This mode is largely obsolete due to its comparatively poor performance.

iptables Mode

The iptables mode, long the default, programs a chain of NAT rules per Service and per endpoint directly into the kernel's packet filtering framework, avoiding userspace round-trips entirely. Rule evaluation is sequential, so lookup cost scales with the total number of Services and endpoints configured.

IPVS Mode

The IPVS mode configures the kernel's IP Virtual Server subsystem instead, using hash-table-based virtual server definitions rather than sequential rule chains, giving it more consistent performance characteristics as Service count grows and additional load balancing algorithm choices beyond the iptables mode's simple random selection.

API Server watch Services/Endpoints kube-proxy iptables / IPVS rules (node-local kernel state)

Rule Programming Behavior

Full Resync Versus Incremental Updates

kube-proxy periodically performs a full resynchronization of its forwarding rules against current API state, in addition to reacting incrementally to individual object change events, which guards against drift or missed updates caused by transient watch disconnections or programming errors.

Minimizing Disruption During Updates

Because reprogramming forwarding rules can briefly disrupt in-flight connections if done carelessly, kube-proxy's rule update logic is designed to apply changes as atomically as the underlying backend allows, minimizing the window during which forwarding state is inconsistent.


Session Affinity and Load Balancing

Backend-Specific Affinity Implementation

kube-proxy exposes Service-level configuration for client IP-based session affinity, but the concrete mechanism differs by backend mode: iptables mode uses connection recency matching rules, while IPVS mode uses the kernel's native persistence engine, both achieving the same externally visible behavior through different underlying primitives.


Limitations Driving Alternative Data Planes

Rule Set Scaling Ceiling

The iptables mode's sequential rule evaluation becomes a measurable latency and CPU cost in clusters with tens of thousands of Services and endpoints, which is the primary motivation for clusters at that scale adopting IPVS mode or, increasingly, replacing kube-proxy entirely with an eBPF-based data plane provided by certain CNI plugins.

No Layer 7 Awareness

kube-proxy operates purely at Layer 4, meaning it has no visibility into HTTP paths, headers, or other application-layer routing signals; any Layer 7-aware traffic management, such as path-based routing, is handled by a separate component like an Ingress controller or service mesh sidecar, layered on top of, not inside, the kube-proxy data plane.


Operational Monitoring

Sync Latency as a Health Signal

kube-proxy exposes metrics describing how long rule synchronization takes and how many rules are currently programmed, which are commonly monitored as leading indicators of Service routing health, since a node whose kube-proxy is falling behind on synchronization will serve stale or incomplete Service routing until it catches up.