Custom Scheduler leaves pod in pending Kubernetes cluster Custom Scheduler leaves pod in pending Kubernetes cluster kubernetes kubernetes

Custom Scheduler leaves pod in pending Kubernetes cluster


I've found a solution

Add these lines:

- apiGroups:  - storage.k8s.io  resources:  - storageclasses  verbs:  - watch  - list  - get

to the end of the output of this command (this opens a file for you to edit):

kubectl edit clusterrole system:kube-scheduler

The pod using the scheduler that I deployed is now Running

alisd@kubeMaster:~$ kubectl get pods NAME                          READY   STATUS    RESTARTS   AGEannotation-second-scheduler   1/1     Running   0          9m33s

......

kubectl describe pod annotation-second-scheduler

......

 Events:      Type    Reason     Age   From                 Message      ----    ------     ----  ----                 -------      Normal  Scheduled  12m   my-scheduler         Successfully assigned default/annotation-second-scheduler to kubemaster      Normal  Pulled     12m   kubelet, kubemaster  Container image "k8s.gcr.io/pause:2.0" already present on machine      Normal  Created    12m   kubelet, kubemaster  Created container pod-with-second-annotation-container      Normal  Started    12m   kubelet, kubemaster  Started container pod-with-second-annotation-container


Service Account system:serviceaccount:kube-system:my-scheduler needs to associate with the following cluster wide role system:kube-scheduler in order to access the resources. my-scheduler will have same authorities as the default scheduler.

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. define-a-kubernetes-deployment-for-the-scheduler

kind: ClusterRoleBindingapiVersion: rbac.authorization.k8s.io/v1metadata:  name: my-scheduler-as-kube-schedulersubjects:- kind: ServiceAccount  name: my-scheduler  namespace: kube-systemroleRef:  kind: ClusterRole  name: system:kube-scheduler  apiGroup: rbac.authorization.k8s.io


To add to ali saaad solution answer I also had to add "csinodes" to resources to be able to schedule pod, so it looks like:

- apiGroups:   - storage.k8s.io   resources:   - csinodes   - storageclasses   verbs:   - watch   - list   - get