How to avoid other pods from being scheduled on your node in Kubernetes

Taints on nodes repel pods. Tolerations on pods let them ignore specific taints. Together they give you control over scheduling. Taint effects NoSchedule — pods without a matching toleration won’t be scheduled on the node. PreferNoSchedule — the scheduler avoids the node but will use it if there’s nowhere else. NoExecute — pods without a matching toleration are evicted and won’t be rescheduled there. Applying a taint kubectl taint nodes node1 type=db:NoSchedule This prevents any pod from being scheduled on node1 unless it has a toleration for type=db. ...

Kubernetes Tolerations

Taints and tolerations work together to control which pods land on which nodes. Taints go on nodes and repel pods. Tolerations go on pods and let them ignore specific taints. Taint effects There are three effects: NoSchedule — pods without a matching toleration won’t be scheduled on the node. Existing pods are unaffected. PreferNoSchedule — the scheduler avoids the node but will use it if there’s nowhere else. NoExecute — pods without a matching toleration are evicted from the node and won’t be rescheduled there. Applying taints # Add a taint kubectl taint nodes node1 example-key=example-value:NoSchedule # Remove a taint kubectl taint nodes node1 example-key=example-value:NoSchedule- # Multiple taints at once kubectl taint nodes node1 key1=value1:NoSchedule key2=value2:PreferNoSchedule View taints on a node: ...