Skip to content

Commit dc89e82

Browse files
committed
[zh]Resync Extend Kubernetes files
1 parent 3316bae commit dc89e82

File tree

5 files changed

+111
-76
lines changed

5 files changed

+111
-76
lines changed

content/zh/docs/tasks/extend-kubectl/kubectl-plugins.md

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ content_type: task
1616
<!-- overview -->
1717
<!--
1818
This guide demonstrates how to install and write extensions for [kubectl](/docs/reference/kubectl/kubectl/). By thinking of core `kubectl` commands as essential building blocks for interacting with a Kubernetes cluster, a cluster administrator can think
19-
of plugins as a means of utilizing these building blocks to create more complex behavior. Plugins extend `kubectl` with new sub-commands, allowing for new and custom features not included in the main distribution of `kubectl`.
19+
of plugins as a means of utilizing these building blocks to create more complex behavior. Plugins extend `kubectl` with new sub-commands, allowing for new and custom features not included in the main distribution of `kubectl`.
2020
-->
2121
本指南演示了如何为 [kubectl](/zh/docs/reference/kubectl/kubectl/) 安装和编写扩展。
2222
通过将核心 `kubectl` 命令看作与 Kubernetes 集群交互的基本构建块,
@@ -35,12 +35,12 @@ You need to have a working `kubectl` binary installed.
3535
<!--
3636
## Installing kubectl plugins
3737
38-
A plugin is nothing more than a standalone executable file, whose name begins with `kubectl-`. To install a plugin, simply move this executable file to anywhere on your PATH.
38+
A plugin is a standalone executable file, whose name begins with `kubectl-`. To install a plugin, move its executable file to anywhere on your `PATH`.
3939
-->
4040
## 安装 kubectl 插件
4141

42-
插件只不过是一个独立的可执行文件,名称以 `kubectl-` 开头。
43-
要安装插件,只需将此可执行文件移动到 PATH 中的任何位置。
42+
插件是一个独立的可执行文件,名称以 `kubectl-` 开头。
43+
要安装插件,将其可执行文件移动到 `PATH` 中的任何位置。
4444

4545
<!--
4646
You can also discover and install kubectl plugins available in the open source
@@ -112,14 +112,14 @@ You can write a plugin in any programming language or script that allows you to
112112
<!--
113113
There is no plugin installation or pre-loading required. Plugin executables receive
114114
the inherited environment from the `kubectl` binary.
115-
A plugin determines which command path it wishes to implement based on its name. For
116-
example, a plugin wanting to provide a new command `kubectl foo`, would simply be named
117-
`kubectl-foo`, and live somewhere in the user's PATH.
115+
A plugin determines which command path it wishes to implement based on its name.
116+
For example, a plugin named `kubectl-foo` provides a command `kubectl foo`. You must
117+
install the plugin executable somewhere in your `PATH`.
118118
-->
119119
不需要安装插件或预加载,插件可执行程序从 `kubectl` 二进制文件接收继承的环境,
120120
插件根据其名称确定它希望实现的命令路径。
121-
例如,一个插件想要提供一个新的命令 `kubectl foo`,它将被简单地命名为 `kubectl-foo`
122-
并且位于用户 PATH 的某个位置
121+
例如,名为 `kubectl-foo` 的插件提供了命令 `kubectl foo`
122+
必须将插件的可执行文件安装在 `PATH` 中的某个位置
123123

124124
<!--
125125
### Example plugin
@@ -152,11 +152,11 @@ echo "I am a plugin named kubectl-foo"
152152
### 使用插件
153153

154154
<!--
155-
To use the above plugin, simply make it executable:
155+
To use a plugin, make the plugin executable:
156156
-->
157-
要使用上面的插件,只需使其可执行
157+
要使用某插件,先要使其可执行
158158

159-
```
159+
```shell
160160
sudo chmod +x ./kubectl-foo
161161
```
162162

@@ -165,7 +165,7 @@ and place it anywhere in your PATH:
165165
-->
166166
并将它放在你的 PATH 中的任何地方:
167167

168-
```
168+
```shell
169169
sudo mv ./kubectl-foo /usr/local/bin
170170
```
171171

@@ -174,9 +174,10 @@ You may now invoke your plugin as a `kubectl` command:
174174
-->
175175
你现在可以调用你的插件作为 `kubectl` 命令:
176176

177-
```
177+
```shell
178178
kubectl foo
179179
```
180+
180181
```
181182
I am a plugin named kubectl-foo
182183
```
@@ -186,9 +187,10 @@ All args and flags are passed as-is to the executable:
186187
-->
187188
所有参数和标记按原样传递给可执行文件:
188189

189-
```
190+
```shell
190191
kubectl foo version
191192
```
193+
192194
```
193195
1.0.0
194196
```
@@ -202,13 +204,15 @@ All environment variables are also passed as-is to the executable:
202204
export KUBECONFIG=~/.kube/config
203205
kubectl foo config
204206
```
207+
205208
```
206209
/home/<user>/.kube/config
207210
```
208211

209212
```shell
210213
KUBECONFIG=/etc/kube/config kubectl foo config
211214
```
215+
212216
```
213217
/etc/kube/config
214218
```
@@ -584,7 +588,6 @@ installs easier.
584588
* In case of any questions, feel free to reach out to the [CLI SIG team](https://github.com/kubernetes/community/tree/master/sig-cli).
585589
* Read about [Krew](https://krew.dev/), a package manager for kubectl plugins.
586590
-->
587-
588591
* 查看 CLI 插件库示例,查看用 Go 编写的插件的[详细示例](https://github.com/kubernetes/sample-cli-plugin)
589592
* 如有任何问题,请随时联系 [SIG CLI ](https://github.com/kubernetes/community/tree/master/sig-cli)
590593
* 了解 [Krew](https://krew.dev/),一个 kubectl 插件管理器。

content/zh/docs/tasks/extend-kubernetes/configure-multiple-schedulers.md

Lines changed: 82 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,25 @@ weight: 20
1515
<!-- overview -->
1616

1717
<!--
18-
Kubernetes ships with a default scheduler that is described [here](/docs/admin/kube-scheduler/).
18+
Kubernetes ships with a default scheduler that is described
19+
[here](/docs/reference/command-line-tools-reference/kube-scheduler/).
1920
If the default scheduler does not suit your needs you can implement your own scheduler.
20-
Not just that, you can even run multiple schedulers simultaneously alongside
21-
the default scheduler and instruct Kubernetes what scheduler to use for each
22-
of your pods. Let's learn how to run multiple schedulers in Kubernetes with an
23-
example.
21+
Moreover, you can even run multiple schedulers simultaneously alongside the default
22+
scheduler and instruct Kubernetes what scheduler to use for each of your pods. Let's
23+
learn how to run multiple schedulers in Kubernetes with an example.
2424
-->
2525
Kubernetes 自带了一个默认调度器,其详细描述请查阅
2626
[这里](/zh/docs/reference/command-line-tools-reference/kube-scheduler/)
2727
如果默认调度器不适合你的需求,你可以实现自己的调度器。
28-
不仅如此,你甚至可以和默认调度器一起同时运行多个调度器,并告诉 Kubernetes 为每个
28+
而且,你甚至可以和默认调度器一起同时运行多个调度器,并告诉 Kubernetes 为每个
2929
Pod 使用哪个调度器。
3030
让我们通过一个例子讲述如何在 Kubernetes 中运行多个调度器。
3131

3232
<!--
33-
A detailed description of how to implement a scheduler is outside the scope of
34-
this document. Please refer to the kube-scheduler implementation
35-
in[pkg/scheduler](https://github.com/kubernetes/kubernetes/tree/{{< param
36-
"githubbranch" >}}/pkg/scheduler)in the Kubernetes source directory for a
37-
canonical example.
33+
A detailed description of how to implement a scheduler is outside the scope of this
34+
document. Please refer to the kube-scheduler implementation in
35+
[pkg/scheduler](https://github.com/kubernetes/kubernetes/tree/{{< param "githubbranch" >}}/pkg/scheduler)
36+
in the Kubernetes source directory for a canonical example.
3837
-->
3938
关于实现调度器的具体细节描述超出了本文范围。
4039
请参考 kube-scheduler 的实现,规范示例代码位于
@@ -50,15 +49,15 @@ canonical example.
5049
## Package the scheduler
5150
5251
Package your scheduler binary into a container image. For the purposes of this example,
53-
let's just use the default scheduler (kube-scheduler) as our second scheduler as well.
54-
Clone the [Kubernetes source code from Github](https://github.com/kubernetes/kubernetes)
52+
you can use the default scheduler (kube-scheduler) as your second scheduler.
53+
Clone the [Kubernetes source code from GitHub](https://github.com/kubernetes/kubernetes)
5554
and build the source.
5655
-->
5756
## 打包调度器
5857

59-
将调度器可执行文件打包到容器镜像中。出于示例目的,我们就使用默认调度器
60-
(kube-scheduler)作为我们的第二个调度器
61-
克隆 [Github 上 Kubernetes 源代码](https://github.com/kubernetes/kubernetes)
58+
将调度器可执行文件打包到容器镜像中。出于示例目的,可以使用默认调度器
59+
(kube-scheduler)作为第二个调度器
60+
克隆 [GitHub 上 Kubernetes 源代码](https://github.com/kubernetes/kubernetes)
6261
并编译构建源代码。
6362

6463
```shell
@@ -68,13 +67,14 @@ make
6867
```
6968

7069
<!--
71-
Create a container image containing the kube-scheduler binary. Here is the `Dockerfile`to build the image:
70+
Create a container image containing the kube-scheduler binary. Here is the `Dockerfile`
71+
to build the image:
7272
-->
7373
创建一个包含 kube-scheduler 二进制文件的容器镜像。用于构建镜像的 `Dockerfile` 内容如下:
7474

7575
```docker
7676
FROM busybox
77-
ADD ./_output/dockerized/bin/linux/amd64/kube-scheduler /usr/local/bin/kube-scheduler
77+
ADD ./_output/local/bin/linux/amd64/kube-scheduler /usr/local/bin/kube-scheduler
7878
```
7979

8080
<!--
@@ -96,17 +96,17 @@ gcloud docker -- push gcr.io/my-gcp-project/my-kube-scheduler:1.0
9696
<!--
9797
## Define a Kubernetes Deployment for the scheduler
9898
99-
Now that we have our scheduler in a container image, we can just create a pod
100-
config for it and run it in our Kubernetes cluster. But instead of creating a pod
101-
directly in the cluster, let's use a [Deployment](/docs/concepts/workloads/controllers/deployment/)
99+
Now that you have your scheduler in a container image, create a pod
100+
configuration for it and run it in your Kubernetes cluster. But instead of creating a pod
101+
directly in the cluster, you can use a [Deployment](/docs/concepts/workloads/controllers/deployment/)
102102
for this example. A [Deployment](/docs/concepts/workloads/controllers/deployment/) manages a
103103
[Replica Set](/docs/concepts/workloads/controllers/replicaset/) which in turn manages the pods,
104104
thereby making the scheduler resilient to failures. Here is the deployment
105105
config. Save it as `my-scheduler.yaml`:
106106
-->
107107
## 为调度器定义 Kubernetes Deployment
108108

109-
现在我们将调度器放在容器镜像中,我们可以为它创建一个 Pod 配置,并在我们的 Kubernetes 集群中
109+
现在将调度器放在容器镜像中,为它创建一个 Pod 配置,并在 Kubernetes 集群中
110110
运行它。但是与其在集群中直接创建一个 Pod,不如使用
111111
[Deployment](/zh/docs/concepts/workloads/controllers/deployment/)
112112
Deployment 管理一个 [ReplicaSet](/zh/docs/concepts/workloads/controllers/replicaset/)
@@ -134,18 +134,22 @@ Note also that we created a dedicated service account `my-scheduler` and bind th
134134
绑定到它,以便它可以获得与 `kube-scheduler` 相同的权限。
135135

136136
<!--
137-
Please see the[kube-scheduler documentation](/docs/admin/kube-scheduler/) for detailed description of other command line arguments.
137+
Please see the
138+
[kube-scheduler documentation](/docs/reference/command-line-tools-reference/kube-scheduler/) for
139+
detailed description of other command line arguments.
138140
-->
139-
请参阅 [kube-scheduler 文档](/docs/reference/command-line-tools-reference/kube-scheduler/)以获取其他命令行参数的详细说明。
141+
请参阅 [kube-scheduler 文档](/docs/reference/command-line-tools-reference/kube-scheduler/)
142+
以获取其他命令行参数的详细说明。
140143

141144
<!--
142145
## Run the second scheduler in the cluster
143146
144-
In order to run your scheduler in a Kubernetes cluster, just create the deployment specified in the config above in a Kubernetes cluster:
147+
In order to run your scheduler in a Kubernetes cluster, create the deployment
148+
specified in the config above in a Kubernetes cluster:
145149
-->
146150
## 在集群中运行第二个调度器
147151

148-
为了在 Kubernetes 集群中运行我们的第二个调度器,只需在 Kubernetes 集群中创建上面配置中指定的 Deployment:
152+
为了在 Kubernetes 集群中运行我们的第二个调度器, Kubernetes 集群中创建上面配置中指定的 Deployment:
149153

150154
```shell
151155
kubectl create -f my-scheduler.yaml
@@ -170,7 +174,8 @@ my-scheduler-lnf4s-4744f 1/1 Running 0 2m
170174
```
171175

172176
<!--
173-
You should see a "Running" my-scheduler pod, in addition to the default kube-scheduler pod in this list.
177+
You should see a "Running" my-scheduler pod, in addition to the default kube-scheduler
178+
pod in this list.
174179
-->
175180
此列表中,除了默认的 `kube-scheduler` Pod 之外,你应该还能看到处于 “Running” 状态的
176181
`my-scheduler` Pod。
@@ -190,14 +195,24 @@ First, update the following fields in your YAML file:
190195
首先,更新上述 Deployment YAML(my-scheduler.yaml)文件中的以下字段:
191196

192197
* `--leader-elect=true`
193-
* `--lock-object-namespace=lock-object-namespace`
194-
* `--lock-object-name=lock-object-name`
198+
* `--lock-object-namespace=<lock-object-namespace>`
199+
* `--lock-object-name=<lock-object-name>`
195200

201+
{{< note >}}
196202
<!--
197-
If RBAC is enabled on your cluster, you must update the `system:kube-scheduler` cluster role. Add you scheduler name to the resourceNames of the rule applied for endpoints resources, as in the following example:
203+
The control plane creates the lock objects for you, but the namespace must already exist.
204+
You can use the `kube-system` namespace.
205+
-->
206+
控制平面会为你创建锁对象,但是命名空间必须已经存在。
207+
你可以使用 `kube-system` 命名空间。
208+
{{< /note >}}
209+
210+
<!--
211+
If RBAC is enabled on your cluster, you must update the `system:kube-scheduler` cluster role.
212+
Add your scheduler name to the resourceNames of the rule applied for `endpoints` and `leases` resources, as in the following example:
198213
-->
199214
如果在集群上启用了 RBAC,则必须更新 `system:kube-scheduler` 集群角色。
200-
将调度器名称添加到应用于端点资源的规则的 resourceNames,如以下示例所示:
215+
将调度器名称添加到应用了 `endpoints``leases` 资源的规则的 resourceNames,如以下示例所示:
201216

202217
```shell
203218
kubectl edit clusterrole system:kube-scheduler
@@ -211,11 +226,13 @@ kubectl edit clusterrole system:kube-scheduler
211226
## 为 Pod 指定调度器
212227

213228
<!--
214-
Now that our second scheduler is running, let's create some pods, and direct them to be scheduled by either the default scheduler or the one we just deployed. In order to schedule a given pod using a specific scheduler, we specify the name of the scheduler in that pod spec. Let's look at three examples.
229+
Now that your second scheduler is running, create some pods, and direct them
230+
to be scheduled by either the default scheduler or the one you deployed.
231+
In order to schedule a given pod using a specific scheduler, specify the name of the
232+
scheduler in that pod spec. Let's look at three examples.
215233
-->
216-
现在我们的第二个调度器正在运行,让我们创建一些 Pod,并指定它们由默认调度器或我们刚部署的
217-
调度器进行调度。
218-
为了使用特定的调度器调度给定的 Pod,我们在那个 Pod 的规约中指定调度器的名称。让我们看看三个例子。
234+
现在第二个调度器正在运行,创建一些 Pod,并指定它们由默认调度器或部署的调度器进行调度。
235+
为了使用特定的调度器调度给定的 Pod,在那个 Pod 的 spec 中指定调度器的名称。让我们看看三个例子。
219236

220237
<!--
221238
- Pod spec without any scheduler name
@@ -225,7 +242,8 @@ Now that our second scheduler is running, let's create some pods, and direct the
225242
{{< codenew file="admin/sched/pod1.yaml" >}}
226243

227244
<!--
228-
When no scheduler name is supplied, the pod is automatically scheduled using the default-scheduler.
245+
When no scheduler name is supplied, the pod is automatically scheduled using the
246+
default-scheduler.
229247
-->
230248
如果未提供调度器名称,则会使用 default-scheduler 自动调度 pod。
231249

@@ -246,7 +264,8 @@ Now that our second scheduler is running, let's create some pods, and direct the
246264
{{< codenew file="admin/sched/pod2.yaml" >}}
247265

248266
<!--
249-
A scheduler is specified by supplying the scheduler name as a value to `spec.schedulerName`. In this case, we supply the name of the default scheduler which is `default-scheduler`.
267+
A scheduler is specified by supplying the scheduler name as a value to `spec.schedulerName`. In this case, we supply the name of the
268+
default scheduler which is `default-scheduler`.
250269
-->
251270
通过将调度器名称作为 `spec.schedulerName` 参数的值来指定调度器。
252271
在这种情况下,我们提供默认调度器的名称,即 `default-scheduler`
@@ -268,10 +287,9 @@ Now that our second scheduler is running, let's create some pods, and direct the
268287
{{< codenew file="admin/sched/pod3.yaml" >}}
269288

270289
<!--
271-
In this case, we specify that this pod should be scheduled using the
272-
scheduler that we deployed - `my-scheduler`. Note that the value of
273-
`spec.schedulerName` should match the name supplied to the scheduler command
274-
as an argument in the deployment config for the scheduler.
290+
In this case, we specify that this pod should be scheduled using the scheduler that we
291+
deployed - `my-scheduler`. Note that the value of `spec.schedulerName` should match the name supplied to the scheduler
292+
command as an argument in the deployment config for the scheduler.
275293
-->
276294
在这种情况下,我们指定此 pod 使用我们部署的 `my-scheduler` 来调度。
277295
请注意,`spec.schedulerName` 参数的值应该与 Deployment 中配置的提供给
@@ -287,13 +305,13 @@ Now that our second scheduler is running, let's create some pods, and direct the
287305
```
288306

289307
<!--
290-
Verify that all three pods are running.
308+
Verify that all three pods are running.
291309
-->
292-
确认所有三个 pod 都在运行。
310+
确认所有三个 pod 都在运行。
293311

294-
```shell
295-
kubectl get pods
296-
```
312+
```shell
313+
kubectl get pods
314+
```
297315

298316
<!-- discussion -->
299317

@@ -303,7 +321,14 @@ kubectl get pods
303321
### 验证是否使用所需的调度器调度了 pod
304322

305323
<!--
306-
In order to make it easier to work through these examples, we did not verify that the pods were actually scheduled using the desired schedulers. We can verify that by changing the order of pod and deployment config submissions above. If we submit all the pod configs to a Kubernetes cluster before submitting the scheduler deployment config,we see that the pod `annotation-second-scheduler` remains in "Pending" state forever while the other two pods get scheduled. Once we submit the scheduler deployment config and our new scheduler starts running, the `annotation-second-scheduler` pod gets scheduled as well.
324+
In order to make it easier to work through these examples, we did not verify that the
325+
pods were actually scheduled using the desired schedulers. We can verify that by
326+
changing the order of pod and deployment config submissions above. If we submit all the
327+
pod configs to a Kubernetes cluster before submitting the scheduler deployment config,
328+
we see that the pod `annotation-second-scheduler` remains in "Pending" state forever
329+
while the other two pods get scheduled. Once we submit the scheduler deployment config
330+
and our new scheduler starts running, the `annotation-second-scheduler` pod gets
331+
scheduled as well.
307332
-->
308333
为了更容易地完成这些示例,我们没有验证 Pod 实际上是使用所需的调度程序调度的。
309334
我们可以通过更改 Pod 的顺序和上面的部署配置提交来验证这一点。
@@ -313,11 +338,20 @@ In order to make it easier to work through these examples, we did not verify tha
313338
一旦我们提交调度器部署配置并且我们的新调度器开始运行,注解了
314339
`annotation-second-scheduler` 的 pod 就能被调度。
315340
<!--
316-
Alternatively, one could just look at the "Scheduled" entries in the event logs to verify that the pods were scheduled by the desired schedulers.
341+
Alternatively, you can look at the "Scheduled" entries in the event logs to
342+
verify that the pods were scheduled by the desired schedulers.
317343
-->
318344
或者,可以查看事件日志中的 “Scheduled” 条目,以验证是否由所需的调度器调度了 Pod。
319345

320346
```shell
321347
kubectl get events
322348
```
323349

350+
<!--
351+
You can also use a [custom scheduler configuration](/docs/reference/scheduling/config/#multiple-profiles)
352+
or a custom container image for the cluster's main scheduler by modifying its static pod manifest
353+
on the relevant control plane nodes.
354+
-->
355+
你也可以使用[自定义调度器配置](/zh/docs/reference/scheduling/config/#multiple-profiles)
356+
或自定义容器镜像,用于集群的主调度器,方法是在相关控制平面节点上修改其静态 pod 清单。
357+

0 commit comments

Comments
 (0)