Defining Tolerations in Pod Specs
What you'll learn: How to configure pod tolerations so your workloads can land on nodes with specific taints.
Understanding Tolerations
You've learned that taints act like "keep out" signs on nodes. Tolerations are the permission slips that pods present to bypass those restrictions. Without the correct toleration, a pod cannot schedule on a tainted node—even if resources are available.
Think of it like airport security: the taint is the checkpoint, and your toleration is the boarding pass that lets you through.
How Tolerations Work
Tolerations are defined in the pod specification under spec.tolerations. Each toleration must match a corresponding taint's key, value, effect, and operator.
Here's the basic structure:
apiVersion: v1
kind: Pod
metadata:
name: app-pod
spec:
tolerations:
- key: "environment"
operator: "Equal"
value: "production"
effect: "NoSchedule"
containers:
- name: app
image: nginx
This toleration says: "I can tolerate nodes tainted with environment=production:NoSchedule."
Matching Rules
- key and effect must match the taint exactly
- operator can be
Equal(value must match) orExists(any value accepted) - If operator is
Exists, you omit thevaluefield
Example with Exists:
tolerations:
- key: "dedicated"
operator: "Exists"
effect: "NoSchedule"
This matches any dedicated taint with NoSchedule effect, regardless of value.
Tolerate All Taints
For maximum flexibility (use cautiously):
tolerations:
- operator: "Exists"
This pod can schedule on any tainted node.
Key Takeaway: Tolerations in pod specs act as permissions that allow scheduling on tainted nodes by matching the taint's key, value, effect, and operator—enabling precise workload placement alongside node restrictions.