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
Add application/yaml section in api-concepts (#48417)
* fix: add application/yaml section in api-concepts
* nit fix: breaking the request and response into distinct code blocks
* fix: split the request and response into separate code blocks
Copy file name to clipboardExpand all lines: content/en/docs/reference/using-api/api-concepts.md
+51-15Lines changed: 51 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -126,18 +126,9 @@ virtual resource type would be used if that becomes necessary.
126
126
127
127
Over HTTP, Kubernetes supports JSON and Protobuf wire encodings.
128
128
129
-
{{% note %}}
130
-
Although YAML is widely used to define Kubernetes manifests locally, Kubernetes does not
131
-
support the [`application/yaml`](https://www.rfc-editor.org/rfc/rfc9512.html) media type
132
-
for API operations.
133
-
134
-
All JSON documents are valid YAML, so you can also use a JSON API response anywhere that is
135
-
expecting a YAML input.
136
-
{{% /note %}}
137
-
138
129
By default, Kubernetes returns objects in [JSON serialization](#json-encoding), using the
139
-
`application/json` media type. Although JSON is the default, clients may request the more
140
-
efficient binary [Protobuf representation](#protobuf-encoding) for better performance at scale.
130
+
`application/json` media type. Although JSON is the default, clients may request a response in
131
+
YAML, or use the more efficient binary [Protobuf representation](#protobuf-encoding) for better performance at scale.
141
132
142
133
The Kubernetes API implements standard HTTP content type negotiation: passing an
143
134
`Accept` header with a `GET` call will request that the server tries to return
@@ -161,7 +152,9 @@ For example:
161
152
162
153
```
163
154
GET /api/v1/pods
164
-
---
155
+
```
156
+
157
+
```
165
158
200 OK
166
159
Content-Type: application/json
167
160
@@ -175,7 +168,9 @@ For example:
175
168
Content-Type: application/json
176
169
Accept: application/json
177
170
… JSON encoded Pod object
178
-
---
171
+
```
172
+
173
+
```
179
174
200 OK
180
175
Content-Type: application/json
181
176
@@ -186,6 +181,43 @@ For example:
186
181
}
187
182
```
188
183
184
+
### 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.
186
+
187
+
For example:
188
+
189
+
1. List all of the pods on a cluster in YAML format
190
+
```
191
+
GET /api/v1/pods
192
+
Accept: application/yaml
193
+
```
194
+
195
+
```
196
+
200 OK
197
+
Content-Type: application/yaml
198
+
199
+
… YAML encoded collection of Pods (PodList object)
200
+
```
201
+
202
+
1. Create a pod by sending YAML-encoded data to the server, requesting a YAML response:
0 commit comments