MidKubernetes

How does the scheduler decide where a pod runs, and how do you influence it with affinity and taints?

What they are really testing: Whether you know the filter-then-score model and the difference between attracting pods (affinity) and repelling them (taints). Misusing these causes unschedulable pods.

A real interview question

How does the scheduler decide where a pod runs, and how do you influence it with affinity and taints?

What most people say

drag me

The scheduler puts the pod on a node that has enough resources.

Resource fit is only the first filter. It misses affinity, taints/tolerations, and spreading, which are the actual tools for controlling placement and the source of "why is my pod Pending".

The follow-ups they ask next

  • A pod is stuck in Pending. What scheduling causes do you check?

    No node with enough free CPU/memory for the requests, an unsatisfied nodeSelector/affinity, a taint with no matching toleration, or no node in the required zone. kubectl describe pod shows the scheduler reason.

  • What is the difference between node affinity and a taint?

    Affinity is the pod choosing nodes (attraction). A taint is the node repelling pods unless they tolerate it (rejection). You often combine them: taint a node pool and give the intended pods both a toleration and affinity for it.

What the interviewer is listening for

  • Knows filter-then-score
  • Distinguishes affinity (attract) from taints (repel)
  • Uses spread/anti-affinity for resilience

What sinks the answer

  • Only "enough resources"
  • Confuses affinity and taints
  • No idea why a pod is Pending

If you genuinely do not know

Say this instead of freezing. Reasoning out loud from what you do know beats silence every single time, and a good interviewer is listening for exactly that.

The scheduler [filters nodes that cannot run the pod (resources, selectors, taints), then scores and picks the best]. Affinity [attracts: nodeSelector/node affinity, plus pod affinity/anti-affinity to co-locate or spread]. Taints [repel pods unless they tolerate, to reserve nodes]. For resilience [spread replicas across nodes/zones]. Most Pending pods [fail one of these filters].

Keep going with kubernetes

All 336 cloud engineer questions

Knowing the answer is not the same as recalling it under pressure

Sign in to send the questions you fumble to spaced recall, so they come back right before you would forget them, and learn the concepts behind them with hands-on labs.

Start free