- Take me to Video Tutorial
In this section, we will take a look at taints and tolerations.
- Pod to node relationship and how you can restrict what pods are placed on what nodes.
-
Use
kubectl taint nodes
command to taint a node.Syntax
$ kubectl taint nodes <node-name> key=value:taint-effect
Example
$ kubectl taint nodes node1 app=blue:NoSchedule
-
The taint effect defines what would happen to the pods if they do not tolerate the taint.
-
There are 3 taint effects
NoSchedule
PreferNoSchedule
NoExecute
- Tolerations are added to pods by adding a
tolerations
section in pod definition.apiVersion: v1 kind: Pod metadata: name: myapp-pod spec: containers: - name: nginx-container image: nginx tolerations: - key: "app" operator: "Equal" value: "blue" effect: "NoSchedule"
Taints and Tolerations do not tell the pod to go to a particular node. Instead, they tell the node to only accept pods with certain tolerations.
- To see this taint, run the below command
$ kubectl describe node kubemaster |grep Taint