What is the Kubernetes scheduler and custom scheduling?
Why Interviewers Ask This
This is a differentiating question used for senior and lead roles. Interviewers want to see if you can explain not just what happens, but why — and what the trade-offs are in different approaches.
Answer
The Kubernetes scheduler assigns pods to nodes through a two-phase process: Filtering (Predicate): eliminate nodes that don't satisfy pod requirements. Checks: nodeSelector, nodeAffinity (required), resource availability (requests fit node allocatable), port conflicts (hostPort), volume zone constraints, taints/tolerations, PodTopologySpread. Result: feasible nodes list. Scoring (Priority): rank feasible nodes and pick the best. Plugins: LeastAllocated (prefer nodes with fewer resources used — spreading), MostAllocated (bin-packing — consolidate on fewer nodes), NodeAffinity (preferred), PodTopologySpread (preferred), InterPodAffinity/AntiAffinity, NodeResourcesFit, ImageLocality (prefer nodes already having the container image). Scheduler plugins: Kubernetes scheduler uses a plugin framework (Scheduling Framework). Each scheduling phase has extension points: PreFilter, Filter, PostFilter, PreScore, Score, Reserve, Permit, PreBind, Bind, PostBind. Custom scheduler: write a custom scheduler for specialized placement logic. Specify in pod spec: spec: schedulerName: my-custom-scheduler. Multiple schedulers: run multiple schedulers in the same cluster for different workload types. Scheduler extender: add custom filter/score logic via webhook — call an external HTTP service during scheduling. Gang scheduling: all pods of a batch job must be scheduled simultaneously (AI/ML training, MPI jobs). Volcano or Scheduler framework Coscheduling plugin. Descheduler: rebalances pods after initial scheduling — evicts pods violating affinity constraints, on overutilized nodes, duplicates on same node. Runs periodically as a CronJob. Complement to scheduler (scheduler places pods, descheduler corrects drift).
Pro Tip
Back up your answer with a specific project or situation. Saying 'In my last Kubernetes (K8s) project, I used this when...' immediately makes your answer more credible and memorable.
Previous
What is Kubernetes multi-cluster management?
Next
What is etcd in Kubernetes and how to back it up?