Kubernetes (K8s) (50 Qs)•Part 2: Core Architecture & Implementation (Mid-Level)
Kube-Scheduler Deep-Dive: Filtering, Scoring, Affinity, Taints, and Tolerations.
senior LevelMost AskedSystem Design
In Simple Words: The scheduler assigns unscheduled Pods to optimal worker nodes in a two-phase process:
- Filtering (Predicates): Eliminates unqualified nodes:
- Does the node have enough unreserved CPU/memory requests?
- Does the node match Pod
nodeSelector/nodeAffinity? - Does the node have a Taint that the Pod cannot Tolerate?
- Scoring (Priorities): Ranks surviving nodes from 0 to 100:
- Evaluates image locality (is the Docker image already cached on the node?).
- Evaluates
podAntiAffinity(spreads replicas across different availability zones). - Assigns the Pod to the node with the highest aggregate score.
Taints and Tolerations:
- Taint (on Node): Repels pods (
key=gpu:NoSchedule). - Toleration (on Pod): Allows (but does not force) the Pod to schedule on a tainted node.