Skip to content

Commit 2cd0599

Browse files
committed
Streaming lists documentation
1 parent cdef82b commit 2cd0599

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-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.
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: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,57 @@ 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, we added a support for requesting the initial state (previously requested via
237+
the **list** request) as part of the **watch** request.
238+
239+
Provided that the `WatchList` [feature gate](/docs/reference/command-line-tools-reference/feature-gates/)
240+
is enabled, this can be achieved by specifying `SendInitialEvents=true` parameter
241+
in a watch request. If set, the server starts the watch stream with synthetic init
242+
events to build the whole state of all existing objects followed by a `BOOKMARK` event
243+
(if requested via `allowWatchBookmarks=true` option) containing a ResourceVersion after
244+
which the server continue streaming events.
245+
246+
When `SendInitialEvents` option is set, we require `ResourceVersionMatch` to be set
247+
to `NotOlderThan`. If the provided `ResourceVersion` is unset, this is interpreted
248+
as **consistent read** and the bookmark event is send when the state is synced at
249+
least to the moment of a consistent read from when the request started to be
250+
processed. If the provided `ResourceVersion` is set, the bookmark event is send when
251+
the state is synced at least to the provided resource version.
252+
253+
As an example imagine a case when the current resource version is 10245 and there
254+
exist two pod: `foo` and `bar`. Then sending the following request could result
255+
in the following sequence of events:
256+
257+
```console
258+
GET /api/v1/namespaces/test/pods?watch=1&sendInitialEvents=true&allowWatchBookmarks=true&resourceVersion=&resourceVersionMatch=NotOlderThan
259+
---
260+
200 OK
261+
Transfer-Encoding: chunked
262+
Content-Type: application/json
263+
264+
{
265+
"type": "ADDED",
266+
"object": {"kind": "Pod", "apiVersion": "v1", "metadata": {"resourceVersion": "8467", "name": "foo"}, ...}
267+
}
268+
{
269+
"type": "ADDED",
270+
"object": {"kind": "Pod", "apiVersion": "v1", "metadata": {"resourceVersion": "5726", "name": "bar"}, ...}
271+
}
272+
{
273+
"type": "BOOKMARK",
274+
"object": {"kind": "Pod", "apiVersion": "v1", "metadata": {"resourceVersion": "10245"} }
275+
}
276+
...
277+
<followed by regular watch stream starting from resourceVersion="10245">
278+
```
279+
229280
## Retrieving large results sets in chunks
230281

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

0 commit comments

Comments
 (0)