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
- ConfigMaps and Secrets: how do they differ, and how should secrets really be handled?
- What is the difference between resource requests and limits, and what are the QoS classes?
- Describe the Kubernetes architecture: what runs on the control plane and what runs on the nodes?
- How do rolling updates work in a Deployment, and how do you roll back?
- Explain the Service types: ClusterIP, NodePort, LoadBalancer, ExternalName and headless.
- What happens, step by step, when you run kubectl apply for a Deployment?
- Deployment, StatefulSet, DaemonSet, Job and CronJob: when do you use each?
- Liveness, readiness and startup probes: how do you configure them correctly?