Skip to content

Commit 381209a

Browse files
authored
Merge pull request #36091 from windsonsea/operyhf
[zh-cn] updated extend-kubernetes/operator.md
2 parents 090fa92 + 7fa666f commit 381209a

File tree

1 file changed

+50
-54
lines changed
  • content/zh-cn/docs/concepts/extend-kubernetes

1 file changed

+50
-54
lines changed

content/zh-cn/docs/concepts/extend-kubernetes/operator.md

Lines changed: 50 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -18,30 +18,28 @@ Operators are software extensions to Kubernetes that make use of
1818
to manage applications and their components. Operators follow
1919
Kubernetes principles, notably the [control loop](/docs/concepts/architecture/controller).
2020
-->
21-
Operator 是 Kubernetes 的扩展软件,它利用
22-
[定制资源](/zh-cn/docs/concepts/extend-kubernetes/api-extension/custom-resources/)
23-
管理应用及其组件。
24-
Operator 遵循 Kubernetes 的理念,特别是在[控制器](/zh-cn/docs/concepts/architecture/controller)
25-
方面。
21+
Operator 是 Kubernetes 的扩展软件,
22+
它利用[定制资源](/zh-cn/docs/concepts/extend-kubernetes/api-extension/custom-resources/)管理应用及其组件。
23+
Operator 遵循 Kubernetes 的理念,特别是在[控制器](/zh-cn/docs/concepts/architecture/controller)方面。
2624

2725
<!-- body -->
2826

2927
<!--
3028
## Motivation
3129
32-
The Operator pattern aims to capture the key aim of a human operator who
30+
The _operator pattern_ aims to capture the key aim of a human operator who
3331
is managing a service or set of services. Human operators who look after
3432
specific applications and services have deep knowledge of how the system
3533
ought to behave, how to deploy it, and how to react if there are problems.
3634
3735
People who run workloads on Kubernetes often like to use automation to take
38-
care of repeatable tasks. The Operator pattern captures how you can write
36+
care of repeatable tasks. The operator pattern captures how you can write
3937
code to automate a task beyond what Kubernetes itself provides.
4038
-->
41-
## 初衷
39+
## 初衷 {#motivation}
4240

43-
Operator 模式旨在捕获(正在管理一个或一组服务的)运维人员的关键目标。
44-
负责特定应用和 service 的运维人员,在系统应该如何运行、如何部署以及出现问题时如何处理等方面有深入的了解
41+
**Operator 模式** 旨在记述(正在管理一个或一组服务的)运维人员的关键目标。
42+
这些运维人员负责一些特定的应用和 Service,他们需要清楚地知道系统应该如何运行、如何部署以及出现问题时如何处理
4543

4644
在 Kubernetes 上运行工作负载的人们都喜欢通过自动化来处理重复的任务。
4745
Operator 模式会封装你编写的(Kubernetes 本身提供功能以外的)任务自动化代码。
@@ -58,20 +56,19 @@ Kubernetes' {{< glossary_tooltip text="operator pattern" term_id="operator-patte
5856
Operators are clients of the Kubernetes API that act as controllers for
5957
a [Custom Resource](/docs/concepts/extend-kubernetes/api-extension/custom-resources/).
6058
-->
61-
## Kubernetes 上的 Operator
59+
## Kubernetes 上的 Operator {#operators-in-kubernetes}
6260

6361
Kubernetes 为自动化而生。无需任何修改,你即可以从 Kubernetes 核心中获得许多内置的自动化功能。
64-
你可以使用 Kubernetes 自动化部署和运行工作负载, *甚至* 可以自动化 Kubernetes 自身。
62+
你可以使用 Kubernetes 自动化部署和运行工作负载, **甚至** 可以自动化 Kubernetes 自身。
6563

6664
Kubernetes 的 {{< glossary_tooltip text="Operator 模式" term_id="operator-pattern" >}}概念允许你在不修改
67-
Kubernetes 自身代码的情况下,通过为一个或多个自定义资源关联{{< glossary_tooltip text="控制器" term_id="controller" >}}
68-
来扩展集群的能力。
69-
Operator 是 Kubernetes API 的客户端,充当
70-
[自定义资源](/zh-cn/docs/concepts/extend-kubernetes/api-extension/custom-resources/)
71-
的控制器。
65+
Kubernetes 自身代码的情况下,
66+
通过为一个或多个自定义资源关联{{< glossary_tooltip text="控制器" term_id="controller" >}}来扩展集群的能力。
67+
Operator 是 Kubernetes API 的客户端,
68+
充当[自定义资源](/zh-cn/docs/concepts/extend-kubernetes/api-extension/custom-resources/)的控制器。
7269

7370
<!--
74-
## An example Operator {#example}
71+
## An example operator {#example}
7572
7673
Some of the things that you can use an operator to automate include:
7774
@@ -97,26 +94,26 @@ Some of the things that you can use an operator to automate include:
9794
* 在没有内部成员选举程序的情况下,为分布式应用选择首领角色
9895

9996
<!--
100-
What might an Operator look like in more detail? Here's an example:
97+
What might an operator look like in more detail? Here's an example:
10198
10299
1. A custom resource named SampleDB, that you can configure into the cluster.
103100
2. A Deployment that makes sure a Pod is running that contains the
104101
controller part of the operator.
105102
3. A container image of the operator code.
106103
4. Controller code that queries the control plane to find out what SampleDB
107104
resources are configured.
108-
5. The core of the Operator is code to tell the API server how to make
105+
5. The core of the operator is code to tell the API server how to make
109106
reality match the configured resources.
110107
* If you add a new SampleDB, the operator sets up PersistentVolumeClaims
111108
to provide durable database storage, a StatefulSet to run SampleDB and
112109
a Job to handle initial configuration.
113-
* If you delete it, the Operator takes a snapshot, then makes sure that
110+
* If you delete it, the operator takes a snapshot, then makes sure that
114111
the StatefulSet and Volumes are also removed.
115112
6. The operator also manages regular database backups. For each SampleDB
116113
resource, the operator determines when to create a Pod that can connect
117114
to the database and take backups. These Pods would rely on a ConfigMap
118115
and / or a Secret that has database connection details and credentials.
119-
7. Because the Operator aims to provide robust automation for the resource
116+
7. Because the operator aims to provide robust automation for the resource
120117
it manages, there would be additional supporting code. For this example,
121118
code checks to see if the database is running an old version and, if so,
122119
creates Job objects that upgrade it for you.
@@ -129,40 +126,38 @@ What might an Operator look like in more detail? Here's an example:
129126
3. Operator 代码的容器镜像。
130127
4. 控制器代码,负责查询控制平面以找出已配置的 SampleDB 资源。
131128
5. Operator 的核心是告诉 API 服务器,如何使现实与代码里配置的资源匹配。
132-
* 如果添加新的 SampleDB,Operator 将设置 PersistentVolumeClaims 以提供
133-
持久化的数据库存储,设置 StatefulSet 以运行 SampleDB,并设置 Job
134-
来处理初始配置。
129+
* 如果添加新的 SampleDB,Operator 将设置 PersistentVolumeClaims 以提供持久化的数据库存储,
130+
设置 StatefulSet 以运行 SampleDB,并设置 Job 来处理初始配置。
135131
* 如果你删除它,Operator 将建立快照,然后确保 StatefulSet 和 Volume 已被删除。
136132
6. Operator 也可以管理常规数据库的备份。对于每个 SampleDB 资源,Operator
137133
会确定何时创建(可以连接到数据库并进行备份的)Pod。这些 Pod 将依赖于
138134
ConfigMap 和/或具有数据库连接详细信息和凭据的 Secret。
139-
7. 由于 Operator 旨在为其管理的资源提供强大的自动化功能,因此它还需要一些
140-
额外的支持性代码。在这个示例中,代码将检查数据库是否正运行在旧版本上,
135+
7. 由于 Operator 旨在为其管理的资源提供强大的自动化功能,因此它还需要一些额外的支持性代码。
136+
在这个示例中,代码将检查数据库是否正运行在旧版本上,
141137
如果是,则创建 Job 对象为你升级数据库。
142138

143139
<!--
144-
## Deploying Operators
140+
## Deploying operators
145141
146-
The most common way to deploy an Operator is to add the
142+
The most common way to deploy an operator is to add the
147143
Custom Resource Definition and its associated Controller to your cluster.
148144
The Controller will normally run outside of the
149145
{{< glossary_tooltip text="control plane" term_id="control-plane" >}},
150146
much as you would run any containerized application.
151147
For example, you can run the controller in your cluster as a Deployment.
152148
-->
153-
## 部署 Operator
149+
## 部署 Operator {#deploying-operators}
154150

155151
部署 Operator 最常见的方法是将自定义资源及其关联的控制器添加到你的集群中。
156-
跟运行容器化应用一样,控制器通常会运行在
157-
{{< glossary_tooltip text="控制平面" term_id="control-plane" >}} 之外。
152+
跟运行容器化应用一样,控制器通常会运行在{{< glossary_tooltip text="控制平面" term_id="control-plane" >}}之外。
158153
例如,你可以在集群中将控制器作为 Deployment 运行。
159154

160155
<!--
161-
## Using an Operator {#using-operators}
156+
## Using an operator {#using-operators}
162157
163-
Once you have an Operator deployed, you'd use it by adding, modifying or
164-
deleting the kind of resource that the Operator uses. Following the above
165-
example, you would set up a Deployment for the Operator itself, and then:
158+
Once you have an operator deployed, you'd use it by adding, modifying or
159+
deleting the kind of resource that the operator uses. Following the above
160+
example, you would set up a Deployment for the operator itself, and then:
166161
167162
```shell
168163
kubectl get SampleDB # find configured databases
@@ -182,35 +177,39 @@ kubectl edit SampleDB/example-database # 手动修改某些配置
182177
```
183178

184179
<!--
185-
&hellip;and that's it! The Operator will take care of applying the changes as well as keeping the existing service in good shape.
180+
&hellip;and that's it! The operator will take care of applying the changes
181+
as well as keeping the existing service in good shape.
186182
-->
187183
可以了!Operator 会负责应用所作的更改并保持现有服务处于良好的状态。
188184

189185
<!--
190-
## Writing your own Operator {#writing-operator}
186+
## Writing your own operator {#writing-operator}
191187
-->
192-
193188
## 编写你自己的 Operator {#writing-operator}
194189

195190
<!--
196-
If there isn't an Operator in the ecosystem that implements the behavior you
197-
want, you can code your own.
191+
If there isn't an operator in the ecosystem that implements the behavior you
192+
want, you can code your own.
198193
199-
You also implement an Operator (that is, a Controller) using any language / runtime
194+
You also implement an operator (that is, a Controller) using any language / runtime
200195
that can act as a [client for the Kubernetes API](/docs/reference/using-api/client-libraries/).
201196
-->
202197

203198
如果生态系统中没可以实现你目标的 Operator,你可以自己编写代码。
204199

205-
你还可以使用任何支持 [Kubernetes API 客户端](/zh-cn/docs/reference/using-api/client-libraries/)
206-
的语言或运行时来实现 Operator(即控制器)。
200+
你还可以使用任何支持
201+
[Kubernetes API 客户端](/zh-cn/docs/reference/using-api/client-libraries/)的语言或运行时来实现
202+
Operator(即控制器)。
207203

208204
<!--
209205
Following are a few libraries and tools you can use to write your own cloud native
210-
Operator.
206+
operator.
207+
-->
208+
以下是一些库和工具,你可用于编写自己的云原生 Operator。
211209

212210
{{% thirdparty-content %}}
213211

212+
<!--
214213
* [Charmed Operator Framework](https://juju.is/)
215214
* [Java Operator SDK](https://github.com/java-operator-sdk/java-operator-sdk)
216215
* [Kopf](https://github.com/nolar/kopf) (Kubernetes Operator Pythonic Framework)
@@ -223,17 +222,14 @@ you implement yourself
223222
* [Operator Framework](https://operatorframework.io)
224223
* [shell-operator](https://github.com/flant/shell-operator)
225224
-->
226-
以下是一些库和工具,你可用于编写自己的云原生 Operator。
227-
228-
{{% thirdparty-content %}}
229225

230226
* [Charmed Operator Framework](https://juju.is/)
231227
* [Java Operator SDK](https://github.com/java-operator-sdk/java-operator-sdk)
232228
* [Kopf](https://github.com/nolar/kopf) (Kubernetes Operator Pythonic Framework)
233229
* [kube-rs](https://kube.rs/) (Rust)
234230
* [kubebuilder](https://book.kubebuilder.io/)
235231
* [KubeOps](https://buehler.github.io/dotnet-operator-sdk/) (.NET operator SDK)
236-
* [KUDO](https://kudo.dev/) (Kubernetes 通用声明式 Operator)
232+
* [KUDO](https://kudo.dev/)Kubernetes 通用声明式 Operator
237233
* [Metacontroller](https://metacontroller.github.io/metacontroller/intro.html),可与 Webhooks 结合使用,以实现自己的功能。
238234
* [Operator Framework](https://operatorframework.io)
239235
* [shell-operator](https://github.com/flant/shell-operator)
@@ -245,14 +241,14 @@ you implement yourself
245241
* Learn more about [Custom Resources](/docs/concepts/extend-kubernetes/api-extension/custom-resources/)
246242
* Find ready-made operators on [OperatorHub.io](https://operatorhub.io/) to suit your use case
247243
* [Publish](https://operatorhub.io/) your operator for other people to use
248-
* Read [CoreOS' original article](https://web.archive.org/web/20170129131616/https://coreos.com/blog/introducing-operators.html) that introduced the Operator pattern (this is an archived version of the original article).
249-
* Read an [article](https://cloud.google.com/blog/products/containers-kubernetes/best-practices-for-building-kubernetes-operators-and-stateful-apps) from Google Cloud about best practices for building Operators
244+
* Read [CoreOS' original article](https://web.archive.org/web/20170129131616/https://coreos.com/blog/introducing-operators.html) that introduced the operator pattern (this is an archived version of the original article).
245+
* Read an [article](https://cloud.google.com/blog/products/containers-kubernetes/best-practices-for-building-kubernetes-operators-and-stateful-apps) from Google Cloud about best practices for building operators
250246
-->
251247

252248
* 阅读 {{< glossary_tooltip text="CNCF" term_id="cncf" >}} [Operator 白皮书](https://github.com/cncf/tag-app-delivery/blob/eece8f7307f2970f46f100f51932db106db46968/operator-wg/whitepaper/Operator-WhitePaper_v1-0.md)
253-
* 详细了解 [定制资源](/zh-cn/docs/concepts/extend-kubernetes/api-extension/custom-resources/)
249+
* 详细了解[定制资源](/zh-cn/docs/concepts/extend-kubernetes/api-extension/custom-resources/)
254250
*[OperatorHub.io](https://operatorhub.io/) 上找到现成的、适合你的 Operator
255251
* [发布](https://operatorhub.io/)你的 Operator,让别人也可以使用
256252
* 阅读 [CoreOS 原始文章](https://web.archive.org/web/20170129131616/https://coreos.com/blog/introducing-operators.html),它介绍了 Operator 模式(这是一个存档版本的原始文章)。
257-
* 阅读这篇来自谷歌云的关于构建 Operator 最佳实践的
258-
[文章](https://cloud.google.com/blog/products/containers-kubernetes/best-practices-for-building-kubernetes-operators-and-stateful-apps)
253+
* 阅读这篇来自谷歌云的关于构建 Operator
254+
最佳实践的[文章](https://cloud.google.com/blog/products/containers-kubernetes/best-practices-for-building-kubernetes-operators-and-stateful-apps)

0 commit comments

Comments
 (0)