@@ -226,6 +226,57 @@ As a client, you can request `BOOKMARK` events by setting the
226226assume bookmarks are returned at any specific interval, nor can clients assume that
227227the 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 sent 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 sent 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 pods: ` 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