💻 Tech
Node affinity and taints and tolerations are concepts in Kubernetes that determine to which node a pod will be scheduled. There are instances where you want to implement both in requirements where:
- Specific pods must be scheduled to specific nodes
- No other pods should be scheduled to those nodes
For example, if we have pods for svc, db, and utils, the requirement is they must be scheduled to their respective nodes: node-svc, node-db, and node-utils. In addition, no other pods should be scheduled to those nodes
Solution 1: Implement Node affinity
- Although there is guarantee that pods that match its node selector to a node’s labels will always be scheduled to that node, there’s no guarantee that no other pods will be scheduled to that node.
Solution 2: Implement Taints and Tolerations
- Although there is guarantee that no other pods will not be scheduled to nodes if those pods don’t have tolerations with the node’s taints, there’s no guarantee that pods with toleration to a node will always be scheduled to that node.
Solution 3: Implement both Node affinity and Taints and Tolerations
- As you would have guessed it, it guarantees that two requirements mentioned above.