Skip to content

Commit fdf9201

Browse files
authored
Merge pull request #36353 from yanrongshi/zh-cn]Sync-1.25-api-extension/custom-resources.md
[zh-cn]Sync custom-resources.md
2 parents a1fd581 + f46f180 commit fdf9201

File tree

1 file changed

+27
-31
lines changed

1 file changed

+27
-31
lines changed

content/zh-cn/docs/concepts/extend-kubernetes/api-extension/custom-resources.md

Lines changed: 27 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ weight: 10
1919
resource to your Kubernetes cluster and when to use a standalone service. It describes the two
2020
methods for adding custom resources and how to choose between them.
2121
-->
22-
*定制资源(Custom Resource)* 是对 Kubernetes API 的扩展。
22+
**定制资源(Custom Resource)** 是对 Kubernetes API 的扩展。
2323
本页讨论何时向 Kubernetes 集群添加定制资源,何时使用独立的服务。
2424
本页描述添加定制资源的两种方法以及怎样在二者之间做出抉择。
2525

@@ -36,12 +36,11 @@ collection of Pod objects.
3636
-->
3737
## 定制资源
3838

39-
*资源(Resource)*
39+
**资源(Resource)**
4040
[Kubernetes API](/zh-cn/docs/concepts/overview/kubernetes-api/) 中的一个端点,
4141
其中存储的是某个类别的
42-
[API 对象](/zh-cn/docs/concepts/overview/working-with-objects/kubernetes-objects/)
43-
的一个集合。
44-
例如内置的 *pods* 资源包含一组 Pod 对象。
42+
[API 对象](/zh-cn/docs/concepts/overview/working-with-objects/kubernetes-objects/)的一个集合。
43+
例如内置的 **Pod** 资源包含一组 Pod 对象。
4544

4645
<!--
4746
A *custom resource* is an extension of the Kubernetes API that is not necessarily available in a default
@@ -54,15 +53,14 @@ Once a custom resource is installed, users can create and access its objects usi
5453
[kubectl](/docs/reference/kubectl/), just as they do for built-in resources like
5554
*Pods*.
5655
-->
57-
*定制资源(Custom Resource)* 是对 Kubernetes API 的扩展,不一定在默认的
58-
Kubernetes 安装中就可用。定制资源所代表的是对特定 Kubernetes 安装的一种定制。
59-
不过,很多 Kubernetes 核心功能现在都用定制资源来实现,这使得 Kubernetes
60-
更加模块化。
56+
**定制资源(Custom Resource)** 是对 Kubernetes API 的扩展,不一定在默认的
57+
Kubernetes 安装中就可用。
58+
定制资源所代表的是对特定 Kubernetes 安装的一种定制。
59+
不过,很多 Kubernetes 核心功能现在都用定制资源来实现,这使得 Kubernetes 更加模块化。
6160

62-
定制资源可以通过动态注册的方式在运行中的集群内或出现或消失,集群管理员可以独立于集群
63-
更新定制资源。一旦某定制资源被安装,用户可以使用
64-
[kubectl](/docs/reference/kubectl/)
65-
来创建和访问其中的对象,就像他们为 *pods* 这种内置资源所做的一样。
61+
定制资源可以通过动态注册的方式在运行中的集群内或出现或消失,集群管理员可以独立于集群更新定制资源。
62+
一旦某定制资源被安装,用户可以使用 [kubectl](/zh-cn/docs/reference/kubectl/) 来创建和访问其中的对象,
63+
就像他们为 **Pod** 这种内置资源所做的一样。
6664

6765
<!--
6866
## Custom controllers
@@ -74,20 +72,19 @@ provide a true _declarative API_.
7472
## 定制控制器 {#custom-controllers}
7573

7674
就定制资源本身而言,它只能用来存取结构化的数据。
77-
当你将定制资源与 *定制控制器(Custom Controller)* 相结合时,定制资源就能够
78-
提供真正的 _声明式 API(Declarative API)_
75+
当你将定制资源与**定制控制器(Custom Controller)** 结合时,
76+
定制资源就能够提供真正的**声明式 API(Declarative API)**
7977

8078
<!--
81-
A [declarative API](/docs/concepts/overview/kubernetes-api/)
82-
allows you to _declare_ or specify the desired state of your resource and tries to
83-
keep the current state of Kubernetes objects in sync with the desired state.
84-
The controller interprets the structured data as a record of the user's
85-
desired state, and continually maintains this state.
79+
The Kubernetes [declarative API](/docs/concepts/overview/kubernetes-api/)
80+
enforces a separation of responsibilities. You declare the desired state of
81+
your resource. The Kubernetes controller keeps the current state of Kubernetes
82+
objects in sync with your declared desired state. This is in contrast to an
83+
imperative API, where you *instruct* a server what to do.
8684
-->
87-
使用[声明式 API](/zh-cn/docs/concepts/overview/kubernetes-api/)
88-
你可以 _声明_ 或者设定你的资源的期望状态,并尝试让 Kubernetes 对象的当前状态
89-
同步到其期望状态。控制器负责将结构化的数据解释为用户所期望状态的记录,并
90-
持续地维护该状态。
85+
Kubernetes [声明式 API](/zh-cn/docs/concepts/overview/kubernetes-api/) 强制对职权做了一次分离操作。
86+
你声明所用资源的期望状态,而 Kubernetes 控制器使 Kubernetes 对象的当前状态与你所声明的期望状态保持同步。
87+
声明式 API 的这种机制与命令式 API(你**指示**服务器要做什么,服务器就去做什么)形成鲜明对比。
9188

9289
<!--
9390
You can deploy and update a custom controller on a running cluster, independently
@@ -99,9 +96,8 @@ for specific applications into an extension of the Kubernetes API.
9996
-->
10097
你可以在一个运行中的集群上部署和更新定制控制器,这类操作与集群的生命周期无关。
10198
定制控制器可以用于任何类别的资源,不过它们与定制资源结合起来时最为有效。
102-
[Operator 模式](/zh-cn/docs/concepts/extend-kubernetes/operator/)就是将定制资源
103-
与定制控制器相结合的。你可以使用定制控制器来将特定于某应用的领域知识组织
104-
起来,以编码的形式构造对 Kubernetes API 的扩展。
99+
[Operator 模式](/zh-cn/docs/concepts/extend-kubernetes/operator/)就是将定制资源与定制控制器相结合的。
100+
你可以使用定制控制器来将特定于某应用的领域知识组织起来,以编码的形式构造对 Kubernetes API 的扩展。
105101

106102
<!--
107103
## Should I add a custom resource to my Kubernetes Cluster?
@@ -364,14 +360,14 @@ CRD 比聚合 API 更容易创建
364360
<!--
365361
| CRDs | Aggregated API |
366362
| --------------------------- | -------------- |
367-
| Do not require programming. Users can choose any language for a CRD controller. | Requires programming in Go and building binary and image. |
363+
| Do not require programming. Users can choose any language for a CRD controller. | Requires programming and building binary and image. |
368364
| No additional service to run; CRDs are handled by API server. | An additional service to create and that could fail. |
369365
| No ongoing support once the CRD is created. Any bug fixes are picked up as part of normal Kubernetes Master upgrades. | May need to periodically pickup bug fixes from upstream and rebuild and update the Aggregated API server. |
370366
| No need to handle multiple versions of your API; for example, when you control the client for this resource, you can upgrade it in sync with the API. | You need to handle multiple versions of your API; for example, when developing an extension to share with the world. |
371367
-->
372-
| CRDs | 聚合 API |
368+
| CRD | 聚合 API |
373369
| --------------------------- | -------------- |
374-
| 无需编程。用户可选择任何语言来实现 CRD 控制器。 | 需要使用 Go 来编程,并构建可执行文件和镜像。 |
370+
| 无需编程。用户可选择任何语言来实现 CRD 控制器。 | 需要编程,并构建可执行文件和镜像。 |
375371
| 无需额外运行服务;CRD 由 API 服务器处理。 | 需要额外创建服务,且该服务可能失效。 |
376372
| 一旦 CRD 被创建,不需要持续提供支持。Kubernetes 主控节点升级过程中自动会带入缺陷修复。 | 可能需要周期性地从上游提取缺陷修复并更新聚合 API 服务器。 |
377373
| 无需处理 API 的多个版本;例如,当你控制资源的客户端时,你可以更新它使之与 API 同步。 | 你需要处理 API 的多个版本;例如,在开发打算与很多人共享的扩展时。 |
@@ -400,7 +396,7 @@ Aggregated APIs offer more advanced API features and customization of other feat
400396
| Protocol Buffers | The new resource supports clients that want to use Protocol Buffers | No | Yes |
401397
| OpenAPI Schema | Is there an OpenAPI (swagger) schema for the types that can be dynamically fetched from the server? Is the user protected from misspelling field names by ensuring only allowed fields are set? Are types enforced (in other words, don't put an `int` in a `string` field?) | Yes, based on the [OpenAPI v3.0 validation](/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/#validation) schema (GA in 1.16). | Yes |
402398
-->
403-
| 特性 | 描述 | CRDs | 聚合 API |
399+
| 特性 | 描述 | CRD | 聚合 API |
404400
| ------- | ----------- | ---- | -------------- |
405401
| 合法性检查 | 帮助用户避免错误,允许你独立于客户端版本演化 API。这些特性对于由很多无法同时更新的客户端的场合。| 可以。大多数验证可以使用 [OpenAPI v3.0 合法性检查](/zh-cn/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/#validation) 来设定。其他合法性检查操作可以通过添加[合法性检查 Webhook](/zh-cn/docs/reference/access-authn-authz/admission-controllers/#validatingadmissionwebhook-alpha-in-1-8-beta-in-1-9)来实现。 | 可以,可执行任何合法性检查。|
406402
| 默认值设置 | 同上 | 可以。可通过 [OpenAPI v3.0 合法性检查](/zh-cn/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/#defaulting)`default` 关键词(自 1.17 正式发布)或[更改性(Mutating)Webhook](/zh-cn/docs/reference/access-authn-authz/admission-controllers/#mutatingadmissionwebhook)来实现(不过从 etcd 中读取老的对象时不会执行这些 Webhook)。 | 可以。 |

0 commit comments

Comments
 (0)