Taint and Toleration
Taint and Toleration
TAINT AND TOLERATION
controlplane ~ ➜ k get nodes
NAME STATUS ROLES AGE VERSION
controlplane Ready control-plane 44m v1.27.0
node01 Ready <none> 43m v1.27.0
k taint nodes node01 storage=ssd:NoSchedule
=> This will Create a tain on node01, and pods will not be scheduled on it
Create a simple nginx pod
kubectl run --image=nginx
NAME READY STATUS RESTARTS AGE
nginx 0/1 Pending 0 3s
Create a deployment with toleration and see if it runs
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: taint-toleration
name: taint-toleration
spec:
replicas: 1
selector:
matchLabels:
app: taint-toleration
strategy: {}
template:
metadata:
labels:
app: taint-toleration
spec:
containers:
- image: nginx
name: nginx
resources: {}
tolerations:
- key: "storage"
operator: "Equal"
value: "ssd"
effect: "NoSchedule"
status: {}
As you can see in the manifest file in the container spec section:
- key: "storage"
operator: "Equal"
value: "ssd"
effect: "NoSchedule"
And with thi toleration th deployment will run on node01
NAME READY STATUS RESTARTS AGE
nginx 0/1 Pending 0 4m8s
taint-toleration-77d579fb4f-dk6f6 1/1 Running 0 7s
Remove the taint from the node
Follow up the command with hypehn '-'
controlplane ~ ➜ k taint nodes node01 storage=ssd:NoSchedule- node/node01 untainted