Kubernetes Scheduling | Taints, Tolerations, Node Affinity & Pod Anti-Affinity (Hands-On Demo)

Опубликовано: 21 Март 2026
на канале: TechOps Tutorials
88
6

Kubernetes scheduling decides where your Pods run — and in real production clusters, this decision is controlled using taints, tolerations, node affinity, and pod anti-affinity.

In this hands-on tutorial, we explore Kubernetes scheduler behavior step by step using a real multi-node cluster, not Minikube.

You’ll learn:
✔ Why control plane nodes are protected by default taints
✔ How taints reserve worker nodes for specific workloads
✔ How tolerations allow Pods to run on tainted nodes
✔ How Node Affinity works for advanced node selection
✔ How Pod Anti-Affinity spreads Pods across nodes
✔ Why Pods go into Pending state in real clusters
✔ How to verify scheduler decisions using kubectl -o wide

📌 Demo performed on a multi-node kubeadm cluster to reflect real production behavior.

This video is ideal for:
Kubernetes beginners
System Administrators
DevOps Engineers
CKA exam aspirants

📌 Watch the Full Kubeadm Labs Playlist:
If you want to continue learning and building real multi-node Kubernetes clusters, check out our full playlist: [   • Kubernetes Real-World Labs (kubeadm)  ]

📌 Key Commands Used
Check nodes and roles
kubectl get nodes

View node taints
kubectl describe node k8s-master | grep -i taint

Taint a worker node
kubectl taint nodes k8s-worker reserved=true:NoSchedule

Deploy Pod without toleration
kubectl apply -f pod.yaml

Verify Pod scheduling
kubectl get pods -o wide

Deploy Pod with toleration
kubectl apply -f tolerant-pod.yaml

Show node labels
kubectl get nodes -L disktype

Add labels to nodes
kubectl label nodes k8s-worker disktype=hdd
kubectl label nodes k8s-worker2 disktype=ssd

Deploy Pod with Node Affinity
kubectl apply -f affinity-pod.yaml

Deploy Deployment with Pod Anti-Affinity
kubectl apply -f web-deploy.yaml

Watch Pods in real time
kubectl get pods -w

Describe Pod to troubleshoot Pending state
kubectl describe pod pod-name

Cleanup
kubectl delete -f web-deploy.yaml
kubectl delete all --all

📚 Chapters
0:00 - 🚀 Intro: Kubernetes Scheduling Deep Dive
0:43 - 🗺️ Session Overview and Goals
1:38 - ⚖️ Node Selector vs Node Affinity

2:52 - 🏗️ Hard vs Soft Affinity Rules
4:00 - 🛡️ Pod Anti-Affinity for High Availability

5:08 - 📋 Hands-on Demo Roadmap
6:10 - 🔐 Control Plane Taint Verification
7:19 - 🚫 Tainting Worker Nodes
9:24 - 🔓 Deploying Pods with Tolerations
12:07 - 🎯 Node Affinity Production Demo

17:40 - 🌐 Implementing Pod Anti-Affinity
19:44 - ⚠️ Testing Replica Scaling Limits
21:01 - 🔍 Troubleshooting Pending Pods
21:44 - 🧹 Resource Cleanup and Summary
22:56 - 👋 Conclusion and Next Steps

👍 If this helped you, like the video
📌 Subscribe for more Kubernetes & DevOps tutorials
💬 Drop your questions in the comments

#Kubernetes #DevOps #KubernetesScheduling #CKA #CloudNative