You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
return the instance of the resource type with NAME in NAMESPACE
112
115
113
116
Since a namespace is a cluster-scoped resource type, you can retrieve the list
114
117
(“collection”) of all namespaces with `GET /api/v1/namespaces` and details about
@@ -182,11 +185,15 @@ For example:
182
185
```
183
186
184
187
### YAML resource encoding {#yaml-encoding}
185
-
Kubernetes also supports the [`application/yaml`](https://www.rfc-editor.org/rfc/rfc9512.html) media type for both requests and responses. [`YAML`](https://yaml.org/) can be used for defining Kubernetes manifests and API interactions.
188
+
189
+
Kubernetes also supports the [`application/yaml`](https://www.rfc-editor.org/rfc/rfc9512.html)
190
+
media type for both requests and responses. [`YAML`](https://yaml.org/)
191
+
can be used for defining Kubernetes manifests and API interactions.
186
192
187
193
For example:
188
194
189
195
1. List all of the pods on a cluster in YAML format
196
+
190
197
```
191
198
GET /api/v1/pods
192
199
Accept: application/yaml
@@ -200,13 +207,14 @@ For example:
200
207
```
201
208
202
209
1. Create a pod by sending YAML-encoded data to the server, requesting a YAML response:
210
+
203
211
```
204
212
POST /api/v1/namespaces/test/pods
205
213
Content-Type: application/yaml
206
214
Accept: application/yaml
207
215
… YAML encoded Pod object
208
216
```
209
-
217
+
210
218
```
211
219
200 OK
212
220
Content-Type: application/yaml
@@ -224,7 +232,7 @@ Kubernetes uses an envelope wrapper to encode [Protobuf](https://protobuf.dev/)
224
232
That wrapper starts with a 4 byte magic number to help identify content in disk or in etcd as Protobuf
225
233
(as opposed to JSON). The 4 byte magic number data is followed by a Protobuf encoded wrapper message, which
226
234
describes the encoding and type of the underlying object. Within the Protobuf wrapper message,
227
-
the inner object data is recorded using the `raw` field of Unknown (see the [IDL](##protobuf-encoding-idl)
235
+
the inner object data is recorded using the `raw` field of Unknown (see the [IDL](#protobuf-encoding-idl)
The Kubernetes API allows clients to make an initial request for an object or a
@@ -576,7 +583,7 @@ of 500 pods at a time, request those chunks as follows:
576
583
}
577
584
```
578
585
579
-
2. Continue the previous call, retrieving the next set of 500 pods.
586
+
1. Continue the previous call, retrieving the next set of 500 pods.
580
587
581
588
```
582
589
GET /api/v1/pods?limit=500&continue=ENCODED_CONTINUE_TOKEN
@@ -597,7 +604,7 @@ of 500 pods at a time, request those chunks as follows:
597
604
}
598
605
```
599
606
600
-
3. Continue the previous call, retrieving the last 253 pods.
607
+
1. Continue the previous call, retrieving the last 253 pods.
601
608
602
609
```
603
610
GET /api/v1/pods?limit=500&continue=ENCODED_CONTINUE_TOKEN_2
@@ -642,14 +649,15 @@ collections of different types of resource. Collections have a kind
642
649
named for the resource kind, with `List` appended.
643
650
644
651
When you query the API for a particular type, all items returned by that query are
645
-
of that type.
646
-
For example, when you **list** Services, the collection response
652
+
of that type. For example, when you **list** Services, the collection response
647
653
has `kind` set to
648
-
[`ServiceList`](/docs/reference/kubernetes-api/service-resources/service-v1/#ServiceList); each item in that collection represents a single Service. For example:
the object and is randomly generated (non-deterministic)
1009
1016
*`resourceVersion`: tracks the persisted version of the object
1010
1017
* Any field set by a mutating admission controller
1011
1018
* For the `Service` resource: Ports or IP addresses that the kube-apiserver assigns to Service objects
@@ -1045,7 +1052,8 @@ provided is stale), the API server returns a `409 Conflict` error response.
1045
1052
1046
1053
Instead of sending a PUT request, the client can send an instruction to the API
1047
1054
server to **patch** an existing resource. A **patch** is typically appropriate
1048
-
if the change that the client wants to make isn't conditional on the existing data. Clients that need effective detection of lost updates should consider
1055
+
if the change that the client wants to make isn't conditional on the existing data.
1056
+
Clients that need effective detection of lost updates should consider
1049
1057
making their request conditional on the existing `resourceVersion` (either HTTP PUT or HTTP PATCH),
1050
1058
and then handle any retries that are needed in case there is a conflict.
Kubernetes' [Server Side Apply](/docs/reference/using-api/server-side-apply/)
1095
1102
feature allows the control plane to track managed fields for newly created objects.
1096
1103
Server Side Apply provides a clear pattern for managing field conflicts,
@@ -1143,10 +1150,10 @@ A **patch** update is helpful, because:
1143
1150
1144
1151
However:
1145
1152
1146
-
* you need more local (client) logic to build the patch; it helps a lot if you have
1147
-
a library implementation of JSON Patch, or even for making a JSON Patch specifically against Kubernetes
1148
-
* as the author of client software, you need to be careful when building the patch
1149
-
(the HTTP request body) not to drop fields (the order of operations matters)
1153
+
* You need more local (client) logic to build the patch; it helps a lot if you have
1154
+
a library implementation of JSON Patch, or even for making a JSON Patch specifically against Kubernetes.
1155
+
* As the author of client software, you need to be careful when building the patch
1156
+
(the HTTP request body) not to drop fields (the order of operations matters).
1150
1157
1151
1158
#### HTTP PATCH using Server-Side Apply {#update-mechanism-server-side-apply}
1152
1159
@@ -1155,13 +1162,13 @@ Server-Side Apply has some clear benefits:
1155
1162
* A single round trip: it rarely requires making a `GET` request first.
1156
1163
* and you can still detect conflicts for unexpected changes
1157
1164
* you have the option to force override a conflict, if appropriate
1158
-
* Client implementations are easy to make
1165
+
* Client implementations are easy to make.
1159
1166
* You get an atomic create-or-update operation without extra effort
1160
-
(similar to `UPSERT` in some SQL dialects)
1167
+
(similar to `UPSERT` in some SQL dialects).
1161
1168
1162
1169
However:
1163
1170
1164
-
* Server-Side Apply does not work at all for field changes that depend on a current value of the object
1171
+
* Server-Side Apply does not work at all for field changes that depend on a current value of the object.
1165
1172
* You can only apply updates to objects. Some resources in the Kubernetes HTTP API are
1166
1173
not objects (they do not have a `.metadata` field), and Server-Side Apply
1167
1174
is only relevant for Kubernetes objects.
@@ -1183,9 +1190,12 @@ resource versions for greater-than or less-than relationships).
1183
1190
Clients find resource versions in resources, including the resources from the response
1184
1191
stream for a **watch**, or when using **list** to enumerate resources.
1185
1192
1186
-
[v1.meta/ObjectMeta](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#objectmeta-v1-meta) - The `metadata.resourceVersion` of a resource instance identifies the resource version the instance was last modified at.
The `metadata.resourceVersion` of a resource instance identifies the resource version the instance was last modified at.
1187
1195
1188
-
[v1.meta/ListMeta](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#listmeta-v1-meta) - The `metadata.resourceVersion` of a resource collection (the response to a **list**) identifies the resource version at which the collection was constructed.
0 commit comments