Day 14/40 - Taints and Tolerations in Kubernetes

About this video

### Summary of the Video on Taints, Tolerations, and Node Selectors: 1. **Introduction**: - The video is part of the EKA 2024 series (video #14) by Push. - Focuses on explaining **taints**, **tolerations**, and **node selectors** in Kubernetes. - Aim: To clarify these concepts with both theoretical explanations and practical demos. --- 2. **Taints and Tolerations**: - **Taint**: Applied to a node to restrict which pods can be scheduled on it. - Example: A node specialized for AI workloads might have a taint like `GPU=true`. - **Toleration**: Applied to a pod to allow it to tolerate a node's taint. - Only pods with matching tolerations (e.g., `GPU=true`) can be scheduled on tainted nodes. - **Purpose**: Ensures specific nodes are reserved for specialized workloads (e.g., GPUs for AI tasks). - **Effects**: - **NoSchedule**: Prevents scheduling of new pods without matching tolerations. - **PreferNoSchedule**: Tries to avoid scheduling but does not guarantee it. - **NoExecute**: Evicts existing pods that do not tolerate the taint and prevents new ones. --- 3. **Demo of Taints and Tolerations**: - **Step 1**: Add a taint (`GPU=true:NoSchedule`) to worker nodes using `kubectl taint`. - **Step 2**: Attempt to schedule a pod without toleration → Results in a **pending state** due to untolerated taint. - **Step 3**: Add a toleration (`GPU=true:NoSchedule`) to a new pod → Pod successfully schedules on the tainted node. - **Step 4**: Remove the taint from a node → Pods without toleration can now schedule on that node. --- 4. **Node Selectors**: - **Purpose**: Allows pods to specify which nodes they should run on based on labels. - **How It Works**: - Nodes are labeled (e.g., `GPU=false`). - Pods specify a `nodeSelector` with matching labels (e.g., `GPU=false`). - The pod is scheduled only on nodes with matching labels. - **Limitations**: - Cannot use complex conditions or logical operators (e.g., AND/OR). - Limited flexibility compared to **node affinity**. --- 5. **Demo of Node Selectors**: - **Step 1**: Label a node (e.g., `GPU=false`). - **Step 2**: Create a pod with a `nodeSelector` matching the label. - **Step 3**: Pod is scheduled only on nodes with the matching label. - **Step 4**: If no nodes have the label, the pod remains in a **pending state**. --- 6. **Key Differences Between Taints/Tolerations and Node Selectors**: - **Taints and Tolerations**: - Restrictive: Nodes decide which pods they accept. - Focus: Prevent unwanted pods from being scheduled. - **Node Selectors**: - Directive: Pods decide which nodes they want to run on. - Focus: Ensure pods are scheduled on specific nodes. --- 7. **Advanced Scheduling Concepts**: - **Node Affinity/Anti-Affinity**: - More flexible than node selectors. - Allows complex conditions (e.g., logical AND/OR) for pod placement. - Covered in the next video. --- 8. **Practical Use Cases**: - Specialized nodes for specific workloads (e.g., AI, GPUs). - Preventing non-system workloads from running on control plane nodes. - Ensuring efficient resource utilization in production environments. --- 9. **Assignment and Community Engagement**: - An assignment task is available in the GitHub repository (Day 14 folder). - Encourages viewers to practice taints, tolerations, and node selectors. - Support available via Discord or YouTube comments. --- 10. **Call to Action**: - Request for 200 comments and 200 likes within 24 hours. - Next video will be published after achieving the target or within 24 hours. --- ### Key Takeaways: - **Taints and Tolerations**: Control which pods can run on specific nodes. - **Node Selectors**: Allow pods to choose nodes based on labels. - **Node Affinity/Anti-Affinity**: Provides advanced scheduling capabilities (to be covered next). - Practical demos reinforce understanding of these concepts.


Course: Certified Kubernetes Administrator Full Course For beginners | CKA 2025

This playlist contains the complete CKA series for beginners, based on the latest 2025 curriculum. It includes 40+ videos with hands-on demos, assignments, and exam-based scenarios. We will cover everything from the basics to the Advanced, including fundamental concepts such as Docker, containers, Docker storage and networking, DNS, etc.

View Full Course