Skip to content

Commit 5607a0b

Browse files
committed
Clean up using-api/api-concepts.md
1 parent ce8a338 commit 5607a0b

File tree

1 file changed

+58
-53
lines changed

1 file changed

+58
-53
lines changed

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

Lines changed: 58 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,11 @@ Almost all object resource types support the standard HTTP verbs - GET, POST, PU
6868
and DELETE. Kubernetes also uses its own verbs, which are often written in lowercase to distinguish
6969
them from HTTP verbs.
7070

71-
Kubernetes uses the term **list** to describe returning a [collection](#collections) of
72-
resources to distinguish from retrieving a single resource which is usually called
71+
Kubernetes uses the term **list** to describe the action of returning a [collection](#collections) of
72+
resources, to distinguish it from retrieving a single resource which is usually called
7373
a **get**. If you sent an HTTP GET request with the `?watch` query parameter,
74-
Kubernetes calls this a **watch** and not a **get** (see
75-
[Efficient detection of changes](#efficient-detection-of-changes) for more details).
74+
Kubernetes calls this a **watch** and not a **get**
75+
(see [Efficient detection of changes](#efficient-detection-of-changes) for more details).
7676

7777
For PUT requests, Kubernetes internally classifies these as either **create** or **update**
7878
based on the state of the existing object. An **update** is different from a **patch**; the
@@ -335,17 +335,16 @@ Accept: application/vnd.kubernetes.protobuf, application/json
335335

336336
{{< feature-state feature_gate_name="CBORServingAndStorage" >}}
337337

338-
With the `CBORServingAndStorage` [feature
339-
gate](/docs/reference/command-line-tools-reference/feature-gates/) enabled, request and response
340-
bodies for all built-in resource types and all resources defined by a {{< glossary_tooltip
341-
term_id="CustomResourceDefinition" text="CustomResourceDefinition" >}} may be encoded to the
342-
[CBOR](https://www.rfc-editor.org/rfc/rfc8949) binary data format. CBOR is also supported at the {{<
343-
glossary_tooltip text="aggregation layer" term_id="aggregation-layer" >}} if it is enabled in
338+
With the `CBORServingAndStorage` [feature gate](/docs/reference/command-line-tools-reference/feature-gates/)
339+
enabled, request and response bodies for all built-in resource types and all resources defined by a
340+
{{< glossary_tooltip term_id="CustomResourceDefinition" text="CustomResourceDefinition" >}} may be encoded to the
341+
[CBOR](https://www.rfc-editor.org/rfc/rfc8949) binary data format. CBOR is also supported at the
342+
{{< glossary_tooltip text="aggregation layer" term_id="aggregation-layer" >}} if it is enabled in
344343
individual aggregated API servers.
345344

346345
Clients should indicate the IANA media type `application/cbor` in the `Content-Type` HTTP request
347-
header when the request body contains a single CBOR [encoded data
348-
item](https://www.rfc-editor.org/rfc/rfc8949.html#section-1.2-4.2), and in the `Accept` HTTP request
346+
header when the request body contains a single CBOR
347+
[encoded data item](https://www.rfc-editor.org/rfc/rfc8949.html#section-1.2-4.2), and in the `Accept` HTTP request
349348
header when prepared to accept a CBOR encoded data item in the response. API servers will use
350349
`application/cbor` in the `Content-Type` HTTP response header when the response body contains a
351350
CBOR-encoded object.
@@ -355,8 +354,8 @@ CBOR, the response body will be a [CBOR Sequence](https://www.rfc-editor.org/rfc
355354
`Content-Type` HTTP response header will use the IANA media type `application/cbor-seq`. Each entry
356355
of the sequence (if any) is a single CBOR-encoded watch event.
357356

358-
In addition to the existing `application/apply-patch+yaml` media type for YAML-encoded [server-side
359-
apply configurations](#patch-and-apply), API servers that enable CBOR will accept the
357+
In addition to the existing `application/apply-patch+yaml` media type for YAML-encoded
358+
[server-side apply configurations](#patch-and-apply), API servers that enable CBOR will accept the
360359
`application/apply-patch+cbor` media type for CBOR-encoded server-side apply configurations. There
361360
is no supported CBOR equivalent for `application/json-patch+json` or `application/merge-patch+json`,
362361
or `application/strategic-merge-patch+json`.
@@ -388,7 +387,7 @@ For example:
388387

389388
1. List all of the pods in a given namespace.
390389

391-
```
390+
```http
392391
GET /api/v1/namespaces/test/pods
393392
---
394393
200 OK
@@ -407,7 +406,7 @@ For example:
407406
_test_ namespace. Each change notification is a JSON document. The HTTP response body
408407
(served as `application/json`) consists a series of JSON documents.
409408

410-
```
409+
```http
411410
GET /api/v1/namespaces/test/pods?watch=1&resourceVersion=10245
412411
---
413412
200 OK
@@ -444,7 +443,7 @@ to a given `resourceVersion` the client is requesting have already been sent. Th
444443
document representing the `BOOKMARK` event is of the type requested by the request,
445444
but only includes a `.metadata.resourceVersion` field. For example:
446445

447-
```
446+
```http
448447
GET /api/v1/namespaces/test/pods?watch=1&resourceVersion=10245&allowWatchBookmarks=true
449448
---
450449
200 OK
@@ -474,7 +473,7 @@ the API server will send any `BOOKMARK` event even when requested.
474473
On large clusters, retrieving the collection of some resource types may result in
475474
a significant increase of resource usage (primarily RAM) on the control plane.
476475
To alleviate the impact and simplify the user experience of the **list** + **watch**
477-
pattern, Kubernetes v1.32 promotes to beta the feature that allows requesting the initial state
476+
pattern, Kubernetes v1.32 promotes to beta the feature that allows requesting the initial state
478477
(previously requested via the **list** request) as part of the **watch** request.
479478

480479
On the client-side the initial state can be requested by specifying `sendInitialEvents=true` as query string parameter
@@ -500,7 +499,7 @@ is 10245 and there are two pods: `foo` and `bar`. Then sending the following req
500499
_consistent read_ by setting empty resource version using `resourceVersion=`) could result
501500
in the following sequence of events:
502501

503-
```
502+
```http
504503
GET /api/v1/namespaces/test/pods?watch=1&sendInitialEvents=true&allowWatchBookmarks=true&resourceVersion=&resourceVersionMatch=NotOlderThan
505504
---
506505
200 OK
@@ -541,7 +540,7 @@ can be saved and the latency can be reduced.
541540
To verify if `APIResponseCompression` is working, you can send a **get** or **list** request to the
542541
API server with an `Accept-Encoding` header, and check the response size and headers. For example:
543542

544-
```
543+
```http
545544
GET /api/v1/pods
546545
Accept-Encoding: gzip
547546
---
@@ -592,7 +591,7 @@ of 500 pods at a time, request those chunks as follows:
592591

593592
1. List all of the pods on a cluster, retrieving up to 500 pods each time.
594593

595-
```
594+
```http
596595
GET /api/v1/pods?limit=500
597596
---
598597
200 OK
@@ -613,7 +612,7 @@ of 500 pods at a time, request those chunks as follows:
613612

614613
1. Continue the previous call, retrieving the next set of 500 pods.
615614

616-
```
615+
```http
617616
GET /api/v1/pods?limit=500&continue=ENCODED_CONTINUE_TOKEN
618617
---
619618
200 OK
@@ -634,7 +633,7 @@ of 500 pods at a time, request those chunks as follows:
634633

635634
1. Continue the previous call, retrieving the last 253 pods.
636635

637-
```
636+
```http
638637
GET /api/v1/pods?limit=500&continue=ENCODED_CONTINUE_TOKEN_2
639638
---
640639
200 OK
@@ -655,7 +654,7 @@ of 500 pods at a time, request those chunks as follows:
655654
Notice that the `resourceVersion` of the collection remains constant across each request,
656655
indicating the server is showing you a consistent snapshot of the pods. Pods that
657656
are created, updated, or deleted after version `10245` would not be shown unless
658-
you make a separate **list** request without the `continue` token. This allows you
657+
you make a separate **list** request without the `continue` token. This allows you
659658
to break large requests into smaller chunks and then perform a **watch** operation
660659
on the full set without missing any updates.
661660

@@ -682,7 +681,7 @@ has `kind` set to
682681
[`ServiceList`](/docs/reference/kubernetes-api/service-resources/service-v1/#ServiceList);
683682
each item in that collection represents a single Service. For example:
684683

685-
```
684+
```http
686685
GET /api/v1/services
687686
```
688687

@@ -779,7 +778,7 @@ type.
779778

780779
For example, list all of the pods on a cluster in the Table format.
781780

782-
```
781+
```http
783782
GET /api/v1/pods
784783
Accept: application/json;as=Table;g=meta.k8s.io;v=v1
785784
---
@@ -800,7 +799,7 @@ For API resource types that do not have a custom Table definition known to the c
800799
plane, the API server returns a default Table response that consists of the resource's
801800
`name` and `creationTimestamp` fields.
802801

803-
```
802+
```http
804803
GET /apis/crd.example.com/v1alpha1/namespaces/default/resources
805804
---
806805
200 OK
@@ -844,7 +843,7 @@ Accept: application/json;as=Table;g=meta.k8s.io;v=v1, application/json
844843
When you **delete** a resource this takes place in two phases.
845844

846845
1. _finalization_
847-
2. removal
846+
1. removal
848847

849848
```yaml
850849
{
@@ -857,7 +856,8 @@ When you **delete** a resource this takes place in two phases.
857856
}
858857
```
859858

860-
When a client first sends a **delete** to request the removal of a resource, the `.metadata.deletionTimestamp` is set to the current time.
859+
When a client first sends a **delete** to request the removal of a resource,
860+
the `.metadata.deletionTimestamp` is set to the current time.
861861
Once the `.metadata.deletionTimestamp` is set, external controllers that act on finalizers
862862
may start performing their cleanup work at any time, in any order.
863863

@@ -896,8 +896,12 @@ the **delete** and **unsafe-delete-ignore-read-errors** verbs on the given resou
896896
{{< /note >}}
897897

898898
A resource is considered corrupt if it can not be successfully retrieved from the
899-
storage due to a) transformation error (for example: decryption failure), or b) the object
900-
failed to decode. The API server first attempts a normal deletion, and if it fails with
899+
storage due to:
900+
901+
- transformation error (for example: decryption failure), or
902+
- the object failed to decode.
903+
904+
The API server first attempts a normal deletion, and if it fails with
901905
a _corrupt resource_ error then it triggers the force delete. A force **delete** operation
902906
is unsafe because it ignores finalizer constraints, and skips precondition checks.
903907

@@ -944,18 +948,17 @@ an HTTP request.
944948
These situations are:
945949

946950
1. The field is unrecognized because it is not in the resource's OpenAPI schema. (One
947-
exception to this is for {{< glossary_tooltip
948-
term_id="CustomResourceDefinition" text="CRDs" >}} that explicitly choose not to prune unknown
949-
fields via `x-kubernetes-preserve-unknown-fields`).
951+
exception to this is for {{< glossary_tooltip term_id="CustomResourceDefinition" text="CRDs" >}}
952+
that explicitly choose not to prune unknown fields via `x-kubernetes-preserve-unknown-fields`).
950953
1. The field is duplicated in the object.
951954

952955
### Validation for unrecognized or duplicate fields {#setting-the-field-validation-level}
953956

954957
{{< feature-state feature_gate_name="ServerSideFieldValidation" >}}
955958

956959
From 1.25 onward, unrecognized or duplicate fields in an object are detected via
957-
validation on the server when you use HTTP verbs that can submit data (`POST`, `PUT`, and `PATCH`). Possible levels of
958-
validation are `Ignore`, `Warn` (default), and `Strict`.
960+
validation on the server when you use HTTP verbs that can submit data (`POST`, `PUT`, and `PATCH`).
961+
Possible levels of validation are `Ignore`, `Warn` (default), and `Strict`.
959962

960963
`Ignore`
961964
: The API server succeeds in handling the request as it would without the erroneous fields
@@ -1003,7 +1006,7 @@ Client-side validation will be removed entirely in a future version of kubectl.
10031006

10041007
{{< note >}}
10051008

1006-
Prior to Kubernetes 1.25 `kubectl --validate` was used to toggle client-side validation on or off as
1009+
Prior to Kubernetes 1.25, `kubectl --validate` was used to toggle client-side validation on or off as
10071010
a boolean flag.
10081011

10091012
{{< /note >}}
@@ -1056,7 +1059,7 @@ effects on any request marked as dry runs.
10561059

10571060
Here is an example dry-run request that uses `?dryRun=All`:
10581061

1059-
```
1062+
```http
10601063
POST /api/v1/namespaces/test/pods?dryRun=All
10611064
Content-Type: application/json
10621065
Accept: application/json
@@ -1127,14 +1130,14 @@ corresponding HTTP `Content-Type` header:
11271130
: Server Side Apply YAML (a Kubernetes-specific extension, based on YAML).
11281131
All JSON documents are valid YAML, so you can also submit JSON using this
11291132
media type. See [Server Side Apply serialization](/docs/reference/using-api/server-side-apply/#serialization)
1130-
for more details.
1133+
for more details.
11311134
To Kubernetes, this is a **create** operation if the object does not exist,
11321135
or a **patch** operation if the object already exists.
11331136

11341137
`application/json-patch+json`
11351138
: JSON Patch, as defined in [RFC6902](https://tools.ietf.org/html/rfc6902).
11361139
A JSON patch is a sequence of operations that are executed on the resource;
1137-
for example `{"op": "add", "path": "/a/b/c", "value": [ "foo", "bar" ]}`.
1140+
for example `{"op": "add", "path": "/a/b/c", "value": [ "foo", "bar" ]}`.
11381141
To Kubernetes, this is a **patch** operation.
11391142

11401143
A **patch** using `application/json-patch+json` can include conditions to
@@ -1145,7 +1148,7 @@ corresponding HTTP `Content-Type` header:
11451148
: JSON Merge Patch, as defined in [RFC7386](https://tools.ietf.org/html/rfc7386).
11461149
A JSON Merge Patch is essentially a partial representation of the resource.
11471150
The submitted JSON is combined with the current resource to create a new one,
1148-
then the new one is saved.
1151+
then the new one is saved.
11491152
To Kubernetes, this is a **patch** operation.
11501153

11511154
`application/strategic-merge-patch+json`
@@ -1333,23 +1336,23 @@ Any
13331336
Most recent
13341337
: Return data at the most recent resource version. The returned data must be
13351338
consistent (in detail: served from etcd via a quorum read).
1336-
For etcd v3.4.31+ and v3.5.13+ Kubernetes {{< skew currentVersion >}} serves “most recent” reads from the _watch cache_:
1339+
For etcd v3.4.31+ and v3.5.13+, Kubernetes {{< skew currentVersion >}} serves “most recent” reads from the _watch cache_:
13371340
an internal, in-memory store within the API server that caches and mirrors the state of data
13381341
persisted into etcd. Kubernetes requests progress notification to maintain cache consistency against
1339-
the etcd persistence layer. Kubernetes versions v1.28 through to v1.30 also supported this
1342+
the etcd persistence layer. Kubernetes v1.28 through to v1.30 also supported this
13401343
feature, although as Alpha it was not recommended for production nor enabled by default until the v1.31 release.
13411344

13421345
Not older than
13431346
: Return data at least as new as the provided `resourceVersion`. The newest
13441347
available data is preferred, but any data not older than the provided `resourceVersion` may be
1345-
served. For **list** requests to servers that honor the `resourceVersionMatch` parameter, this
1348+
served. For **list** requests to servers that honor the `resourceVersionMatch` parameter, this
13461349
guarantees that the collection's `.metadata.resourceVersion` is not older than the requested
13471350
`resourceVersion`, but does not make any guarantee about the `.metadata.resourceVersion` of any
13481351
of the items in that collection.
13491352

13501353
Exact
13511354
: Return data at the exact resource version provided. If the provided `resourceVersion` is
1352-
unavailable, the server responds with HTTP 410 "Gone". For **list** requests to servers that honor the
1355+
unavailable, the server responds with HTTP `410 Gone`. For **list** requests to servers that honor the
13531356
`resourceVersionMatch` parameter, this guarantees that the collection's `.metadata.resourceVersion`
13541357
is the same as the `resourceVersion` you requested in the query string. That guarantee does
13551358
not apply to the `.metadata.resourceVersion` of any items within that collection.
@@ -1370,7 +1373,7 @@ the object is when served.
13701373
{{< /note >}}
13711374

13721375
When using `resourceVersionMatch=NotOlderThan` and limit is set, clients must
1373-
handle HTTP 410 "Gone" responses. For example, the client might retry with a
1376+
handle HTTP `410 Gone` responses. For example, the client might retry with a
13741377
newer `resourceVersion` or fall back to `resourceVersion=""`.
13751378

13761379
When using `resourceVersionMatch=Exact` and `limit` is unset, clients must
@@ -1395,11 +1398,7 @@ For **watch**, the semantics of resource version are:
13951398
The meaning of those **watch** semantics are:
13961399

13971400
Get State and Start at Any
1398-
: {{< caution >}} Watches initialized this way may return arbitrarily stale
1399-
data. Please review this semantic before using it, and favor the other semantics
1400-
where possible.
1401-
{{< /caution >}}
1402-
Start a **watch** at any resource version; the most recent resource version
1401+
: Start a **watch** at any resource version; the most recent resource version
14031402
available is preferred, but not required. Any starting resource version is
14041403
allowed. It is possible for the **watch** to start at a much older resource
14051404
version that the client has previously observed, particularly in high availability
@@ -1410,6 +1409,12 @@ Get State and Start at Any
14101409
watch events are for all changes that occurred after the resource version the
14111410
**watch** started at.
14121411

1412+
{{< caution >}}
1413+
**watches** initialized this way may return arbitrarily stale
1414+
data. Please review this semantic before using it, and favor the other semantics
1415+
where possible.
1416+
{{< /caution >}}
1417+
14131418
Get State and Start at Most Recent
14141419
: Start a **watch** at the most recent resource version, which must be consistent
14151420
(in detail: served from etcd via a quorum read). To establish initial state,
@@ -1450,8 +1455,8 @@ then the API server may either:
14501455
should wait before retrying the request.
14511456

14521457
If you request a resource version that an API server does not recognize, the
1453-
kube-apiserver additionally identifies its error responses with a "Too large resource
1454-
version" message.
1458+
kube-apiserver additionally identifies its error responses with a message
1459+
`Too large resource version`.
14551460

14561461
If you make a **watch** request for an unrecognized resource version, the API server
14571462
may wait indefinitely (until the request timeout) for the resource version to become

0 commit comments

Comments
 (0)