You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/zh/docs/tasks/extend-kubectl/kubectl-plugins.md
+19-16Lines changed: 19 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,7 @@ content_type: task
16
16
<!-- overview -->
17
17
<!--
18
18
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`.
@@ -35,12 +35,12 @@ You need to have a working `kubectl` binary installed.
35
35
<!--
36
36
## Installing kubectl plugins
37
37
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`.
39
39
-->
40
40
## 安装 kubectl 插件
41
41
42
-
插件只不过是一个独立的可执行文件,名称以 `kubectl-` 开头。
43
-
要安装插件,只需将此可执行文件移动到 PATH 中的任何位置。
42
+
插件是一个独立的可执行文件,名称以 `kubectl-` 开头。
43
+
要安装插件,将其可执行文件移动到 `PATH` 中的任何位置。
44
44
45
45
<!--
46
46
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
112
112
<!--
113
113
There is no plugin installation or pre-loading required. Plugin executables receive
114
114
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`.
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:
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.
215
233
-->
216
-
现在我们的第二个调度器正在运行,让我们创建一些 Pod,并指定它们由默认调度器或我们刚部署的
217
-
调度器进行调度。
218
-
为了使用特定的调度器调度给定的 Pod,我们在那个 Pod 的规约中指定调度器的名称。让我们看看三个例子。
234
+
现在第二个调度器正在运行,创建一些 Pod,并指定它们由默认调度器或部署的调度器进行调度。
235
+
为了使用特定的调度器调度给定的 Pod,在那个 Pod 的 spec 中指定调度器的名称。让我们看看三个例子。
219
236
220
237
<!--
221
238
- 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
225
242
{{< codenew file="admin/sched/pod1.yaml" >}}
226
243
227
244
<!--
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.
229
247
-->
230
248
如果未提供调度器名称,则会使用 default-scheduler 自动调度 pod。
231
249
@@ -246,7 +264,8 @@ Now that our second scheduler is running, let's create some pods, and direct the
246
264
{{< codenew file="admin/sched/pod2.yaml" >}}
247
265
248
266
<!--
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`.
250
269
-->
251
270
通过将调度器名称作为 `spec.schedulerName` 参数的值来指定调度器。
252
271
在这种情况下,我们提供默认调度器的名称,即 `default-scheduler`。
@@ -268,10 +287,9 @@ Now that our second scheduler is running, let's create some pods, and direct the
268
287
{{< codenew file="admin/sched/pod3.yaml" >}}
269
288
270
289
<!--
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.
@@ -287,13 +305,13 @@ Now that our second scheduler is running, let's create some pods, and direct the
287
305
```
288
306
289
307
<!--
290
-
Verify that all three pods are running.
308
+
Verify that all three pods are running.
291
309
-->
292
-
确认所有三个 pod 都在运行。
310
+
确认所有三个 pod 都在运行。
293
311
294
-
```shell
295
-
kubectl get pods
296
-
```
312
+
```shell
313
+
kubectl get pods
314
+
```
297
315
298
316
<!-- discussion -->
299
317
@@ -303,7 +321,14 @@ kubectl get pods
303
321
### 验证是否使用所需的调度器调度了 pod
304
322
305
323
<!--
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.
307
332
-->
308
333
为了更容易地完成这些示例,我们没有验证 Pod 实际上是使用所需的调度程序调度的。
309
334
我们可以通过更改 Pod 的顺序和上面的部署配置提交来验证这一点。
@@ -313,11 +338,20 @@ In order to make it easier to work through these examples, we did not verify tha
313
338
一旦我们提交调度器部署配置并且我们的新调度器开始运行,注解了
314
339
`annotation-second-scheduler` 的 pod 就能被调度。
315
340
<!--
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.
317
343
-->
318
344
或者,可以查看事件日志中的 “Scheduled” 条目,以验证是否由所需的调度器调度了 Pod。
319
345
320
346
```shell
321
347
kubectl get events
322
348
```
323
349
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
0 commit comments