The Kubernetes API server is the central communication point for almost every Kubernetes component. Controllers, operators, command-line tools, and other clients continuously interact with the API server to read resources and receive change notifications.
When a Kubernetes cluster becomes large, the volume of API requests can become significant. Watch requests are particularly important because controllers use them to observe changes without repeatedly polling the API server.
Kubernetes 1.37 introduces improvements to the API server watch cache, including a new mechanism that allows the watch cache to recover more efficiently after an unexpected failure. These changes are designed to reduce unnecessary load on etcd and improve API server recovery behavior.
For developers and platform engineers running .NET workloads on Kubernetes, this matters because application deployments, scaling operations, configuration changes, and custom resources all depend on the Kubernetes control plane.
What Is the Kubernetes Watch Cache?
The Kubernetes API server uses a watch cache to efficiently serve watch requests.
A simplified request flow looks like this:
Controller
|
| Watch Pods
v
API Server
|
| Watch Cache
v
etcd
Without an effective cache, many clients would need to retrieve information directly from etcd or repeatedly query the API server.
The watch cache keeps recently observed resource state in memory and allows the API server to respond to watch requests without constantly replaying the same information from etcd.
This is particularly useful for resources such as:
Pods
Deployments
Services
ConfigMaps
Secrets
Nodes
Custom Resources
Why Watch Performance Matters
Kubernetes controllers are built around a reconciliation model.
A controller effectively follows this pattern:
Observe
↓
Detect change
↓
Reconcile desired state
↓
Update resource
↓
Observe next change
For example, when a Deployment changes from three replicas to five, Kubernetes components need to observe that change and react.
A simplified example is:
Deployment
↓
ReplicaSet
↓
Pods
↓
Scheduler / Kubelet
If API-server watch handling becomes inefficient, large clusters can experience increased control-plane load.
That does not necessarily mean the application itself is slow. The bottleneck can exist entirely in the Kubernetes control plane.
What Changed in Kubernetes 1.37?
Kubernetes 1.37 includes improvements to watch-cache initialization and recovery.
The important idea is that rebuilding a watch cache should not unnecessarily create additional pressure on etcd.
The Kubernetes API server can use the existing resource state more efficiently while reconstructing the cache instead of repeatedly performing expensive operations.
Conceptually:
Before
-----
Watch Cache Failure
↓
Rebuild Cache
↓
Heavy etcd Activity
↓
API Server Recovery
Improved Recovery
-----------------
Watch Cache Failure
↓
Recover / Reconstruct Cache
↓
Reduced unnecessary etcd work
↓
API Server resumes normal operation
The goal is not to eliminate etcd interaction. The goal is to make cache recovery more efficient and reduce unnecessary control-plane work.
Watch Cache and etcd
etcd is the backing key-value store used by Kubernetes for cluster state.
The relationship can be simplified as:
Clients
|
v
API Server
|
+--> Watch Cache
|
v
etcd
etcd stores the authoritative state.
The watch cache provides an API-server-side mechanism for efficiently serving watch operations.
This separation is important because an API-server problem does not automatically mean etcd is unhealthy.
Likewise, an etcd performance problem can cause API-server operations to become slow even when application Pods are healthy.
Understanding Watch Requests
A watch request asks the API server to continuously report changes to a resource.
For example, a client can request:
GET /api/v1/pods?watch=true
Instead of returning one static response, the API server keeps the connection open and sends events as resources change.
Conceptually:
{
"type": "ADDED",
"object": {
"metadata": {
"name": "orders-api"
}
}
}
A later change can generate:
{
"type": "MODIFIED",
"object": {
"metadata": {
"name": "orders-api"
}
}
}
Controllers can therefore react to changes without continuously polling the API server.
Why Recovery Behavior Matters
Watch caches can be rebuilt after events such as API-server restarts or other cache lifecycle events.
During recovery, the API server must reconstruct enough state to serve new watch requests correctly.
In a busy cluster, recovery can happen while other control-plane operations are still running.
This creates a potentially expensive scenario:
API Server Restart
|
+--> Controllers reconnect
|
+--> Watches reconnect
|
+--> Cache rebuild begins
|
+--> Normal API requests continue
|
+--> etcd receives additional traffic
A recovery mechanism that minimizes unnecessary work is therefore valuable for cluster stability.
Impact on .NET Workloads
Application developers may not interact with the watch cache directly, but Kubernetes workloads depend on the API server constantly.
For example, deploying a .NET application involves resources such as:
apiVersion: apps/v1
kind: Deployment
metadata:
name: orders-api
spec:
replicas: 3
selector:
matchLabels:
app: orders-api
template:
metadata:
labels:
app: orders-api
spec:
containers:
- name: orders-api
image: example/orders-api:latest
Join the conversation! Your thoughts help the community grow.