Merge pull request #30107 from chirangaalwis/patch-3
Update "multiple schedulers" example
This commit is contained in:
@@ -71,15 +71,26 @@ config. Save it as `my-scheduler.yaml`:
|
||||
|
||||
{{< codenew file="admin/sched/my-scheduler.yaml" >}}
|
||||
|
||||
An important thing to note here is that the name of the scheduler specified as an
|
||||
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.
|
||||
In the above manifest, you use a [KubeSchedulerConfiguration](/docs/reference/scheduling/config/)
|
||||
to customize the behavior of your scheduler implementation. This configuration has been passed to
|
||||
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.
|
||||
|
||||
Note also that we created a dedicated service account `my-scheduler` and bind the cluster role
|
||||
In the aforementioned Scheduler Configuration, your scheduler implementation is represented via
|
||||
a [KubeSchedulerProfile](/docs/reference/config-api/kube-scheduler-config.v1beta2/#kubescheduler-config-k8s-io-v1beta2-KubeSchedulerProfile).
|
||||
{{< note >}}
|
||||
To determine if a scheduler is responsible for scheduling a specific Pod, the `spec.schedulerName` field in a
|
||||
PodTemplate or Pod manifest must match the `schedulerName` field of the `KubeSchedulerProfile`.
|
||||
All schedulers running in the cluster must have unique names.
|
||||
{{< /note >}}
|
||||
|
||||
Also, note that you create a dedicated service account `my-scheduler` and bind the ClusterRole
|
||||
`system:kube-scheduler` to it so that it can acquire the same privileges as `kube-scheduler`.
|
||||
|
||||
Please see the
|
||||
[kube-scheduler documentation](/docs/reference/command-line-tools-reference/kube-scheduler/) for
|
||||
detailed description of other command line arguments.
|
||||
detailed description of other command line arguments and
|
||||
[Scheduler Configuration reference](https://kubernetes.io/docs/reference/config-api/kube-scheduler-config.v1beta2/) for
|
||||
detailed description of other customizable `kube-scheduler` configurations.
|
||||
|
||||
## Run the second scheduler in the cluster
|
||||
|
||||
@@ -110,11 +121,11 @@ pod in this list.
|
||||
|
||||
To run multiple-scheduler with leader election enabled, you must do the following:
|
||||
|
||||
First, update the following fields in your YAML file:
|
||||
Update the following fields for the KubeSchedulerConfiguration in the `my-scheduler-config` ConfigMap in your YAML file:
|
||||
|
||||
* `--leader-elect=true`
|
||||
* `--lock-object-namespace=<lock-object-namespace>`
|
||||
* `--lock-object-name=<lock-object-name>`
|
||||
* `leaderElection.leaderElect` to `true`
|
||||
* `leaderElection.resourceNamespace` to `<lock-object-namespace>`
|
||||
* `leaderElection.resourceName` to `<lock-object-name>`
|
||||
|
||||
{{< note >}}
|
||||
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.
|
||||
{{< codenew file="admin/sched/pod3.yaml" >}}
|
||||
|
||||
In this case, we specify that this pod should be scheduled using the scheduler that we
|
||||
deployed - `my-scheduler`. Note that the value of `spec.schedulerName` should match the name supplied to the scheduler
|
||||
command as an argument in the deployment config for the scheduler.
|
||||
deployed - `my-scheduler`. Note that the value of `spec.schedulerName` should match the name supplied for the scheduler
|
||||
in the `schedulerName` field of the mapping `KubeSchedulerProfile`.
|
||||
|
||||
Save this file as `pod3.yaml` and submit it to the Kubernetes cluster.
|
||||
|
||||
|
||||
@@ -30,6 +30,22 @@ roleRef:
|
||||
name: system:volume-scheduler
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
---
|
||||
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: my-scheduler-config
|
||||
namespace: kube-system
|
||||
data:
|
||||
my-scheduler-config.yaml: |
|
||||
apiVersion: kubescheduler.config.k8s.io/v1beta2
|
||||
kind: KubeSchedulerConfiguration
|
||||
profiles:
|
||||
- schedulerName: my-scheduler
|
||||
leaderElection:
|
||||
leaderElect: false
|
||||
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
@@ -55,9 +71,7 @@ spec:
|
||||
containers:
|
||||
- command:
|
||||
- /usr/local/bin/kube-scheduler
|
||||
- --address=0.0.0.0
|
||||
- --leader-elect=false
|
||||
- --scheduler-name=my-scheduler
|
||||
- --config=/etc/kubernetes/my-scheduler/my-scheduler-config.yaml
|
||||
image: gcr.io/my-gcp-project/my-kube-scheduler:1.0
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
@@ -74,7 +88,12 @@ spec:
|
||||
cpu: '0.1'
|
||||
securityContext:
|
||||
privileged: false
|
||||
volumeMounts: []
|
||||
volumeMounts:
|
||||
- name: config-volume
|
||||
mountPath: /etc/kubernetes/my-scheduler
|
||||
hostNetwork: false
|
||||
hostPID: false
|
||||
volumes: []
|
||||
volumes:
|
||||
- name: config-volume
|
||||
configMap:
|
||||
name: my-scheduler-config
|
||||
|
||||
Reference in New Issue
Block a user