📖 Scenario: You are managing a Kubernetes cluster where certain nodes should only run special workloads. To control this, you will use taints on nodes and tolerations on pods.This helps keep normal workloads off special nodes, like reserving some nodes for high-memory jobs.
🎯 Goal: Learn how to add a taint to a Kubernetes node and create a pod that tolerates that taint so it can be scheduled on that node.
📋 What You'll Learn
Add a taint to a node named special-node with key special, value true, and effect NoSchedule
Create a pod manifest named toleration-pod.yaml that tolerates the taint with the exact key, value, and effect
Verify the pod can be scheduled on the tainted node
💡 Why This Matters
🌍 Real World
Taints and tolerations help Kubernetes cluster admins control which nodes run which workloads, improving resource management and stability.
💼 Career
Understanding taints and tolerations is essential for Kubernetes operators and DevOps engineers to manage workload placement and cluster reliability.
Progress0 / 4 steps
1
Add a taint to the node
Use the kubectl taint nodes command to add a taint with key special, value true, and effect NoSchedule to the node named special-node.
Kubernetes
Hint
This command adds a taint so pods without matching tolerations won't be scheduled on special-node.
2
Create a pod manifest with tolerations
Create a YAML file named toleration-pod.yaml that defines a pod with a toleration for the taint key special, value true, and effect NoSchedule. The pod should run the nginx container.
Kubernetes
Hint
The tolerations section must exactly match the taint's key, value, and effect.
3
Apply the pod manifest
Use kubectl apply -f toleration-pod.yaml to create the pod with the toleration.
Kubernetes
Hint
This command creates the pod that can run on the tainted node.
4
Check pod scheduling on the tainted node
Run kubectl get pods -o wide and verify that the pod named toleration-pod is scheduled on the node special-node. Write the exact command and then the expected output line for the pod.
Kubernetes
Hint
The pod should be listed as running on special-node.
Practice
(1/5)
1. What is the main purpose of a taint in Kubernetes?
easy
A. To repel pods from nodes unless they have matching tolerations
B. To allow pods to run on any node without restrictions
C. To label pods for easier identification
D. To increase node resource limits automatically
Solution
Step 1: Understand what a taint does
A taint is applied to a node to repel pods that do not tolerate it.
Step 2: Compare with other options
Options B, C, and D describe unrelated features: pod scheduling without restrictions, pod labeling, and resource limits, which are not taint functions.
Final Answer:
To repel pods from nodes unless they have matching tolerations -> Option A
A. The pod will be scheduled but evicted immediately
B. The pod will be scheduled on the tainted node
C. The pod will be rejected and not scheduled
D. The pod will ignore the taint and schedule anywhere
Solution
Step 1: Understand the pod toleration
The pod tolerates the taint with matching key, value, and effect, so it can be scheduled on the node.
Step 2: Analyze the taint effect
The taint effect is NoSchedule, which prevents pods without tolerations from scheduling. Since this pod has the matching toleration, it is allowed.
Final Answer:
The pod will be scheduled on the tainted node -> Option B
Quick Check:
Matching toleration allows scheduling despite taint = C [OK]
Hint: Matching toleration lets pod schedule on tainted node [OK]
Common Mistakes:
Ignoring the value match in toleration
Confusing NoSchedule with NoExecute
Assuming tolerations always allow scheduling
4. You applied the taint key=value:NoSchedule to a node, but pods without tolerations are still scheduling on it. What is the most likely cause?
medium
A. Pods have tolerations matching the taint
B. Taints do not affect scheduling
C. The node is in a NotReady state
D. The taint was applied with a typo in the key or value
Solution
Step 1: Check taint correctness
If pods without tolerations schedule on a tainted node, the taint might have a typo or was not applied correctly.
Step 2: Evaluate other options
Pods have tolerations matching the taint means pods tolerate the taint, which contradicts the question. The node is in a NotReady state is unrelated to taints. Taints do not affect scheduling is false because taints do affect scheduling.
Final Answer:
The taint was applied with a typo in the key or value -> Option D
Quick Check:
Incorrect taint syntax causes scheduling errors = B [OK]
Hint: Check taint spelling carefully if pods ignore it [OK]
Common Mistakes:
Assuming taints don't affect scheduling
Ignoring typos in taint keys or values
Confusing node status with taint issues
5. You want to ensure that only pods with a specific toleration can run on a node, and all other pods are evicted if already running. Which taint effect should you use?
hard
A. NoSchedule
B. PreferNoSchedule
C. NoExecute
D. NoEvict
Solution
Step 1: Understand taint effects
NoSchedule prevents new pods without tolerations from scheduling. PreferNoSchedule tries to avoid scheduling but doesn't guarantee. NoExecute evicts existing pods without tolerations and prevents new ones. NoEvict is not a valid effect.
Step 2: Match requirement to effect
Since you want to evict existing pods without tolerations, NoExecute is the correct effect.
Final Answer:
NoExecute -> Option C
Quick Check:
Evict pods without tolerations = NoExecute = D [OK]
Hint: Use NoExecute to evict pods lacking tolerations [OK]
Common Mistakes:
Choosing NoSchedule which doesn't evict existing pods
Confusing PreferNoSchedule with eviction
Using invalid effect NoEvict
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.