Skip to content

Commit f8276a4

Browse files
authored
Merge pull request #30107 from chirangaalwis/patch-3
Update "multiple schedulers" example
2 parents 191cc3f + 7449bb3 commit f8276a4

File tree

2 files changed

+45
-15
lines changed

2 files changed

+45
-15
lines changed

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

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,26 @@ config. Save it as `my-scheduler.yaml`:
7171

7272
{{< codenew file="admin/sched/my-scheduler.yaml" >}}
7373

74-
An important thing to note here is that the name of the scheduler specified as an
75-
argument to the scheduler command in the container spec should be unique. This is the name that is matched against the value of the optional `spec.schedulerName` on pods, to determine whether this scheduler is responsible for scheduling a particular pod.
74+
In the above manifest, you use a [KubeSchedulerConfiguration](/docs/reference/scheduling/config/)
75+
to customize the behavior of your scheduler implementation. This configuration has been passed to
76+
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.
7677

77-
Note also that we created a dedicated service account `my-scheduler` and bind the cluster role
78+
In the aforementioned Scheduler Configuration, your scheduler implementation is represented via
79+
a [KubeSchedulerProfile](/docs/reference/config-api/kube-scheduler-config.v1beta2/#kubescheduler-config-k8s-io-v1beta2-KubeSchedulerProfile).
80+
{{< note >}}
81+
To determine if a scheduler is responsible for scheduling a specific Pod, the `spec.schedulerName` field in a
82+
PodTemplate or Pod manifest must match the `schedulerName` field of the `KubeSchedulerProfile`.
83+
All schedulers running in the cluster must have unique names.
84+
{{< /note >}}
85+
86+
Also, note that you create a dedicated service account `my-scheduler` and bind the ClusterRole
7887
`system:kube-scheduler` to it so that it can acquire the same privileges as `kube-scheduler`.
7988

8089
Please see the
8190
[kube-scheduler documentation](/docs/reference/command-line-tools-reference/kube-scheduler/) for
82-
detailed description of other command line arguments.
91+
detailed description of other command line arguments and
92+
[Scheduler Configuration reference](https://kubernetes.io/docs/reference/config-api/kube-scheduler-config.v1beta2/) for
93+
detailed description of other customizable `kube-scheduler` configurations.
8394

8495
## Run the second scheduler in the cluster
8596

@@ -110,11 +121,11 @@ pod in this list.
110121

111122
To run multiple-scheduler with leader election enabled, you must do the following:
112123

113-
First, update the following fields in your YAML file:
124+
Update the following fields for the KubeSchedulerConfiguration in the `my-scheduler-config` ConfigMap in your YAML file:
114125

115-
* `--leader-elect=true`
116-
* `--lock-object-namespace=<lock-object-namespace>`
117-
* `--lock-object-name=<lock-object-name>`
126+
* `leaderElection.leaderElect` to `true`
127+
* `leaderElection.resourceNamespace` to `<lock-object-namespace>`
128+
* `leaderElection.resourceName` to `<lock-object-name>`
118129

119130
{{< note >}}
120131
The control plane creates the lock objects for you, but the namespace must already exist.
@@ -168,8 +179,8 @@ scheduler in that pod spec. Let's look at three examples.
168179
{{< codenew file="admin/sched/pod3.yaml" >}}
169180

170181
In this case, we specify that this pod should be scheduled using the scheduler that we
171-
deployed - `my-scheduler`. Note that the value of `spec.schedulerName` should match the name supplied to the scheduler
172-
command as an argument in the deployment config for the scheduler.
182+
deployed - `my-scheduler`. Note that the value of `spec.schedulerName` should match the name supplied for the scheduler
183+
in the `schedulerName` field of the mapping `KubeSchedulerProfile`.
173184

174185
Save this file as `pod3.yaml` and submit it to the Kubernetes cluster.
175186

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

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,22 @@ roleRef:
3030
name: system:volume-scheduler
3131
apiGroup: rbac.authorization.k8s.io
3232
---
33+
34+
apiVersion: v1
35+
kind: ConfigMap
36+
metadata:
37+
name: my-scheduler-config
38+
namespace: kube-system
39+
data:
40+
my-scheduler-config.yaml: |
41+
apiVersion: kubescheduler.config.k8s.io/v1beta2
42+
kind: KubeSchedulerConfiguration
43+
profiles:
44+
- schedulerName: my-scheduler
45+
leaderElection:
46+
leaderElect: false
47+
48+
---
3349
apiVersion: apps/v1
3450
kind: Deployment
3551
metadata:
@@ -55,9 +71,7 @@ spec:
5571
containers:
5672
- command:
5773
- /usr/local/bin/kube-scheduler
58-
- --address=0.0.0.0
59-
- --leader-elect=false
60-
- --scheduler-name=my-scheduler
74+
- --config=/etc/kubernetes/my-scheduler/my-scheduler-config.yaml
6175
image: gcr.io/my-gcp-project/my-kube-scheduler:1.0
6276
livenessProbe:
6377
httpGet:
@@ -74,7 +88,12 @@ spec:
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)