How to use a custom scheduler for kubernetes (on google cloud), written in bash language?

8/1/2017

at http://blog.kubernetes.io/2017/03/advanced-scheduling-in-kubernetes.html an example of a custom scheduler for kubernetes is given, which is written in bash language. My question is how can such a custom scheduler be used for a pod? It says "Note that you need to run this along with kubectl proxy for it to work", which is not clear to me.

I would appreciate any help. thanks

-- samanta
kubernetes

1 Answer

8/1/2017

You would need to deploy the scheduler. Then associate that scheduler to your pod.

This is a great write-up: https://kubernetes.io/docs/tasks/administer-cluster/configure-multiple-schedulers/

Here is an example deployment of my-scheduler:

apiVersion: apps/v1beta1
kind: Deployment
metadata:
  labels:
    component: scheduler
    tier: control-plane
  name: my-scheduler
  namespace: kube-system
spec:
  replicas: 1
  template:
    metadata:
      labels:
        component: scheduler
        tier: control-plane
        version: second
    spec:
      containers:
      - command:
        - /usr/local/bin/kube-scheduler
        - --address=0.0.0.0
        - --leader-elect=false
        - --scheduler-name=my-scheduler
        image: gcr.io/my-gcp-project/my-kube-scheduler:1.0
        livenessProbe:
          httpGet:
            path: /healthz
            port: 10251
          initialDelaySeconds: 15
        name: kube-second-scheduler
        readinessProbe:
          httpGet:
            path: /healthz
            port: 10251
        resources:
          requests:
            cpu: '0.1'
        securityContext:
          privileged: false
        volumeMounts: []
      hostNetwork: false
      hostPID: false
      volumes: []

Here is how to connect a pod to your scheduler:

apiVersion: v1
kind: Pod
metadata:
  name: annotation-second-scheduler
  labels:
    name: multischeduler-example
spec:
  schedulerName: my-scheduler
  containers:
  - name: pod-with-second-annotation-container
    image: gcr.io/google_containers/pause:2.0

The key part in the above are spec.schedulerName.

-- Tr1gZer0
Source: StackOverflow