EndpointSlices and kube-proxy
How a Service's selector becomes ready Pod addresses in EndpointSlices, and how kube-proxy turns them into iptables or nftables rules on every node.
EndpointSlices and kube-proxy
The player loads from youtube-nocookie.com when you press play. Nothing reaches YouTube before that.
Not started
What you'll learn
- The EndpointSlice controller watches Services and Pods and writes the matching Pods' IPs, ports, node, zone and conditions into EndpointSlices, at most 100 endpoints per slice by default.
- Each endpoint carries ready, serving and terminating. Only ready endpoints normally get traffic, and serving lets a terminating Pod finish requests when nothing else is left.
- The old v1 Endpoints API is deprecated since 1.33. Read EndpointSlices, and write them yourself for a selectorless Service that points outside the cluster.
- kube-proxy on each node watches Services and EndpointSlices and programs the kernel. iptables mode is still the default, nftables has been GA since 1.33, and IPVS is deprecated.
- In iptables mode a Service is a chain of DNAT rules picked with random probabilities 1/n, 1/(n-1) and so on, so the cost of updates grows with the number of Services. nftables uses maps instead.
From a selector to a packet
A Service is a promise: traffic to 10.96.241.29:80 will reach a ready Pod labelled app=web. Keeping that promise takes two separate jobs. Someone has to keep an up-to-date list of which Pods match and which are ready. And on every node, something has to make the kernel rewrite packets to the virtual IP into one of those Pod addresses.
Kubernetes splits them cleanly. The EndpointSlice controller in kube-controller-manager maintains the list as API objects. kube-proxy, running on every node, reads the list and programs the kernel. Think of a dispatcher’s whiteboard and the drivers who read it: the dispatcher updates who’s on shift, and each driver routes by what’s on the board.
What’s in a slice
We gave the web Service from the previous lesson three Pods on a lab cluster. (Nothing runs containers there, so we wrote each Pod’s IP and Ready condition into its status ourselves. The controller’s reaction is real.) It produced this:
apiVersion: discovery.k8s.io/v1
kind: EndpointSlice
metadata:
generateName: web-
labels:
kubernetes.io/service-name: web
endpointslice.kubernetes.io/managed-by: endpointslice-controller.k8s.io
ownerReferences: [{kind: Service, name: web, controller: true}]
addressType: IPv4
ports: [{name: http, port: 8080, protocol: TCP}]
endpoints:
- addresses: [10.244.1.11]
conditions: {ready: true, serving: true, terminating: false}
nodeName: w1
zone: eu-a
targetRef: {kind: Pod, name: web-6746cfdc85-dr79j}
- addresses: [10.244.1.13]
conditions: {ready: false, serving: false, terminating: false}
nodeName: w1
zone: eu-a
A few things are worth reading off that. The slice belongs to the Service through a label and an owner reference, so it is deleted with it. Ports are resolved to numbers: the Service says targetPort: 8080, and a named target port is looked up in each Pod’s container ports. Each endpoint records its node and zone, which is what topology-aware routing and trafficDistribution use. And a Pod that isn’t ready stays in the slice, marked ready: false, instead of disappearing.
The three conditions matter during rollouts. When we deleted one Pod, it moved to {"ready":false,"serving":true,"terminating":true}. ready is what proxies use. serving says the Pod would still answer, and proxies fall back to serving-but-terminating endpoints only when no ready ones are left, so a Service whose every Pod is shutting down doesn’t drop connections on the floor.
Why slices, not Endpoints
The original v1 Endpoints object held every address for a Service in one object. A Service with 5,000 Pods meant a huge object, rewritten and re-sent to every kube-proxy in the cluster on each Pod change. Slices cap at 100 endpoints by default (--max-endpoints-per-slice, up to 1,000), so one Pod change touches one small slice. They also carry dual-stack addresses, zones and the terminating states that Endpoints never had.
Endpoints still exists for compatibility, mirrored by a controller, but it’s deprecated:
$ kubectl get endpoints web
Warning: v1 Endpoints is deprecated in v1.33+; use discovery.k8s.io/v1 EndpointSlice
NAME ENDPOINTS AGE
web 10.244.1.11:8080,10.244.1.12:8080 108s
The same lab showed the most common Service bug. Our web-lb Service used targetPort: http, but the Deployment’s container port had no name. The slice listed all three Pods with ports: null, and kubectl get endpoints web-lb said <none>. Every Pod was ready and nothing could reach them.
Writing your own
A Service without a selector gets no controller-managed slices, so you can supply them. This points legacy-db in the cluster at a VM outside it:
apiVersion: discovery.k8s.io/v1
kind: EndpointSlice
metadata:
name: legacy-db-1
labels:
kubernetes.io/service-name: legacy-db
endpointslice.kubernetes.io/managed-by: ops-team
addressType: IPv4
ports: [{name: pg, port: 5432, protocol: TCP}]
endpoints:
- addresses: ["192.168.10.5"]
conditions: {ready: true}
The managed-by label tells the controller this slice isn’t its to touch. Pods now reach the VM at legacy-db.shop.svc and you can move the database into the cluster later without changing clients.
kube-proxy: programming the kernel
kube-proxy isn’t a proxy in the data path. It watches Services and EndpointSlices and writes kernel packet-filter rules, and the kernel does the forwarding. In v1.37 it has three Linux modes:
iptables, still the default when no mode is set (per server_linux.go). Each Service gets a chain. A packet to the cluster IP jumps from KUBE-SERVICES to the Service’s KUBE-SVC-… chain, which picks one KUBE-SEP-… endpoint chain at random and DNATs to that Pod. The randomness is a cascade: with three endpoints, the first rule matches with probability 1/3, the second with 1/2 of what’s left, the last always, which works out to a third each. The cost is scale. Rules are matched in order and the ruleset is rewritten in bulk, so clusters with tens of thousands of Services spend seconds syncing after every change.
nftables, GA since 1.33 and the recommended mode for new clusters. It uses nftables sets and verdict maps, so finding a Service’s rules is a hash lookup, not a walk down a list, and updates are incremental. The nftables lesson covers the kernel side. It isn’t the default yet because it changes some edge behaviours, for example NodePorts listen only on the node’s primary IP by default.
IPVS used the kernel’s load balancer. It’s deprecated, and kube-proxy now logs that it will be disabled by default in 1.40 and removed in 1.43 in favour of nftables.
And some clusters run no kube-proxy at all: Cilium and other eBPF dataplanes read the same EndpointSlices and implement Services in eBPF programs.
About the video
The embed is Kubesimplify’s “kube-proxy inside out: iptables vs IPVS vs nftables”, May 2026, 8 minutes. Its chapters start from the virtual IP that nobody owns, walk a packet through iptables, explain the iptables scale wall, IPVS (and why it still uses iptables) and nftables, note that stable doesn’t mean default, demo a three-Pod Service, and compare rule sync times before a 2026 decision tree. That’s the kube-proxy half of this lesson. Kubesimplify’s companion video on EndpointSlices is first in deeper, and the CNCF talk by two of the nftables mode’s developers is second. Judged from chapters and description, since transcripts can’t be fetched here, and from the “English (US) original” audio track.
What was run: against a local v1.37.3 control plane with no kubelet, we created a three-replica Deployment on fake Nodes, wrote Pod IPs and Ready conditions into Pod status by hand, and watched the real EndpointSlice controller build, update and mark slices, including the terminating state, the deprecated Endpoints warning, the named-port failure and a hand-written slice. kube-proxy wasn’t built or run, so its rules are described from the v1.37.3 source (pkg/proxy/iptables and pkg/proxy/nftables, and server_linux.go for the default mode and IPVS message) and the docs, checked 2026-11-28.
Where this fits
Clients don’t type cluster IPs. They type names. Next: cluster DNS and service discovery.
Check yourself
A Service has three matching Pods, all Ready, but kubectl get endpoints shows <none> and the slice has no ports. What's the likely mistake?
A named targetPort that no container port carries. The controller resolves the name per Pod; if no container port has that name, the slice gets the Pods but no port, and kube-proxy has nothing to forward to. Name the container port or use a number.
During a rollout, a Pod is terminating but still finishing requests. Will a Service send it new connections?
Normally no, because ready goes false once it is terminating. The EndpointSlice keeps it with serving true and terminating true, and proxies fall back to such endpoints only when there are no ready ones, which avoids dropping traffic when every Pod is terminating at once.
How do you point a Service at a database VM at 192.168.10.5?
Create the Service without a selector, then create an EndpointSlice labelled kubernetes.io/service-name set to the Service's name, with that address and a port whose name matches the Service port. Set a managed-by label of your own so the controller leaves it alone.
Why did large clusters move away from iptables mode?
iptables rules are evaluated as linear lists and rewritten as a whole, so with tens of thousands of Services every endpoint change means a big, slow ruleset sync and per-packet matching that grows with Service count. nftables uses verdict maps for constant-time lookup and incremental updates.
Go deeper
Notes
Notes are saved to your account.
Everything else on this page works without one — progress and bookmarks keep themselves in this browser and come with you when you sign in. Notes are the one thing worth not trusting to a browser you might clear.
Your notes could not be loaded.