I'm trying to figure out how to configure the kubernetes scheduler using a custom config but I'm having a bit of trouble understanding exactly how the scheduler is accessible.
The scheduler runs as a pod under the kube-system
namespace called kube-scheduler-it-k8s-master
. The documentation says that you can configure the scheduler by creating a config file and calling kube-scheduler --config <filename>
. However I am not able to access the scheduler container directly as running kubectl exec -it kube-scheduler-it-k8s-master -- /bin/bash
returns:
OCI runtime exec failed: exec failed: container_linux.go:370: starting container process caused: exec: "/bin/bash": stat /bin/bash: no such file or directory: unknown
command terminated with exit code 126
I tried modifying /etc/kubernetes/manifests/kube-scheduler
to mount my custom config file within the pod and explicitly call kube-scheduler
with the --config
option set, but it seems that my changes get reverted and the scheduler runs using the default settings.
I feel like I'm misunderstanding something fundamentally about the kubernetes scheduler. Am I supposed to pass in the custom scheduler config from within the scheduler pod itself? Or is this supposed to be done remotely somehow?
Thanks!
Since your X problem is "how to modify scheduler configuration", you can try the following for it.
Using kubeadm
If you are using
kubeadm
to bootstrap the cluster, you can use--config
flag while runningkubeadm init
to pass a custom configuration object of typeClusterConfiguration
to pass extra arguments to control plane components.Example config for scheduler:
You could also try
kubeadm upgrade apply --config sched.conf <k8s version>
to apply updated config on a live cluster.Reference: https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/control-plane-flags/
Updating static pod manifest
You could also edit
/etc/kubernetes/manifests/kube-scheduler.yaml
, modify the flags to pass the config. Make sure you mount the file into the pod by updatingvolumes
andvolumeMounts
section.