Introduction to Taints and Tolerations
What you'll learn: How Kubernetes uses taints to repel pods from nodes and tolerations to allow specific pods to override those restrictions.
The Core Idea
Imagine a VIP section at a concert venue. By default, regular attendees can't enter (the area "repels" them), but people with special passes can get in. Taints work like "No Entry" signs on nodes, preventing most pods from scheduling there. Tolerations are like those special passes that specific pods carry, allowing them to schedule on tainted nodes despite the restriction.
How Taints Work
When you apply a taint to a node, you're essentially marking it with a label that says "pods should avoid me unless they have permission." Taints have three effects:
- NoSchedule: New pods won't be scheduled here
- PreferNoSchedule: Scheduler tries to avoid this node
- NoExecute: Existing pods are evicted if they don't tolerate the taint
How Tolerations Work
A toleration is a property you add to a pod specification that says "I can tolerate this specific taint." When the scheduler sees a tainted node, it checks if the pod has a matching toleration. If yes, the pod can be scheduled there; if no, the pod is repelled.
Common Use Cases
- Dedicating nodes to specific workloads (GPU nodes for ML workloads)
- Isolating problematic or untested applications
- Reserving nodes for critical system components
- Handling node maintenance or upgrades gracefully
Key Takeaway: Taints repel pods from nodes by default, while tolerations act as exceptions that let specific pods schedule on tainted nodes—creating powerful control over workload placement in your cluster.