Skip to content

Commit 97fd422

Browse files
authored
Merge pull request #31685 from jiwq/resyc-configure-multiple-schedulers-zh
[zh] Resync configure multiple schedulers file
2 parents dcc7a76 + 23c39e4 commit 97fd422

File tree

2 files changed

+66
-30
lines changed

2 files changed

+66
-30
lines changed

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

Lines changed: 40 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ Pod 使用哪个调度器。
3232
<!--
3333
A detailed description of how to implement a scheduler is outside the scope of this
3434
document. Please refer to the kube-scheduler implementation in
35-
[pkg/scheduler](https://github.com/kubernetes/kubernetes/tree/{{< param "githubbranch" >}}/pkg/scheduler)
35+
[pkg/scheduler](https://github.com/kubernetes/kubernetes/tree/master/pkg/scheduler)
3636
in the Kubernetes source directory for a canonical example.
3737
-->
3838
关于实现调度器的具体细节描述超出了本文范围。
3939
请参考 kube-scheduler 的实现,规范示例代码位于
40-
[pkg/scheduler](https://github.com/kubernetes/kubernetes/tree/{{< param "githubbranch" >}}/pkg/scheduler)。
40+
[pkg/scheduler](https://github.com/kubernetes/kubernetes/tree/master/pkg/scheduler)
4141

4242
## {{% heading "prerequisites" %}}
4343

@@ -116,18 +116,33 @@ ReplicaSet 再管理 Pod,从而使调度器能够免受一些故障的影响
116116
{{< codenew file="admin/sched/my-scheduler.yaml" >}}
117117

118118
<!--
119-
An important thing to note here is that the name of the scheduler specified as an
120-
argument to the scheduler command in the container spec should be unique.
121-
This is the name that is matched against the value of the optional `spec.schedulerName`
122-
on pods, to determine whether this scheduler is responsible for scheduling a particular pod.
119+
In the above manifest, you use a [KubeSchedulerConfiguration](/docs/reference/scheduling/config/)
120+
to customize the behavior of your scheduler implementation. This configuration has been passed to
121+
the `kube-scheduler` during initialization with the `--config` option. The `my-scheduler-config` ConfigMap stores the configuration file. The Pod of the`my-scheduler` Deployment mounts the `my-scheduler-config` ConfigMap as a volume.
123122
-->
124-
这里需要注意的是,在容器规约中配置的调度器启动命令参数(--scheduler-name)所指定的
125-
调度器名称应该是唯一的
126-
这个名称应该与 Pod 上的可选参数 `spec.schedulerName` 的值相匹配,也就是说调度器名称的匹配
127-
关系决定了 Pods 的调度任务由哪个调度器负责
123+
在以上的清单中,你使用 [KubeSchedulerConfiguration](/zh/docs/reference/scheduling/config/)
124+
来自定义调度器实现的行为。当使用 `--config` 选项进行初始化时,该配置被传递到 `kube-scheduler`
125+
`my-scheduler-config` ConfigMap 存储配置数据。
126+
`my-scheduler` Deployment 的 Pod 将 `my-scheduler-config` ConfigMap 挂载为一个卷
128127

129128
<!--
130-
Note also that we created a dedicated service account `my-scheduler` and bind the cluster role
129+
In the aforementioned Scheduler Configuration, your scheduler implementation is represented via
130+
a [KubeSchedulerProfile](/docs/reference/config-api/kube-scheduler-config.v1beta3/#kubescheduler-config-k8s-io-v1beta3-KubeSchedulerProfile).
131+
{{< note >}}
132+
To determine if a scheduler is responsible for scheduling a specific Pod, the `spec.schedulerName` field in a
133+
PodTemplate or Pod manifest must match the `schedulerName` field of the `KubeSchedulerProfile`.
134+
All schedulers running in the cluster must have unique names.
135+
{{< /note >}}
136+
-->
137+
在前面提到的调度器配置中,你的调度器通过 [KubeSchedulerProfile](/docs/reference/config-api/kube-scheduler-config.v1beta3/#kubescheduler-config-k8s-io-v1beta3-KubeSchedulerProfile) 进行实现。
138+
{{< note >}}
139+
要确定一个调度器是否可以调度特定的 Pod,PodTemplate 或 Pod 清单中的 `spec.schedulerName`
140+
字段必须匹配 `KubeSchedulerProfile` 中的 `schedulerName` 字段。
141+
所有运行在集群中的调度器必须拥有唯一的名称。
142+
{{< /note >}}
143+
144+
<!--
145+
Also, note that you create a dedicated service account `my-scheduler` and bind the ClusterRole
131146
`system:kube-scheduler` to it so that it can acquire the same privileges as `kube-scheduler`.
132147
-->
133148
还要注意,我们创建了一个专用服务账号 `my-scheduler` 并将集群角色 `system:kube-scheduler`
@@ -136,10 +151,13 @@ Note also that we created a dedicated service account `my-scheduler` and bind th
136151
<!--
137152
Please see the
138153
[kube-scheduler documentation](/docs/reference/command-line-tools-reference/kube-scheduler/) for
139-
detailed description of other command line arguments.
154+
detailed description of other command line arguments and
155+
[Scheduler Configuration reference](/docs/reference/config-api/kube-scheduler-config.v1beta3/) for
156+
detailed description of other customizable `kube-scheduler` configurations.
140157
-->
141158
请参阅 [kube-scheduler 文档](/docs/reference/command-line-tools-reference/kube-scheduler/)
142-
以获取其他命令行参数的详细说明。
159+
获取其他命令行参数以及 [Scheduler 配置参考](/docs/reference/config-api/kube-scheduler-config.v1beta3/)
160+
获取自定义 `kube-scheduler` 配置的详细说明。
143161

144162
<!--
145163
## Run the second scheduler in the cluster
@@ -186,17 +204,17 @@ pod in this list.
186204
187205
To run multiple-scheduler with leader election enabled, you must do the following:
188206
189-
First, update the following fields in your YAML file:
207+
Update the following fields for the KubeSchedulerConfiguration in the `my-scheduler-config` ConfigMap in your YAML file:
190208
-->
191209
### 启用领导者选举
192210

193211
要在启用了 leader 选举的情况下运行多调度器,你必须执行以下操作:
194212

195-
首先,更新上述 Deployment YAMLmy-scheduler.yaml)文件中的以下字段
213+
更新你的 YAML 文件中的 `my-scheduler-config` ConfigMap 里的 KubeSchedulerConfiguration 相关字段如下
196214

197-
* `--leader-elect=true`
198-
* `--lock-object-namespace=<lock-object-namespace>`
199-
* `--lock-object-name=<lock-object-name>`
215+
* `leaderElection.leaderElect` to `true`
216+
* `leaderElection.resourceNamespace` to `<lock-object-namespace>`
217+
* `leaderElection.resourceName` to `<lock-object-name>`
200218

201219
{{< note >}}
202220
<!--
@@ -288,12 +306,11 @@ scheduler in that pod spec. Let's look at three examples.
288306

289307
<!--
290308
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.
309+
deployed - `my-scheduler`. Note that the value of `spec.schedulerName` should match the name supplied for the scheduler
310+
in the `schedulerName` field of the mapping `KubeSchedulerProfile`.
293311
-->
294-
在这种情况下,我们指定此 pod 使用我们部署的 `my-scheduler` 来调度。
295-
请注意,`spec.schedulerName` 参数的值应该与 Deployment 中配置的提供给
296-
scheduler 命令的参数名称匹配。
312+
在这种情况下,我们指定此 Pod 使用我们部署的 `my-scheduler` 来调度。
313+
请注意,`spec.schedulerName` 参数的值应该与调度器提供的 `KubeSchedulerProfile` 中的 `schedulerName` 字段相匹配。
297314

298315
<!--
299316
Save this file as `pod3.yaml` and submit it to the Kubernetes cluster.

content/zh/examples/admin/sched/my-scheduler.yaml

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,20 @@ roleRef:
1717
name: system:kube-scheduler
1818
apiGroup: rbac.authorization.k8s.io
1919
---
20+
apiVersion: v1
21+
kind: ConfigMap
22+
metadata:
23+
name: my-scheduler-config
24+
namespace: kube-system
25+
data:
26+
my-scheduler-config.yaml: |
27+
apiVersion: kubescheduler.config.k8s.io/v1beta2
28+
kind: KubeSchedulerConfiguration
29+
profiles:
30+
- schedulerName: my-scheduler
31+
leaderElection:
32+
leaderElect: false
33+
---
2034
apiVersion: rbac.authorization.k8s.io/v1
2135
kind: ClusterRoleBinding
2236
metadata:
@@ -55,26 +69,31 @@ spec:
5569
containers:
5670
- command:
5771
- /usr/local/bin/kube-scheduler
58-
- --address=0.0.0.0
59-
- --leader-elect=false
60-
- --scheduler-name=my-scheduler
72+
- --config=/etc/kubernetes/my-scheduler/my-scheduler-config.yaml
6173
image: gcr.io/my-gcp-project/my-kube-scheduler:1.0
6274
livenessProbe:
6375
httpGet:
6476
path: /healthz
65-
port: 10251
77+
port: 10259
78+
scheme: HTTPS
6679
initialDelaySeconds: 15
6780
name: kube-second-scheduler
6881
readinessProbe:
6982
httpGet:
7083
path: /healthz
71-
port: 10251
84+
port: 10259
85+
scheme: HTTPS
7286
resources:
7387
requests:
7488
cpu: '0.1'
7589
securityContext:
7690
privileged: false
77-
volumeMounts: []
91+
volumeMounts:
92+
- name: config-volume
93+
mountPath: /etc/kubernetes/my-scheduler
7894
hostNetwork: false
7995
hostPID: false
80-
volumes: []
96+
volumes:
97+
- name: config-volume
98+
configMap:
99+
name: my-scheduler-config

0 commit comments

Comments
 (0)