Skip to content

Commit 5fbcd30

Browse files
authored
Merge pull request #20691 from alculquicondor/fix-2nd-scheduler
Add missing ClusterRoleBinding and leases permissions for running 2nd scheduler
2 parents 21f4066 + ade52de commit 5fbcd30

File tree

2 files changed

+60
-24
lines changed

2 files changed

+60
-24
lines changed

content/en/docs/tasks/administer-cluster/configure-multiple-schedulers.md

Lines changed: 47 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -108,40 +108,63 @@ my-scheduler-lnf4s-4744f 1/1 Running 0 2m
108108
You should see a "Running" my-scheduler pod, in addition to the default kube-scheduler
109109
pod in this list.
110110

111+
### Enable leader election
112+
111113
To run multiple-scheduler with leader election enabled, you must do the following:
112114

113115
First, update the following fields in your YAML file:
114116

115117
* `--leader-elect=true`
116-
* `--lock-object-namespace=lock-object-namespace`
117-
* `--lock-object-name=lock-object-name`
118+
* `--lock-object-namespace=<lock-object-namespace>`
119+
* `--lock-object-name=<lock-object-name>`
120+
121+
{{< note >}}
122+
The control plane creates the lock objects for you, but the namespace must already exist.
123+
You can use the `kube-system` namespace.
124+
{{< /note >}}
118125

119-
If RBAC is enabled on your cluster, you must update the `system:kube-scheduler` cluster role. Add your scheduler name to the resourceNames of the rule applied for endpoints resources, as in the following example:
126+
If RBAC is enabled on your cluster, you must update the `system:kube-scheduler` cluster role. Add your scheduler name to the resourceNames of the rule applied for `endpoints` and `leases` resources, as in the following example:
120127
```
121128
kubectl edit clusterrole system:kube-scheduler
122129
```
123130
```yaml
124-
- apiVersion: rbac.authorization.k8s.io/v1
125-
kind: ClusterRole
126-
metadata:
127-
annotations:
128-
rbac.authorization.kubernetes.io/autoupdate: "true"
129-
labels:
130-
kubernetes.io/bootstrapping: rbac-defaults
131-
name: system:kube-scheduler
132-
rules:
133-
- apiGroups:
134-
- ""
135-
resourceNames:
136-
- kube-scheduler
137-
- my-scheduler
138-
resources:
139-
- endpoints
140-
verbs:
141-
- delete
142-
- get
143-
- patch
144-
- update
131+
apiVersion: rbac.authorization.k8s.io/v1
132+
kind: ClusterRole
133+
metadata:
134+
annotations:
135+
rbac.authorization.kubernetes.io/autoupdate: "true"
136+
labels:
137+
kubernetes.io/bootstrapping: rbac-defaults
138+
name: system:kube-scheduler
139+
rules:
140+
- apiGroups:
141+
- coordination.k8s.io
142+
resources:
143+
- leases
144+
verbs:
145+
- create
146+
- apiGroups:
147+
- coordination.k8s.io
148+
resourceNames:
149+
- kube-scheduler
150+
- my-scheduler
151+
resources:
152+
- leases
153+
verbs:
154+
- get
155+
- update
156+
- apiGroups:
157+
- ""
158+
resourceNames:
159+
- kube-scheduler
160+
- my-scheduler
161+
resources:
162+
- endpoints
163+
verbs:
164+
- delete
165+
- get
166+
- patch
167+
- update
145168
```
146169
147170
## Specify schedulers for pods

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,19 @@ roleRef:
1717
name: system:kube-scheduler
1818
apiGroup: rbac.authorization.k8s.io
1919
---
20+
apiVersion: rbac.authorization.k8s.io/v1
21+
kind: ClusterRoleBinding
22+
metadata:
23+
name: my-scheduler-as-volume-scheduler
24+
subjects:
25+
- kind: ServiceAccount
26+
name: my-scheduler
27+
namespace: kube-system
28+
roleRef:
29+
kind: ClusterRole
30+
name: system:volume-scheduler
31+
apiGroup: rbac.authorization.k8s.io
32+
---
2033
apiVersion: apps/v1
2134
kind: Deployment
2235
metadata:

0 commit comments

Comments
 (0)