Toleration Operators: Equal and Exists
You'll learn how to use Equal and Exists operators to match taints with different levels of matching precision.
The Two Ways to Match
When defining tolerations in Kubernetes, you can use two operators to match taints on nodes: Equal and Exists. These operators determine how specific your toleration needs to be.
Equal Operator
The Equal operator requires an exact match of both the taint key and value. Think of it like a lock and key—both must match perfectly.
tolerations:
- key: "environment"
operator: "Equal"
value: "production"
effect: "NoSchedule"
This toleration only matches a taint with key environment, value production, and effect NoSchedule. It's precise and restrictive.
Exists Operator
The Exists operator is more flexible—it only checks that the taint key exists, ignoring the value entirely. It's like having a master key that opens any door with a specific lock brand, regardless of the lock's serial number.
tolerations:
- key: "environment"
operator: "Exists"
effect: "NoSchedule"
This tolerates any taint with the key environment and effect NoSchedule, regardless of value (e.g., "production", "staging", "dev").
You can even omit the key entirely to tolerate all taints with a specific effect:
tolerations:
- operator: "Exists"
effect: "NoSchedule"
When to Use Which
Use Equal when you need precise control—only specific workloads on specific nodes. Use Exists for more general tolerations, like system pods that should run on any node with a certain taint category.
Key Takeaway: The Equal operator requires exact key-value-effect matches, while Exists matches any taint with the specified key (or all taints if no key is specified), offering flexible scheduling options.