> For the complete documentation index, see [llms.txt](https://dev7days.gitbook.io/dev7days/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dev7days.gitbook.io/dev7days/scheduling/taints-and-tolerations.md).

# Taints and Tolerations

Describe about Taints and Tolerations

Taint is like a spray the we set set on `Node` after we spray on the `Node`  we need to set toleration on `Pod` to make it can tolerant in that `Node` \
\
Example

<img src="https://2166680554-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FP9VzT74ziIucCaJgfreE%2Fuploads%2F1S9OGypKKr5OXPWQJvvc%2Ffile.excalidraw.svg?alt=media&amp;token=9d9daa0d-897d-46c7-8e6b-17d333664760" alt="" class="gitbook-drawing">

From this example you will see `Node 1` has taint blue and `Node 2 , Node 3` has taint green.

So the Pod that tolerant for blue is A then Pod A will created on Node 1  but Pod B, C, and D it tolerant for green then it will got to Node 2 and Node 3 in order.

**CheatSheet Command**

1. Taint Node: `kubectl taint nodes <node_name> <key>=<value>:<taint_effect>` \
   \
   There are 3 type of taint effect: **NoSchedule**,  **PreferNoSchedule** and **NoExecute**
2. Add the tolerant on Pod:

```yaml
# Pod Template
apiVersion: v1
kind: Pod
metadata:
  name: myapp-pod
spec:
  containers:
  - name: nginx-container
    image: nginx
  tolerations:
  # all of below value need to have double quote
  - key: "app"  
    operator: "Equal" 
    value: "blue"
    effect: "NoSchedule"
```

3. Remove taint from Node: `kubectl taint node <node_name> <taint_name>:<taint_effect>-`

**NoSchedule**

&#x20;It mean avoid to create pod on the Node.

**PreferNoSchedule**\
It will avoid to have pod on the Node but it is not guarantee the Pod will be create on Node even the pod tolerant for taint on that Node

**No Execute**

It will avoid to have pod on the Node and If the existing pod does not tolerant for the taint it will be evict
