@@ -226,6 +226,63 @@ As a client, you can request `BOOKMARK` events by setting the
226
226
assume bookmarks are returned at any specific interval, nor can clients assume that
227
227
the API server will send any ` BOOKMARK ` event even when requested.
228
228
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 API 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). The bookmark event includes the resource for that
245
+ watch bookmark. After sending the bookmark event, the API server continues as for any other ** watch**
246
+ request.
247
+
248
+ When you set ` sendInitialEvents=true ` in the query string, Kubernetes also requires that you set
249
+ ` resourceVersionMatch ` to ` NotOlderThan ` value.
250
+ If you provided ` resourceVersion ` in the query string without providing a value or don't provide
251
+ it at all, this is interpreted as a request for _ consistent read_ ;
252
+ the bookmark event is sent when the state is synced at least to the moment of a consistent read
253
+ from when the request started to be processed. If you specify ` resourceVersion ` (in the query string),
254
+ the bookmark event is sent when the state is synced at least to the provided resource version.
255
+
256
+ ### Example {#example-streaming-lists}
257
+
258
+ An example: you want to watch a collection of Pods. For that collection, the current resource version
259
+ is 10245 and there are two pods: ` foo ` and ` bar ` . Then sending the following request (explicitly requesting
260
+ _ consistent read_ by setting empty resource version using ` resourceVersion= ` ) could result
261
+ in the following sequence of events:
262
+
263
+ ``` console
264
+ GET /api/v1/namespaces/test/pods?watch=1&sendInitialEvents=true&allowWatchBookmarks=true&resourceVersion=&resourceVersionMatch=NotOlderThan
265
+ ---
266
+ 200 OK
267
+ Transfer-Encoding: chunked
268
+ Content-Type: application/json
269
+
270
+ {
271
+ "type": "ADDED",
272
+ "object": {"kind": "Pod", "apiVersion": "v1", "metadata": {"resourceVersion": "8467", "name": "foo"}, ...}
273
+ }
274
+ {
275
+ "type": "ADDED",
276
+ "object": {"kind": "Pod", "apiVersion": "v1", "metadata": {"resourceVersion": "5726", "name": "bar"}, ...}
277
+ }
278
+ {
279
+ "type": "BOOKMARK",
280
+ "object": {"kind": "Pod", "apiVersion": "v1", "metadata": {"resourceVersion": "10245"} }
281
+ }
282
+ ...
283
+ <followed by regular watch stream starting from resourceVersion="10245">
284
+ ```
285
+
229
286
## Retrieving large results sets in chunks
230
287
231
288
{{< feature-state for_k8s_version="v1.9" state="beta" >}}
0 commit comments