Merge pull request #20691 from alculquicondor/fix-2nd-scheduler

Add missing ClusterRoleBinding and leases permissions for running 2nd scheduler
This commit is contained in:
Kubernetes Prow Robot
2020-04-30 15:05:37 -07:00
committed by GitHub
2 changed files with 60 additions and 24 deletions
@@ -108,20 +108,27 @@ my-scheduler-lnf4s-4744f 1/1 Running 0 2m
You should see a "Running" my-scheduler pod, in addition to the default kube-scheduler You should see a "Running" my-scheduler pod, in addition to the default kube-scheduler
pod in this list. pod in this list.
### Enable leader election
To run multiple-scheduler with leader election enabled, you must do the following: To run multiple-scheduler with leader election enabled, you must do the following:
First, update the following fields in your YAML file: First, update the following fields in your YAML file:
* `--leader-elect=true` * `--leader-elect=true`
* `--lock-object-namespace=lock-object-namespace` * `--lock-object-namespace=<lock-object-namespace>`
* `--lock-object-name=lock-object-name` * `--lock-object-name=<lock-object-name>`
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: {{< note >}}
The control plane creates the lock objects for you, but the namespace must already exist.
You can use the `kube-system` namespace.
{{< /note >}}
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:
``` ```
kubectl edit clusterrole system:kube-scheduler kubectl edit clusterrole system:kube-scheduler
``` ```
```yaml ```yaml
- apiVersion: rbac.authorization.k8s.io/v1 apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole kind: ClusterRole
metadata: metadata:
annotations: annotations:
@@ -130,6 +137,22 @@ kubectl edit clusterrole system:kube-scheduler
kubernetes.io/bootstrapping: rbac-defaults kubernetes.io/bootstrapping: rbac-defaults
name: system:kube-scheduler name: system:kube-scheduler
rules: rules:
- apiGroups:
- coordination.k8s.io
resources:
- leases
verbs:
- create
- apiGroups:
- coordination.k8s.io
resourceNames:
- kube-scheduler
- my-scheduler
resources:
- leases
verbs:
- get
- update
- apiGroups: - apiGroups:
- "" - ""
resourceNames: resourceNames:
@@ -17,6 +17,19 @@ roleRef:
name: system:kube-scheduler name: system:kube-scheduler
apiGroup: rbac.authorization.k8s.io apiGroup: rbac.authorization.k8s.io
--- ---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: my-scheduler-as-volume-scheduler
subjects:
- kind: ServiceAccount
name: my-scheduler
namespace: kube-system
roleRef:
kind: ClusterRole
name: system:volume-scheduler
apiGroup: rbac.authorization.k8s.io
---
apiVersion: apps/v1 apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata: