What are Kubernetes taints and tolerations, and when do you use them?
Quick Answer
A taint on a node repels pods that do not tolerate it; a matching toleration on a pod lets it schedule onto that tainted node. Together they reserve nodes for specific workloads (GPUs, dedicated tenants) or keep pods off unhealthy nodes.
Detailed Answer
Taints have a key, value, and effect (NoSchedule, PreferNoSchedule, NoExecute). NoExecute even evicts running pods that lack the toleration. Note the direction: taints/tolerations repel (keep pods off), while nodeSelector/affinity attract (pull pods toward) nodes — you often combine both to truly dedicate nodes.
Code Example
kubectl taint nodes gpu-1 gpu=true:NoSchedule # pod: # tolerations: # - key: "gpu" # operator: "Equal" # value: "true" # effect: "NoSchedule"
Interview Tip
Clarify that taints repel while affinity attracts, and that you usually pair both to fully dedicate nodes.