From d03745376c281a37a3dd3cceeb1c2fb86ad415cb Mon Sep 17 00:00:00 2001 From: Yujun Zhang Date: Mon, 4 Jun 2018 23:04:53 +0800 Subject: [PATCH] Fix errors in configure-multiple-schedulers.md (#8540) * Fix errors in configure-multiple-schedulers.md - Failed to push docker image - Errors found in my-scheduler logs ``` ... E0515 06:36:28.180428 1 reflector.go:205] k8s.io/kubernetes/vendor/k8s.io/client-go/informers/factory.go:130: Failed to list *v1beta1.ReplicaSet: replicasets.extensions is forbidden: User "system:serviceaccount:kube-system:default" cannot list replicasets.extensions at the cluster scope ``` * Replace double quote with backticks for code strings * Use `system:kube-scheduler` instead of `cluster-admin` * Create dedicated service account for `my-scheduler` --- .../configure-multiple-schedulers.md | 5 ++++- .../administer-cluster/my-scheduler.yaml | 20 +++++++++++++++++++ test/examples_test.go | 2 +- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/content/en/docs/tasks/administer-cluster/configure-multiple-schedulers.md b/content/en/docs/tasks/administer-cluster/configure-multiple-schedulers.md index 64f72a2f14..bad469431f 100644 --- a/content/en/docs/tasks/administer-cluster/configure-multiple-schedulers.md +++ b/content/en/docs/tasks/administer-cluster/configure-multiple-schedulers.md @@ -44,7 +44,7 @@ For more details, please read the GCR [documentation](https://cloud.google.com/container-registry/docs/). ```shell -docker build -t my-kube-scheduler:1.0 . +docker build -t gcr.io/my-gcp-project/my-kube-scheduler:1.0 . gcloud docker -- push gcr.io/my-gcp-project/my-kube-scheduler:1.0 ``` @@ -63,6 +63,9 @@ config. Save it as `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. +Note also that we created a dedicated service account `my-scheduler` and bind the cluster role +`system:kube-scheduler` to it so that it can acquire the same privileges as `kube-scheduler`. + Please see the [kube-scheduler documentation](/docs/admin/kube-scheduler/) for detailed description of other command line arguments. diff --git a/content/en/docs/tasks/administer-cluster/my-scheduler.yaml b/content/en/docs/tasks/administer-cluster/my-scheduler.yaml index b9f653e1d2..ab0c385cd6 100644 --- a/content/en/docs/tasks/administer-cluster/my-scheduler.yaml +++ b/content/en/docs/tasks/administer-cluster/my-scheduler.yaml @@ -1,3 +1,22 @@ +apiVersion: v1 +kind: ServiceAccount +metadata: + name: my-scheduler + namespace: kube-system +--- +kind: ClusterRoleBinding +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: my-scheduler-as-kube-scheduler +subjects: +- kind: ServiceAccount + name: my-scheduler + namespace: kube-system +roleRef: + kind: ClusterRole + name: kube-scheduler + apiGroup: rbac.authorization.k8s.io +--- apiVersion: apps/v1 kind: Deployment metadata: @@ -19,6 +38,7 @@ spec: tier: control-plane version: second spec: + serviceAccountName: my-scheduler containers: - command: - /usr/local/bin/kube-scheduler diff --git a/test/examples_test.go b/test/examples_test.go index 48de1ea664..55d0fa6a92 100644 --- a/test/examples_test.go +++ b/test/examples_test.go @@ -369,7 +369,7 @@ func TestExampleObjectSchemas(t *testing.T) { "memory-defaults-pod": {&api.Pod{}}, "memory-defaults-pod-2": {&api.Pod{}}, "memory-defaults-pod-3": {&api.Pod{}}, - "my-scheduler": {&extensions.Deployment{}}, + "my-scheduler": {&api.ServiceAccount{}, &rbac.ClusterRoleBinding{}, &extensions.Deployment{}}, "namespace-dev": {&api.Namespace{}}, "namespace-prod": {&api.Namespace{}}, "persistent-volume-label-initializer-config": {&admissionregistration.InitializerConfiguration{}},