Control plane
List and watch
How components stay in sync
Resource versions, watch streams and informers: how every component sees changes without polling. Follow node-2's kubelet catching up after a restart - one LIST, one long-lived watch - and then one Deployment patch as it fans out to every listener in the cluster within milliseconds.
- Pattern
- LIST for state, WATCH for changes
- Resource version
- 48211 · a logical clock from etcd
- Polling
- none - the server pushes
- Fan-out
- one write → every listener, < 10 ms
Read the whole lesson as text
1. The first list
node-2's kubelet restarts and knows nothing. It issues one request: list every Pod assigned to node-2. The API server answers with the full collection and one extra field - resourceVersion 48211, the etcd revision this snapshot reflects. That number is the contract: everything that has happened to these objects, ever, is numbered, and the kubelet is now up to date as of 48211.
- The restarted kubelet asks for its Pods in one request.
- The answer carries the state and the number that dates it.
2. Open the watch
Catching up isn't enough; the kubelet needs changes as they happen. So it immediately re-asks with watch=true and resourceVersion=48211 - send me everything after 48211. The API server holds the HTTP/2 stream open and pushes framed events down it: ADDED, MODIFIED, DELETED. No component in Kubernetes polls. They all hold one of these streams open per resource type.
- The kubelet opens a watch that starts where the list ended.
- Nothing arrives until something changes - that's the point.
3. One write, many pushes
Now you patch the Deployment - anywhere in the cluster. One write hits etcd, etcd's own watch fires inside the API server, and the API server walks its registry of open watchers and pushes the event to every one that matches: the deployment controller, the scheduler, both kubelets' Pod watches after the cascade, kube-proxy on every node. One write becomes as many pushes as there are listeners.
- You change one field of one object.
- etcd was watching itself; the API server hears its own write come back.
- The deployment controller gets the MODIFIED event.
- Seconds later in story-time, the new Pod's binding reaches node-2's kubelet on the same stream.
- And kube-proxy on node-1 hears about the endpoint that will follow.
4. The informer
Nobody writes raw watch loops; every component embeds client-go's informer. The reflector drives the watch stream; every event lands in a delta queue; the store keeps the newest version of each object in memory; handler callbacks fire per change. Controllers read from that cache, not the API - which is why a controller can answer "what Pods exist?" instantly, forever, without a single extra request.
- Each pushed event updates a local cache and fires a handler.
5. Too far behind
Watch buffers are finite. If a listener is too slow - or disconnects and reconnects with an old resourceVersion - the API server can no longer ship the missed range and returns 410 Gone. The client falls back to its only safe move: re-LIST from scratch, then re-watch from the fresh version. BOOKMARK events exist to make that rare: during quiet periods the server sends rv-only keepalives so clients never hold ancient versions.
- The kubelet reconnects with a version too old to resume, and the server refuses.
- So the kubelet lists everything again and opens a fresh watch from the new version.
Summary
One LIST for the past, one watch stream for the future, and a local cache in between: that's how every component stays in sync. The API server is a broker between etcd's revision log and thousands of open streams, pushing each write to whoever's listening. Polling appears nowhere in the design - on a quiet cluster the streams carry little more than bookmarks and pings.
Next lesson: The scheduler