Skip to content

Commit 4187915

Browse files
committed
[zh] sync /concepts/overview/kubernetes-api.md
1 parent 07ffcd1 commit 4187915

File tree

1 file changed

+76
-33
lines changed

1 file changed

+76
-33
lines changed

content/zh-cn/docs/concepts/overview/kubernetes-api.md

Lines changed: 76 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -34,28 +34,28 @@ external components communicate with one another.
3434
3535
The Kubernetes API lets you query and manipulate the state of API objects in Kubernetes
3636
(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)的状态。
3744

45+
<!--
3846
Most operations can be performed through the
3947
[kubectl](/docs/reference/kubectl/) command-line interface or other
4048
command-line tools, such as
4149
[kubeadm](/docs/reference/setup-tools/kubeadm/), which in turn use the
4250
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)的状态。
5051
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+
-->
5155
大部分操作都可以通过 [kubectl](/zh-cn/docs/reference/kubectl/) 命令行接口或类似
5256
[kubeadm](/zh-cn/docs/reference/setup-tools/kubeadm/) 这类命令行工具来执行,
5357
这些工具在背后也是调用 API。不过,你也可以使用 REST 调用来访问这些 API。
5458

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-
-->
5959
如果你正在编写程序来访问 Kubernetes API,
6060
可以考虑使用[客户端库](/zh-cn/docs/reference/using-api/client-libraries/)之一。
6161

@@ -76,7 +76,7 @@ request headers as follows:
7676

7777
完整的 API 细节是用 [OpenAPI](https://www.openapis.org/) 来表述的。
7878

79-
### OpenAPI V2
79+
### OpenAPI v2
8080

8181
Kubernetes API 服务器通过 `/openapi/v2` 端点提供聚合的 OpenAPI v2 规范。
8282
你可以按照下表所给的请求头部,指定响应的格式:
@@ -156,26 +156,19 @@ Kubernetes 为 API 实现了一种基于 Protobuf 的序列化格式,主要用
156156
[Kubernetes Protobuf 序列化](https://git.k8s.io/design-proposals-archive/api-machinery/protobuf.md)设计提案。
157157
每种模式对应的接口描述语言(IDL)位于定义 API 对象的 Go 包中。
158158

159-
### OpenAPI V3
159+
### OpenAPI v3
160160

161-
{{< feature-state state="beta" for_k8s_version="v1.24" >}}
161+
{{< feature-state state="stable" for_k8s_version="v1.27" >}}
162162

163163
<!--
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.
169165
-->
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 形式发布。
174167

175168
<!--
176169
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:
179172
-->
180173
发现端点 `/openapi/v3` 被提供用来查看可用的所有组、版本列表。
181174
此列表仅返回 JSON。这些组、版本以下面的格式提供:
@@ -251,16 +244,66 @@ Kubernetes API 服务器会在端点 `/openapi/v3/apis/<group>/<version>?hash=<h
251244
</tbody>
252245
</table>
253246

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+
254252
<!--
255253
## Persistence
256254
257255
Kubernetes stores the serialized state of objects by writing them into
258256
{{< glossary_tooltip term_id="etcd" >}}.
259257
-->
260-
## 持久化 {#persistence}
258+
## 持久化 {#persistence}
261259

262260
Kubernetes 通过将序列化状态的对象写入到 {{< glossary_tooltip term_id="etcd" >}} 中完成存储操作。
263261

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+
264307
<!--
265308
## API groups and versioning
266309
@@ -291,12 +334,6 @@ API resources are distinguished by their API group, resource type, namespace
291334
API versions transparently: all the different versions are actually representations
292335
of the same persisted data. The API server may serve the same underlying data
293336
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.
300337
-->
301338
为了更容易演进和扩展其 API,Kubernetes 实现了 [API 组](/zh-cn/docs/reference/using-api/#api-groups)
302339
这些 API 组可以被[启用或禁用](/zh-cn/docs/reference/using-api/#enabling-or-disabling)
@@ -305,6 +342,13 @@ API 资源通过其 API 组、资源类型、名字空间(用于名字空间
305342
API 服务器透明地处理 API 版本之间的转换:所有不同的版本实际上都是相同持久化数据的呈现。
306343
API 服务器可以通过多个 API 版本提供相同的底层数据。
307344

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+
-->
308352
例如,假设针对相同的资源有两个 API 版本:`v1``v1beta1`
309353
如果你最初使用其 API 的 `v1beta1` 版本创建了一个对象,
310354
你稍后可以使用 `v1beta1``v1` API 版本来读取、更新或删除该对象,
@@ -413,4 +457,3 @@ The Kubernetes API can be extended in one of two ways:
413457
- 通过阅读 [API 参考](/zh-cn/docs/reference/kubernetes-api/)了解 API 端点、资源类型以及示例。
414458
- 阅读 [API 变更(英文)](https://git.k8s.io/community/contributors/devel/sig-architecture/api_changes.md#readme)
415459
以了解什么是兼容性的变更以及如何变更 API。
416-

0 commit comments

Comments
 (0)