@@ -34,28 +34,28 @@ external components communicate with one another.
34
34
35
35
The Kubernetes API lets you query and manipulate the state of API objects in Kubernetes
36
36
(for example: Pods, Namespaces, ConfigMaps, and Events).
37
+ -->
38
+ Kubernetes {{< glossary_tooltip text="控制面" term_id="control-plane" >}}的核心是
39
+ {{< glossary_tooltip text="API 服务器" term_id="kube-apiserver" >}}。
40
+ API 服务器负责提供 HTTP API,以供用户、集群中的不同部分和集群外部组件相互通信。
41
+
42
+ Kubernetes API 使你可以在 Kubernetes 中查询和操纵 API 对象
43
+ (例如 Pod、Namespace、ConfigMap 和 Event)的状态。
37
44
45
+ <!--
38
46
Most operations can be performed through the
39
47
[kubectl](/docs/reference/kubectl/) command-line interface or other
40
48
command-line tools, such as
41
49
[kubeadm](/docs/reference/setup-tools/kubeadm/), which in turn use the
42
50
API. However, you can also access the API directly using REST calls.
43
- -->
44
- Kubernetes {{< glossary_tooltip text="控制面" term_id="control-plane" >}}的核心是
45
- {{< glossary_tooltip text="API 服务器" term_id="kube-apiserver" >}}。
46
- API 服务器负责提供 HTTP API,以供用户、集群中的不同部分和集群外部组件相互通信。
47
-
48
- Kubernetes API 使你可以查询和操纵 Kubernetes API
49
- 中对象(例如:Pod、Namespace、ConfigMap 和 Event)的状态。
50
51
52
+ Consider using one of the [client libraries](/docs/reference/using-api/client-libraries/)
53
+ if you are writing an application using the Kubernetes API.
54
+ -->
51
55
大部分操作都可以通过 [ kubectl] ( /zh-cn/docs/reference/kubectl/ ) 命令行接口或类似
52
56
[ kubeadm] ( /zh-cn/docs/reference/setup-tools/kubeadm/ ) 这类命令行工具来执行,
53
57
这些工具在背后也是调用 API。不过,你也可以使用 REST 调用来访问这些 API。
54
58
55
- <!--
56
- Consider using one of the [client libraries](/docs/reference/using-api/client-libraries/)
57
- if you are writing an application using the Kubernetes API.
58
- -->
59
59
如果你正在编写程序来访问 Kubernetes API,
60
60
可以考虑使用[ 客户端库] ( /zh-cn/docs/reference/using-api/client-libraries/ ) 之一。
61
61
@@ -76,7 +76,7 @@ request headers as follows:
76
76
77
77
完整的 API 细节是用 [ OpenAPI] ( https://www.openapis.org/ ) 来表述的。
78
78
79
- ### OpenAPI V2
79
+ ### OpenAPI v2
80
80
81
81
Kubernetes API 服务器通过 ` /openapi/v2 ` 端点提供聚合的 OpenAPI v2 规范。
82
82
你可以按照下表所给的请求头部,指定响应的格式:
@@ -156,26 +156,19 @@ Kubernetes 为 API 实现了一种基于 Protobuf 的序列化格式,主要用
156
156
[ Kubernetes Protobuf 序列化] ( https://git.k8s.io/design-proposals-archive/api-machinery/protobuf.md ) 设计提案。
157
157
每种模式对应的接口描述语言(IDL)位于定义 API 对象的 Go 包中。
158
158
159
- ### OpenAPI V3
159
+ ### OpenAPI v3
160
160
161
- {{< feature-state state="beta " for_k8s_version="v1.24 " >}}
161
+ {{< feature-state state="stable " for_k8s_version="v1.27 " >}}
162
162
163
163
<!--
164
- Kubernetes {{< param "version" >}} offers beta support for publishing its APIs as OpenAPI v3; this is a
165
- beta feature that is enabled by default.
166
- You can disable the beta feature by turning off the
167
- [feature gate](/docs/reference/command-line-tools-reference/feature-gates/) named `OpenAPIV3`
168
- for the kube-apiserver component.
164
+ Kubernetes supports publishing a description of its APIs as OpenAPI v3.
169
165
-->
170
- Kubernetes {{< param "version" >}} 提供将其 API 以 OpenAPI v3 形式发布的 beta 支持;
171
- 这一功能特性处于 beta 状态,默认被开启。
172
- 你可以通过为 kube-apiserver 组件关闭 ` OpenAPIV3 `
173
- [ 特性门控] ( /zh-cn/docs/reference/command-line-tools-reference/feature-gates/ ) 来禁用此 beta 特性。
166
+ Kubernetes 支持将其 API 的描述以 OpenAPI v3 形式发布。
174
167
175
168
<!--
176
169
A discovery endpoint `/openapi/v3` is provided to see a list of all
177
- group/versions available. This endpoint only returns JSON. These group/versions
178
- are provided in the following format:
170
+ group/versions available. This endpoint only returns JSON. These
171
+ group/versions are provided in the following format:
179
172
-->
180
173
发现端点 ` /openapi/v3 ` 被提供用来查看可用的所有组、版本列表。
181
174
此列表仅返回 JSON。这些组、版本以下面的格式提供:
@@ -251,16 +244,66 @@ Kubernetes API 服务器会在端点 `/openapi/v3/apis/<group>/<version>?hash=<h
251
244
</tbody >
252
245
</table >
253
246
247
+ <!--
248
+ A Golang implementation to fetch the OpenAPI V3 is provided in the package `k8s.io/client-go/openapi3`.
249
+ -->
250
+ ` k8s.io/client-go/openapi3 ` 包中提供了获取 OpenAPI v3 的 Golang 实现。
251
+
254
252
<!--
255
253
## Persistence
256
254
257
255
Kubernetes stores the serialized state of objects by writing them into
258
256
{{< glossary_tooltip term_id="etcd" >}}.
259
257
-->
260
- ## 持久化 {#persistence}
258
+ ## 持久化 {#persistence}
261
259
262
260
Kubernetes 通过将序列化状态的对象写入到 {{< glossary_tooltip term_id="etcd" >}} 中完成存储操作。
263
261
262
+ <!--
263
+ ## API Discovery
264
+
265
+ A list of all group versions supported by a cluster is published at
266
+ the `/api` and `/apis` endpoints. Each group version also advertises
267
+ the list of resources supported via `/apis/<group>/<version>` (for
268
+ example: `/apis/rbac.authorization.k8s.io/v1alpha1`). These endpoints
269
+ are used by kubectl to fetch the list of resources supported by a
270
+ cluster.
271
+ -->
272
+ ## API 发现 {#api-discovery}
273
+
274
+ 集群支持的所有组版本列表被发布在 ` /api ` 和 ` /apis ` 端点。
275
+ 每个组版本还会通过 ` /apis/<group>/<version> `
276
+ (例如 ` /apis/rbac.authorization.k8s.io/v1alpha1 ` )广播支持的资源列表。
277
+ 这些端点由 kubectl 用于获取集群支持的资源列表。
278
+
279
+ <!--
280
+ ### Aggregated Discovery
281
+ -->
282
+ ### 聚合发现 {#aggregated-discovery}
283
+
284
+ {{< feature-state state="beta" for_k8s_version="v1.27" >}}
285
+
286
+ <!--
287
+ Kubernetes offers beta support for aggregated discovery, publishing
288
+ all resources supported by a cluster through two endpoints (`/api` and
289
+ `/apis`) compared to one for every group version. Requesting this
290
+ endpoint drastically reduces the number of requests sent to fetch the
291
+ discovery for the average Kubernetes cluster. This may be accessed by
292
+ requesting the respective endpoints with an Accept header indicating
293
+ the aggregated discovery resource:
294
+ `Accept: application/json;v=v2beta1;g=apidiscovery.k8s.io;as=APIGroupDiscoveryList`.
295
+
296
+ The endpoint also supports ETag and protobuf encoding.
297
+ -->
298
+ Kubernetes 对聚合发现提供 Beta 支持,通过两个端点(` /api ` 和 ` /apis ` )
299
+ 发布集群支持的所有资源,而不是每个组版本都需要一个端点。
300
+ 请求此端点显著减少了获取平均 Kubernetes 集群发现而发送的请求数量。
301
+ 通过请求各自的端点并附带表明聚合发现资源
302
+ ` Accept: application/json;v=v2beta1;g=apidiscovery.k8s.io;as=APIGroupDiscoveryList `
303
+ 的 Accept 头部来进行访问。
304
+
305
+ 该端点还支持 ETag 和 protobuf 编码。
306
+
264
307
<!--
265
308
## API groups and versioning
266
309
@@ -291,12 +334,6 @@ API resources are distinguished by their API group, resource type, namespace
291
334
API versions transparently: all the different versions are actually representations
292
335
of the same persisted data. The API server may serve the same underlying data
293
336
through multiple API versions.
294
-
295
- For example, suppose there are two API versions, `v1` and `v1beta1`, for the same
296
- resource. If you originally created an object using the `v1beta1` version of its
297
- API, you can later read, update, or delete that object using either the `v1beta1`
298
- or the `v1` API version, until the `v1beta1` version is deprecated and removed.
299
- At that point you can continue accessing and modifying the object using the `v1` API.
300
337
-->
301
338
为了更容易演进和扩展其 API,Kubernetes 实现了 [ API 组] ( /zh-cn/docs/reference/using-api/#api-groups ) ,
302
339
这些 API 组可以被[ 启用或禁用] ( /zh-cn/docs/reference/using-api/#enabling-or-disabling ) 。
@@ -305,6 +342,13 @@ API 资源通过其 API 组、资源类型、名字空间(用于名字空间
305
342
API 服务器透明地处理 API 版本之间的转换:所有不同的版本实际上都是相同持久化数据的呈现。
306
343
API 服务器可以通过多个 API 版本提供相同的底层数据。
307
344
345
+ <!--
346
+ For example, suppose there are two API versions, `v1` and `v1beta1`, for the same
347
+ resource. If you originally created an object using the `v1beta1` version of its
348
+ API, you can later read, update, or delete that object using either the `v1beta1`
349
+ or the `v1` API version, until the `v1beta1` version is deprecated and removed.
350
+ At that point you can continue accessing and modifying the object using the `v1` API.
351
+ -->
308
352
例如,假设针对相同的资源有两个 API 版本:` v1 ` 和 ` v1beta1 ` 。
309
353
如果你最初使用其 API 的 ` v1beta1 ` 版本创建了一个对象,
310
354
你稍后可以使用 ` v1beta1 ` 或 ` v1 ` API 版本来读取、更新或删除该对象,
@@ -413,4 +457,3 @@ The Kubernetes API can be extended in one of two ways:
413
457
- 通过阅读 [ API 参考] ( /zh-cn/docs/reference/kubernetes-api/ ) 了解 API 端点、资源类型以及示例。
414
458
- 阅读 [ API 变更(英文)] ( https://git.k8s.io/community/contributors/devel/sig-architecture/api_changes.md#readme )
415
459
以了解什么是兼容性的变更以及如何变更 API。
416
-
0 commit comments