Professional Documents
Culture Documents
Lab15 - Kubernetes Taints and Tolerations
Lab15 - Kubernetes Taints and Tolerations
Lab15 - Kubernetes Taints and Tolerations
Introduction
Node affinity, is a property of Pods that attracts them to a set of nodes (either as a preference
or a hard requirement). Taints are the opposite -- they allow a node to repel a set of pods.
Tolerations are applied to pods, and allow (but do not require) the pods to schedule onto
nodes with matching taints.
Taints and tolerations work together to ensure that pods are not scheduled onto inappropriate
nodes. One or more taints are applied to a node; this marks that the node should not accept
any pods that do not tolerate the taints.
In this Lab, you will learn below items:
Objective:
• Taint Nodes
• View Taints
• Create Tolerations
• Remove Taints
• Cleanup
1.1 Let us taint the nodes to noschedule, by executing the below command.
Output:
Output:
1.3 Let us create a pod with out any toleration, by executing the below command.
1.4 Let us verify the pod details, by executing the below command.
Output:
Output:
Note: It tells us that the POD could not find a node without taint that it didn’t tolerate.
1.7 Let us verify if the pod is running on the kube-master node, by executing the below
command.
Output:
1.8 Let us remove the taints from worker nodes as well, by executing the below command.
Output:
1.12 Let us delete the nginx deployment, by executing the below command.
Output:
2. Tolerate Taints
Let see how PODs can be configured to tolerate a taint, i.e. we will configure the PODs to be scheduled
on a node, even if the node has a taint.
2.1 Let us add Taint to worker nodes, by executing the below command.
Output:
2.2 Let us clone the git repository which contains manifests required for this exercise, by executing the
below command.
Output:
# cat -n ~/k8s-taints/pod-tolerations.yaml
Output:
Output:
2.5 Let us verify the pod details, by executing the below command.
Output:
Output:
2.9 Let us verify the pod details, by executing the below command
2.10 Let us check the taint on the worker node and verify that toleration does not match the taint of
worker nodes
3. Let us migrate running PODs from a Nodes that are already running on a node by applying a taint
with “NoExecute“effect on the node.
Output:
3.1 Let us remove taint on worker nodes, by executing the below command.
Output:
3.4 Let us add NoSchedule taint on the master and NoExecute taint on worker nodes
Output:
3.5 Verify that the PODs running on kube-node2 are terminated and placed in pending state.
Note:A taint with “NoExecute“ effect will terminate any running POD that has no matching toleration
3.6 The POD is pending since it cannot find a node without taint
3.9 Let us remove the taint of the Worker nodes, by executing the below command.
4.1 Let us verify there are no taints on any nodes, by executing the below command.