Skip to content

Commit c490af8

Browse files
authored
Merge pull request #35965 from windsonsea/jsonyhf
[zh-cn] resync /concepts/overview/kubernetes-api.md
2 parents 4ee9724 + 8c27d18 commit c490af8

File tree

1 file changed

+96
-24
lines changed

1 file changed

+96
-24
lines changed

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

Lines changed: 96 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,19 @@ card:
1010
name: concepts
1111
weight: 30
1212
---
13+
<!--
14+
reviewers:
15+
- chenopis
16+
title: The Kubernetes API
17+
content_type: concept
18+
weight: 30
19+
description: >
20+
The Kubernetes API lets you query and manipulate the state of objects in Kubernetes.
21+
The core of Kubernetes' control plane is the API server and the HTTP API that it exposes. Users, the different parts of your cluster, and external components all communicate with one another through the API server.
22+
card:
23+
name: concepts
24+
weight: 30
25+
-->
1326

1427
<!-- overview -->
1528

@@ -28,23 +41,23 @@ command-line tools, such as
2841
[kubeadm](/docs/reference/setup-tools/kubeadm/), which in turn use the
2942
API. However, you can also access the API directly using REST calls.
3043
-->
31-
Kubernetes {{< glossary_tooltip text="控制面" term_id="control-plane" >}}
32-
的核心是 {{< glossary_tooltip text="API 服务器" term_id="kube-apiserver" >}}。
44+
Kubernetes {{< glossary_tooltip text="控制面" term_id="control-plane" >}}的核心是
45+
{{< glossary_tooltip text="API 服务器" term_id="kube-apiserver" >}}。
3346
API 服务器负责提供 HTTP API,以供用户、集群中的不同部分和集群外部组件相互通信。
3447

3548
Kubernetes API 使你可以查询和操纵 Kubernetes API
3649
中对象(例如:Pod、Namespace、ConfigMap 和 Event)的状态。
3750

38-
大部分操作都可以通过 [kubectl](/zh-cn/docs/reference/kubectl/) 命令行接口或
39-
类似 [kubeadm](/zh-cn/docs/reference/setup-tools/kubeadm/) 这类命令行工具来执行,
51+
大部分操作都可以通过 [kubectl](/zh-cn/docs/reference/kubectl/) 命令行接口或类似
52+
[kubeadm](/zh-cn/docs/reference/setup-tools/kubeadm/) 这类命令行工具来执行,
4053
这些工具在背后也是调用 API。不过,你也可以使用 REST 调用来访问这些 API。
4154

4255
<!--
4356
Consider using one of the [client libraries](/docs/reference/using-api/client-libraries/)
4457
if you are writing an application using the Kubernetes API.
4558
-->
46-
如果你正在编写程序来访问 Kubernetes API,可以考虑使用
47-
[客户端库](/zh-cn/docs/reference/using-api/client-libraries/)之一。
59+
如果你正在编写程序来访问 Kubernetes API,
60+
可以考虑使用[客户端库](/zh-cn/docs/reference/using-api/client-libraries/)之一。
4861

4962
<!-- body -->
5063

@@ -70,6 +83,7 @@ Kubernetes API 服务器通过 `/openapi/v2` 端点提供聚合的 OpenAPI v2
7083

7184
<!--
7285
<table>
86+
<caption style="display:none">Valid request header values for OpenAPI v2 queries</caption>
7387
<thead>
7488
<tr>
7589
<th>Header</th>
@@ -97,10 +111,10 @@ Kubernetes API 服务器通过 `/openapi/v2` 端点提供聚合的 OpenAPI v2
97111
<td><em>serves </em><code>application/json</code></td>
98112
</tr>
99113
</tbody>
100-
<caption>Valid request header values for OpenAPI v2 queries</caption>
101114
</table>
102115
-->
103116
<table>
117+
<caption style="display:none">OpenAPI v2 查询请求的合法头部值</caption>
104118
<thead>
105119
<tr>
106120
<th>头部</th>
@@ -128,20 +142,19 @@ Kubernetes API 服务器通过 `/openapi/v2` 端点提供聚合的 OpenAPI v2
128142
<td><em>提供</em><code>application/json</code></td>
129143
</tr>
130144
</tbody>
131-
<caption>OpenAPI v2 查询请求的合法头部值</caption>
132145
</table>
133146

134147
<!--
135148
Kubernetes implements an alternative Protobuf based serialization format that
136149
is primarily intended for intra-cluster communication. For more information
137-
about this format, see the [Kubernetes Protobuf serialization](https://github.com/kubernetes/community/blob/master/contributors/design-proposals/api-machinery/protobuf.md) design proposal and the
150+
about this format, see the [Kubernetes Protobuf serialization](https://git.k8s.io/design-proposals-archive/api-machinery/protobuf.md) design proposal and the
138151
Interface Definition Language (IDL) files for each schema located in the Go
139152
packages that define the API objects.
140153
-->
141154
Kubernetes 为 API 实现了一种基于 Protobuf 的序列化格式,主要用于集群内部通信。
142155
关于此格式的详细信息,可参考
143-
[Kubernetes Protobuf 序列化](https://github.com/kubernetes/community/blob/master/contributors/design-proposals/api-machinery/protobuf.md)
144-
设计提案。每种模式对应的接口描述语言(IDL)位于定义 API 对象的 Go 包中。
156+
[Kubernetes Protobuf 序列化](https://git.k8s.io/design-proposals-archive/api-machinery/protobuf.md)设计提案。
157+
每种模式对应的接口描述语言(IDL)位于定义 API 对象的 Go 包中。
145158

146159
### OpenAPI V3
147160

@@ -166,19 +179,22 @@ are provided in the following format:
166179
-->
167180
发现端点 `/openapi/v3` 被提供用来查看可用的所有组、版本列表。
168181
此列表仅返回 JSON。这些组、版本以下面的格式提供:
169-
```json
182+
183+
```yaml
170184
{
171185
"paths": {
172-
...
186+
...,
173187
"api/v1": {
174188
"serverRelativeURL": "/openapi/v3/api/v1?hash=CC0E9BFD992D8C59AEC98A1E2336F899E8318D3CF4C68944C3DEC640AF5AB52D864AC50DAA8D145B3494F75FA3CFF939FCBDDA431DAD3CA79738B297795818CF"
175189
},
176190
"apis/admissionregistration.k8s.io/v1": {
177191
"serverRelativeURL": "/openapi/v3/apis/admissionregistration.k8s.io/v1?hash=E19CC93A116982CE5422FC42B590A8AFAD92CDE9AE4D59B5CAAD568F083AD07946E6CB5817531680BCE6E215C16973CD39003B0425F3477CFD854E89A9DB6597"
178192
},
179-
...
193+
....
194+
}
180195
}
181196
```
197+
<!-- for editors: intionally use yaml instead of json here, to prevent syntax highlight error. -->
182198

183199
<!--
184200
The relative URLs are pointing to immutable OpenAPI descriptions, in
@@ -235,20 +251,77 @@ Kubernetes API 服务器会在端点 `/openapi/v3/apis/<group>/<version>?hash=<h
235251
</tbody>
236252
</table>
237253

254+
<!--
255+
## Persistence
256+
257+
Kubernetes stores the serialized state of objects by writing them into
258+
{{< glossary_tooltip term_id="etcd" >}}.
259+
-->
260+
## 持久化 {#persistence}
261+
262+
Kubernetes 通过将序列化状态的对象写入到 {{< glossary_tooltip term_id="etcd" >}} 中完成存储操作。
263+
264+
<!--
265+
## API groups and versioning
266+
267+
To make it easier to eliminate fields or restructure resource representations,
268+
Kubernetes supports multiple API versions, each at a different API path, such
269+
as `/api/v1` or `/apis/rbac.authorization.k8s.io/v1alpha1`.
270+
271+
Versioning is done at the API level rather than at the resource or field level
272+
to ensure that the API presents a clear, consistent view of system resources
273+
and behavior, and to enable controlling access to end-of-life and/or
274+
experimental APIs.
275+
-->
276+
## API 组和版本控制 {#api-groups-and-versioning}
277+
278+
为了更容易消除字段或重组资源的呈现方式,Kubernetes 支持多个 API 版本,每个版本位于不同的 API 路径,
279+
例如 `/api/v1``/apis/rbac.authorization.k8s.io/v1alpha1`
280+
281+
版本控制是在 API 级别而不是在资源或字段级别完成的,以确保 API 呈现出清晰、一致的系统资源和行为视图,
282+
并能够控制对生命结束和/或实验性 API 的访问。
283+
284+
<!--
285+
To make it easier to evolve and to extend its API, Kubernetes implements
286+
[API groups](/docs/reference/using-api/#api-groups) that can be
287+
[enabled or disabled](/docs/reference/using-api/#enabling-or-disabling).
288+
289+
API resources are distinguished by their API group, resource type, namespace
290+
(for namespaced resources), and name. The API server handles the conversion between
291+
API versions transparently: all the different versions are actually representations
292+
of the same persisted data. The API server may serve the same underlying data
293+
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
298+
using either the `v1beta1` or the `v1` API version.
299+
-->
300+
为了更容易演进和扩展其 API,Kubernetes 实现了 [API 组](/zh-cn/docs/reference/using-api/#api-groups)
301+
这些 API 组可以被[启用或禁用](/zh-cn/docs/reference/using-api/#enabling-or-disabling)
302+
303+
API 资源通过其 API 组、资源类型、名字空间(用于名字空间作用域的资源)和名称来区分。
304+
API 服务器透明地处理 API 版本之间的转换:所有不同的版本实际上都是相同持久化数据的呈现。
305+
API 服务器可以通过多个 API 版本提供相同的底层数据。
306+
307+
例如,假设针对相同的资源有两个 API 版本:`v1``v1beta1`
308+
如果你最初使用其 API 的 `v1beta1` 版本创建了一个对象,
309+
你稍后可以使用 `v1beta1``v1` API 版本来读取、更新或删除该对象。
310+
238311
<!--
239312
## API changes
240313
241314
Any system that is successful needs to grow and change as new use cases emerge or existing ones change.
242-
Therefore, Kubernetes has designed its features to allow the Kubernetes API to continuously change and grow.
315+
Therefore, Kubernetes has designed the Kubernetes API to continuously change and grow.
243316
The Kubernetes project aims to _not_ break compatibility with existing clients, and to maintain that
244317
compatibility for a length of time so that other projects have an opportunity to adapt.
245318
-->
246319
## API 变更 {#api-changes}
247320

248321
任何成功的系统都要随着新的使用案例的出现和现有案例的变化来成长和变化。
249-
为此,Kubernetes 的功能特性设计考虑了让 Kubernetes API 能够持续变更和成长的因素
250-
Kubernetes 项目的目标是 _不要_ 引发现有客户端的兼容性问题,并在一定的时期内
251-
维持这种兼容性,以便其他项目有机会作出适应性变更。
322+
为此,Kubernetes 已设计了 Kubernetes API 来持续变更和成长
323+
Kubernetes 项目的目标是 **不要** 给现有客户端带来兼容性问题,并在一定的时期内维持这种兼容性,
324+
以便其他项目有机会作出适应性变更。
252325

253326
<!--
254327
In general, new API resources and new resource fields can be added often and frequently.
@@ -277,7 +350,7 @@ Although Kubernetes also aims to maintain compatibility for _alpha_ APIs version
277350
circumstances this is not possible. If you use any alpha API versions, check the release notes
278351
for Kubernetes when upgrading your cluster, in case the API did change.
279352
-->
280-
尽管 Kubernetes 也努力为 Alpha API 版本维护兼容性,在有些场合兼容性是无法做到的。
353+
尽管 Kubernetes 也努力为 **Alpha** API 版本维护兼容性,在有些场合兼容性是无法做到的。
281354
如果你使用了任何 Alpha API 版本,需要在升级集群时查看 Kubernetes 发布说明,
282355
以防 API 的确发生变更。
283356
{{< /note >}}
@@ -304,11 +377,10 @@ The Kubernetes API can be extended in one of two ways:
304377
1. You can also extend the Kubernetes API by implementing an
305378
[aggregation layer](/docs/concepts/extend-kubernetes/api-extension/apiserver-aggregation/).
306379
-->
307-
1. 你可以使用[自定义资源](/zh-cn/docs/concepts/extend-kubernetes/api-extension/custom-resources/)
308-
来以声明式方式定义 API 服务器如何提供你所选择的资源 API。
309-
1. 你也可以选择实现自己的
310-
[聚合层](/zh-cn/docs/concepts/extend-kubernetes/api-extension/apiserver-aggregation/)
311-
来扩展 Kubernetes API。
380+
1. 你可以使用[自定义资源](/zh-cn/docs/concepts/extend-kubernetes/api-extension/custom-resources/)来以声明式方式定义
381+
API 服务器如何提供你所选择的资源 API。
382+
1. 你也可以选择实现自己的[聚合层](/zh-cn/docs/concepts/extend-kubernetes/api-extension/apiserver-aggregation/)来扩展
383+
Kubernetes API。
312384

313385
## {{% heading "whatsnext" %}}
314386

0 commit comments

Comments
 (0)