Kubernetes interview question · Most asked

How does the scheduler place pods? Explain resource requests, node affinity, taints and tolerations.

Summary

The scheduler filters nodes that can run the pod (enough unreserved CPU and memory for its requests, matching node selectors and affinity, tolerated taints, available volumes and ports) and then scores the remaining nodes (spreading, affinity preferences, resource balance) to pick the best.

Longer Answer

  • Requests reserve capacity for scheduling; a pod with no requests can be packed onto overloaded nodes.
  • nodeSelector / node affinity attract pods to nodes with certain labels (GPU nodes, a specific zone); required... is a hard rule, preferred... a soft one.
  • Taints on nodes repel pods unless the pods have matching tolerations: reserve GPU or system nodes, or evict pods from nodes with problems (NoExecute).
  • Pod affinity/anti-affinity co-locate or separate pods; topology spread constraints spread replicas evenly across zones or nodes.

A pod stuck in Pending usually means no node passes the filters; kubectl describe pod shows the reasons.

Key Points

  • Filter then score.
  • Requests reserve capacity.
  • Affinity attracts; taints repel unless tolerated.
  • Topology spread for zones; describe Pending pods.

More most-asked Kubernetes questions

← All Kubernetes questions