This is an example of Kubernetes Scheduler Extender
$ IMAGE=YOUR_ORG/YOUR_IMAGE:YOUR_TAG
$ docker build . -t "${IMAGE}"
$ docker push "${IMAGE}"
please see ConfigMap in extender.yaml for scheduler policy json which includes scheduler extender config.
# bring up the kube-scheduler along with the extender image you've just built
$ sed 's/a\/b:c/'$(echo "${IMAGE}" | sed 's/\//\\\//')'/' extender.yaml | kubectl apply -f -
For ease of observation, start streaming logs from the extender:
$ kubectl -n kube-system logs deploy/my-scheduler -c my-scheduler-extender-ctr -f
[ warn ] 2018/11/07 08:41:40 main.go:84: LOG_LEVEL="" is empty or invalid, fallling back to "INFO".
[ info ] 2018/11/07 08:41:40 main.go:98: Log level was set to INFO
[ info ] 2018/11/07 08:41:40 main.go:116: server starting on the port :80
Open up an another termianl and proceed.
you will see test-pod
will be scheduled by my-scheduler
.
$ kubectl create -f test-pod.yaml
$ kubectl describe pod test-pod
Name: test-pod
...
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 25s my-scheduler Successfully assigned test-pod to minikube
Normal SuccessfulMountVolume 25s kubelet, minikube MountVolume.SetUp succeeded for volume "default-token-wrk5s"
Normal Pulling 24s kubelet, minikube pulling image "nginx"
Normal Pulled 8s kubelet, minikube Successfully pulled image "nginx"
Normal Created 8s kubelet, minikube Created container
Normal Started 8s kubelet, minikube Started container