Skip to content

Commit f02bfac

Browse files
committed
Streaming lists documentation
1 parent cdef82b commit f02bfac

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

content/en/docs/reference/command-line-tools-reference/feature-gates.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ For a reference to old feature gates that are removed, please refer to
199199
| `UserNamespacesStatelessPodsSupport` | `false` | Alpha | 1.25 | |
200200
| `ValidatingAdmissionPolicy` | `false` | Alpha | 1.26 | |
201201
| `VolumeCapacityPriority` | `false` | Alpha | 1.21 | - |
202+
| `WatchList` | false | Alpha | 1.27 | - |
202203
| `WinDSR` | `false` | Alpha | 1.14 | |
203204
| `WinOverlay` | `false` | Alpha | 1.14 | 1.19 |
204205
| `WinOverlay` | `true` | Beta | 1.20 | |
@@ -748,6 +749,7 @@ Each feature gate is designed for enabling/disabling a specific feature:
748749
- `VolumeCapacityPriority`: Enable support for prioritizing nodes in different
749750
topologies based on available PV capacity.
750751
- `WatchBookmark`: Enable support for watch bookmark events.
752+
- `WatchList` : Enable support for [streaming initial state of objects in watch requests](/docs/reference/using-api/api-concepts/#streaming-lists).
751753
- `WinDSR`: Allows kube-proxy to create DSR loadbalancers for Windows.
752754
- `WinOverlay`: Allows kube-proxy to run in overlay mode for Windows.
753755
- `WindowsHostNetwork`: Enables support for joining Windows containers to a hosts' network namespace.

content/en/docs/reference/using-api/api-concepts.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,58 @@ As a client, you can request `BOOKMARK` events by setting the
226226
assume bookmarks are returned at any specific interval, nor can clients assume that
227227
the API server will send any `BOOKMARK` event even when requested.
228228

229+
## Streaming lists
230+
231+
{{< feature-state for_k8s_version="v1.27" state="alpha" >}}
232+
233+
On large clusters, retrieving the collection of some resource types may result in
234+
a significant increase of resource usage (primarily RAM) on the control plane.
235+
In order to alleviate its impact and simplify the user experience of the **list** + **watch**
236+
pattern, Kubernetes - including version {{< skew currentVersion >}} - provides alpha support
237+
for requesting the initial state (previously requested via the **list** request) as part of
238+
the **watch** request.
239+
240+
Provided that the `WatchList` [feature gate](/docs/reference/command-line-tools-reference/feature-gates/)
241+
is enabled, this can be achieved by specifying `sendInitialEvents=true` as query string parameter
242+
in a watch request. If set, the server starts the watch stream with synthetic init
243+
events to build the whole state of all existing objects followed by a `BOOKMARK` event
244+
(if requested via `allowWatchBookmarks=true` option) containing a resource version after
245+
which the server continue streaming events.
246+
247+
When `sendInitialEvents=true` in the query string is set, we require `ResourceVersionMatch` to be set
248+
to `NotOlderThan`. If the provided `ResourceVersion` is unset, this is interpreted
249+
as a request for _consistent read_; the bookmark event is sent when the state is synced at
250+
least to the moment of a consistent read from when the request started to be
251+
processed. If you specify `resourceVersion` (in the query string), the bookmark event is sent when
252+
the state is synced at least to the provided resource version.
253+
254+
As an example imagine a case when the current resource version is 10245 and there
255+
exist two pods: `foo` and `bar`. Then sending the following request could result
256+
in the following sequence of events:
257+
258+
```console
259+
GET /api/v1/namespaces/test/pods?watch=1&sendInitialEvents=true&allowWatchBookmarks=true&resourceVersion=&resourceVersionMatch=NotOlderThan
260+
---
261+
200 OK
262+
Transfer-Encoding: chunked
263+
Content-Type: application/json
264+
265+
{
266+
"type": "ADDED",
267+
"object": {"kind": "Pod", "apiVersion": "v1", "metadata": {"resourceVersion": "8467", "name": "foo"}, ...}
268+
}
269+
{
270+
"type": "ADDED",
271+
"object": {"kind": "Pod", "apiVersion": "v1", "metadata": {"resourceVersion": "5726", "name": "bar"}, ...}
272+
}
273+
{
274+
"type": "BOOKMARK",
275+
"object": {"kind": "Pod", "apiVersion": "v1", "metadata": {"resourceVersion": "10245"} }
276+
}
277+
...
278+
<followed by regular watch stream starting from resourceVersion="10245">
279+
```
280+
229281
## Retrieving large results sets in chunks
230282

231283
{{< feature-state for_k8s_version="v1.9" state="beta" >}}

0 commit comments

Comments
 (0)