@@ -18,30 +18,28 @@ Operators are software extensions to Kubernetes that make use of
18
18
to manage applications and their components. Operators follow
19
19
Kubernetes principles, notably the [control loop](/docs/concepts/architecture/controller).
20
20
-->
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 ) 方面。
26
24
27
25
<!-- body -->
28
26
29
27
<!--
30
28
## Motivation
31
29
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
33
31
is managing a service or set of services. Human operators who look after
34
32
specific applications and services have deep knowledge of how the system
35
33
ought to behave, how to deploy it, and how to react if there are problems.
36
34
37
35
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
39
37
code to automate a task beyond what Kubernetes itself provides.
40
38
-->
41
- ## 初衷
39
+ ## 初衷 {#motivation}
42
40
43
- Operator 模式旨在捕获 (正在管理一个或一组服务的)运维人员的关键目标。
44
- 负责特定应用和 service 的运维人员,在系统应该如何运行、如何部署以及出现问题时如何处理等方面有深入的了解 。
41
+ ** Operator 模式 ** 旨在记述 (正在管理一个或一组服务的)运维人员的关键目标。
42
+ 这些运维人员负责一些特定的应用和 Service,他们需要清楚地知道系统应该如何运行、如何部署以及出现问题时如何处理 。
45
43
46
44
在 Kubernetes 上运行工作负载的人们都喜欢通过自动化来处理重复的任务。
47
45
Operator 模式会封装你编写的(Kubernetes 本身提供功能以外的)任务自动化代码。
@@ -58,20 +56,19 @@ Kubernetes' {{< glossary_tooltip text="operator pattern" term_id="operator-patte
58
56
Operators are clients of the Kubernetes API that act as controllers for
59
57
a [Custom Resource](/docs/concepts/extend-kubernetes/api-extension/custom-resources/).
60
58
-->
61
- ## Kubernetes 上的 Operator
59
+ ## Kubernetes 上的 Operator {#operators-in-kubernetes}
62
60
63
61
Kubernetes 为自动化而生。无需任何修改,你即可以从 Kubernetes 核心中获得许多内置的自动化功能。
64
- 你可以使用 Kubernetes 自动化部署和运行工作负载, * 甚至 * 可以自动化 Kubernetes 自身。
62
+ 你可以使用 Kubernetes 自动化部署和运行工作负载, ** 甚至 * * 可以自动化 Kubernetes 自身。
65
63
66
64
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/ ) 的控制器。
72
69
73
70
<!--
74
- ## An example Operator {#example}
71
+ ## An example operator {#example}
75
72
76
73
Some of the things that you can use an operator to automate include:
77
74
@@ -97,26 +94,26 @@ Some of the things that you can use an operator to automate include:
97
94
* 在没有内部成员选举程序的情况下,为分布式应用选择首领角色
98
95
99
96
<!--
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:
101
98
102
99
1. A custom resource named SampleDB, that you can configure into the cluster.
103
100
2. A Deployment that makes sure a Pod is running that contains the
104
101
controller part of the operator.
105
102
3. A container image of the operator code.
106
103
4. Controller code that queries the control plane to find out what SampleDB
107
104
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
109
106
reality match the configured resources.
110
107
* If you add a new SampleDB, the operator sets up PersistentVolumeClaims
111
108
to provide durable database storage, a StatefulSet to run SampleDB and
112
109
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
114
111
the StatefulSet and Volumes are also removed.
115
112
6. The operator also manages regular database backups. For each SampleDB
116
113
resource, the operator determines when to create a Pod that can connect
117
114
to the database and take backups. These Pods would rely on a ConfigMap
118
115
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
120
117
it manages, there would be additional supporting code. For this example,
121
118
code checks to see if the database is running an old version and, if so,
122
119
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:
129
126
3 . Operator 代码的容器镜像。
130
127
4 . 控制器代码,负责查询控制平面以找出已配置的 SampleDB 资源。
131
128
5 . Operator 的核心是告诉 API 服务器,如何使现实与代码里配置的资源匹配。
132
- * 如果添加新的 SampleDB,Operator 将设置 PersistentVolumeClaims 以提供
133
- 持久化的数据库存储,设置 StatefulSet 以运行 SampleDB,并设置 Job
134
- 来处理初始配置。
129
+ * 如果添加新的 SampleDB,Operator 将设置 PersistentVolumeClaims 以提供持久化的数据库存储,
130
+ 设置 StatefulSet 以运行 SampleDB,并设置 Job 来处理初始配置。
135
131
* 如果你删除它,Operator 将建立快照,然后确保 StatefulSet 和 Volume 已被删除。
136
132
6 . Operator 也可以管理常规数据库的备份。对于每个 SampleDB 资源,Operator
137
133
会确定何时创建(可以连接到数据库并进行备份的)Pod。这些 Pod 将依赖于
138
134
ConfigMap 和/或具有数据库连接详细信息和凭据的 Secret。
139
- 7 . 由于 Operator 旨在为其管理的资源提供强大的自动化功能,因此它还需要一些
140
- 额外的支持性代码。 在这个示例中,代码将检查数据库是否正运行在旧版本上,
135
+ 7 . 由于 Operator 旨在为其管理的资源提供强大的自动化功能,因此它还需要一些额外的支持性代码。
136
+ 在这个示例中,代码将检查数据库是否正运行在旧版本上,
141
137
如果是,则创建 Job 对象为你升级数据库。
142
138
143
139
<!--
144
- ## Deploying Operators
140
+ ## Deploying operators
145
141
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
147
143
Custom Resource Definition and its associated Controller to your cluster.
148
144
The Controller will normally run outside of the
149
145
{{< glossary_tooltip text="control plane" term_id="control-plane" >}},
150
146
much as you would run any containerized application.
151
147
For example, you can run the controller in your cluster as a Deployment.
152
148
-->
153
- ## 部署 Operator
149
+ ## 部署 Operator {#deploying-operators}
154
150
155
151
部署 Operator 最常见的方法是将自定义资源及其关联的控制器添加到你的集群中。
156
- 跟运行容器化应用一样,控制器通常会运行在
157
- {{< glossary_tooltip text="控制平面" term_id="control-plane" >}} 之外。
152
+ 跟运行容器化应用一样,控制器通常会运行在{{< glossary_tooltip text="控制平面" term_id="control-plane" >}}之外。
158
153
例如,你可以在集群中将控制器作为 Deployment 运行。
159
154
160
155
<!--
161
- ## Using an Operator {#using-operators}
156
+ ## Using an operator {#using-operators}
162
157
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:
166
161
167
162
```shell
168
163
kubectl get SampleDB # find configured databases
@@ -182,35 +177,39 @@ kubectl edit SampleDB/example-database # 手动修改某些配置
182
177
```
183
178
184
179
<!--
185
- …and that's it! The Operator will take care of applying the changes as well as keeping the existing service in good shape.
180
+ …and that's it! The operator will take care of applying the changes
181
+ as well as keeping the existing service in good shape.
186
182
-->
187
183
可以了!Operator 会负责应用所作的更改并保持现有服务处于良好的状态。
188
184
189
185
<!--
190
- ## Writing your own Operator {#writing-operator}
186
+ ## Writing your own operator {#writing-operator}
191
187
-->
192
-
193
188
## 编写你自己的 Operator {#writing-operator}
194
189
195
190
<!--
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.
198
193
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
200
195
that can act as a [client for the Kubernetes API](/docs/reference/using-api/client-libraries/).
201
196
-->
202
197
203
198
如果生态系统中没可以实现你目标的 Operator,你可以自己编写代码。
204
199
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(即控制器)。
207
203
208
204
<!--
209
205
Following are a few libraries and tools you can use to write your own cloud native
210
- Operator.
206
+ operator.
207
+ -->
208
+ 以下是一些库和工具,你可用于编写自己的云原生 Operator。
211
209
212
210
{{% thirdparty-content %}}
213
211
212
+ <!--
214
213
* [Charmed Operator Framework](https://juju.is/)
215
214
* [Java Operator SDK](https://github.com/java-operator-sdk/java-operator-sdk)
216
215
* [Kopf](https://github.com/nolar/kopf) (Kubernetes Operator Pythonic Framework)
@@ -223,17 +222,14 @@ you implement yourself
223
222
* [Operator Framework](https://operatorframework.io)
224
223
* [shell-operator](https://github.com/flant/shell-operator)
225
224
-->
226
- 以下是一些库和工具,你可用于编写自己的云原生 Operator。
227
-
228
- {{% thirdparty-content %}}
229
225
230
226
* [ Charmed Operator Framework] ( https://juju.is/ )
231
227
* [ Java Operator SDK] ( https://github.com/java-operator-sdk/java-operator-sdk )
232
228
* [ Kopf] ( https://github.com/nolar/kopf ) (Kubernetes Operator Pythonic Framework)
233
229
* [ kube-rs] ( https://kube.rs/ ) (Rust)
234
230
* [ kubebuilder] ( https://book.kubebuilder.io/ )
235
231
* [ 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)
237
233
* [ Metacontroller] ( https://metacontroller.github.io/metacontroller/intro.html ) ,可与 Webhooks 结合使用,以实现自己的功能。
238
234
* [ Operator Framework] ( https://operatorframework.io )
239
235
* [ shell-operator] ( https://github.com/flant/shell-operator )
@@ -245,14 +241,14 @@ you implement yourself
245
241
* Learn more about [Custom Resources](/docs/concepts/extend-kubernetes/api-extension/custom-resources/)
246
242
* Find ready-made operators on [OperatorHub.io](https://operatorhub.io/) to suit your use case
247
243
* [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
250
246
-->
251
247
252
248
* 阅读 {{< 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/ )
254
250
* 在 [ OperatorHub.io] ( https://operatorhub.io/ ) 上找到现成的、适合你的 Operator
255
251
* [ 发布] ( https://operatorhub.io/ ) 你的 Operator,让别人也可以使用
256
252
* 阅读 [ 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