Kube Scheduler
π§ What is kube-scheduler?¶
It's the brain that assigns pods to nodes:
- It looks at all unscheduled pods.
- It analyzes each nodeβs available resources, taints, affinities, etc.
- It picks the best node and updates the pod spec.
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
component: kube-scheduler
tier: control-plane
name: kube-scheduler
namespace: kube-system
spec:
containers:
- command:
- kube-scheduler
- --authentication-kubeconfig=/etc/kubernetes/scheduler.conf
- --authorization-kubeconfig=/etc/kubernetes/scheduler.conf
- --bind-address=127.0.0.1
- --kubeconfig=/etc/kubernetes/scheduler.conf
- --leader-elect=true
image: registry.k8s.io/kube-scheduler:v1.33.0
imagePullPolicy: IfNotPresent
livenessProbe:
failureThreshold: 8
httpGet:
host: 127.0.0.1
path: /livez
port: 10259
scheme: HTTPS
initialDelaySeconds: 10
periodSeconds: 10
timeoutSeconds: 15
name: kube-scheduler
readinessProbe:
failureThreshold: 3
httpGet:
host: 127.0.0.1
path: /readyz
port: 10259
scheme: HTTPS
periodSeconds: 1
timeoutSeconds: 15
resources:
requests:
cpu: 100m
startupProbe:
failureThreshold: 24
httpGet:
host: 127.0.0.1
path: /livez
port: 10259
scheme: HTTPS
initialDelaySeconds: 10
periodSeconds: 10
timeoutSeconds: 15
volumeMounts:
- mountPath: /etc/kubernetes/scheduler.conf
name: kubeconfig
readOnly: true
hostNetwork: true
priority: 2000001000
priorityClassName: system-node-critical
securityContext:
seccompProfile:
type: RuntimeDefault
volumes:
- hostPath:
path: /etc/kubernetes/scheduler.conf
type: FileOrCreate
name: kubeconfig
status: {}
πΉ COMMAND FLAGS EXPLAINED¶
Let's go line by line.
β
--authentication-kubeconfig=/etc/kubernetes/scheduler.conf¶
π Purpose: Used by the scheduler when it needs to authenticate itself to the kube-apiserver.
π‘ Think of it like:
"Hey API server, I'm the legit kube-scheduler, here's my kubeconfig + cert."
π This kubeconfig:
- Has client cert/key to prove identity.
- Points to the API server endpoint.
- Includes cluster CA.
β
--authorization-kubeconfig=/etc/kubernetes/scheduler.conf¶
π Purpose: Used for authorization of kube-scheduler β i.e., what itβs allowed to do.
π‘ Think of it like:
"What operations am I allowed to perform on the cluster objects?"
β
Both authentication- and authorization- configs can be same file β which it is here (scheduler.conf).
β
--bind-address=127.0.0.1¶
π Purpose: This tells the scheduler:
"Only listen on the local interface."
It listens on:
https://127.0.0.1:10259β for health checks & metrics
π Security Benefit:
- Prevents access from other hosts.
- Scheduler does not need to be accessed externally.
β
--kubeconfig=/etc/kubernetes/scheduler.conf¶
π§ Purpose: Used by the scheduler to communicate with the kube-apiserver.
π Same file as above, but this is the primary config for API calls like:
- Getting pods
- Listing nodes
- Watching for new pod objects
β
--leader-elect=true¶
π§ Purpose: Enables leader election, important for HA (High Availability) setups.
π‘ In multi-control-plane clusters:
- Multiple scheduler pods might run.
- But only one becomes the active leader.
- Others standby and take over if the leader fails.
π¦ This uses Kubernetes built-in lease objects for coordination.
πΉ PROBES¶
These define how kubelet monitors the scheduler containerβs health.
β
startupProbe, livenessProbe, readinessProbe¶
| Probe Type | Purpose |
|---|---|
startupProbe | Used during boot-up β lets scheduler take time to initialize |
livenessProbe | Is it alive and responding at /livez? |
readinessProbe | Is it ready to serve? i.e., fully initialized |
π All hit:
host: 127.0.0.1port: 10259scheme: HTTPS
π‘οΈ These endpoints are only reachable from localhost.
πΉ VOLUME MOUNTS¶
β Volume + Mount¶
volumeMounts:
- mountPath: /etc/kubernetes/scheduler.conf
name: kubeconfig
It mounts the host's kubeconfig file (scheduler.conf) into the container at the same path β used for authentication + communication with the API server.
πΉ OTHER FIELDS¶
| Field | Meaning |
|---|---|
hostNetwork: true | Required so it can reach other control plane services via localhost |
priorityClassName: system-node-critical | Gives it the highest possible priority to prevent eviction |
securityContext.seccompProfile | Applies the default syscall profile for basic sandboxing |
π§ Summary (Plain English)¶
| Component | Purpose |
|---|---|
--bind-address=127.0.0.1 | Listen only on localhost, for security |
--kubeconfig | Lets it talk to kube-apiserver |
--authentication-kubeconfig | Proves its identity |
--authorization-kubeconfig | Checks what actions it can do |
--leader-elect | Makes sure only one active scheduler exists in HA setup |
startup/liveness/readiness probes | Let kubelet monitor its health via /livez and /readyz |
π‘ Optional Info¶
- The
scheduler.conffile is auto-generated bykubeadm initand is stored at:
/etc/kubernetes/scheduler.conf
You can inspect it:
kubectl config view --kubeconfig=/etc/kubernetes/scheduler.conf