Kubernetes Scheduling Concepts
September 3, 2026
🎯 Overview - အကျဉ်းချုပ် Kubernetes မှာ Pod တွေကို Node တွေမှာ ဘယ်လို schedule လုပ်မလဲဆိုတာ control လုပ်နိုင်တဲ့ နည်းလမ်း 3 မျိုး: 1️⃣ Node Affinity (Pod က Node ကို ရွေးချယ်တာ) အဓိပ္ပာယ်:
- Pod က "ငါ ဒီ node မျိုးမှာပဲ run ချင်တယ်" လို ပြောတာ
• Pod ရဲ့ preference ဖြစ်တယ်
အသုံးပြုပုံ: - GPU ပါတဲ့ node မှာပဲ ML workload run ချင်တယ်
• SSD disk ရှိတဲ့ node မှာပဲ database run ချင်တယ်
• Production node မှာပဲ prod apps run ချင်တယ်
apiVersion: v1
kind: Pod
metadata:
name: gpu-pod
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: gpu
operator: In
values:
- "true"
containers:
- name: ml-app
image: ml-app:v1
2️⃣ Taint & Toleration (Node က Pod ကို ခွင့်ပြု/ငြင်းပယ်တာ) အဓိပ္ပာယ်:
- Node က "ငါက special node ပါ၊ toleration ရှိတဲ့ pod တွေပဲ လာခွင့်ပြုမယ်" လို ပြောတာ
• Node ရဲ့ restriction ဖြစ်တယ်
အသုံးပြုပုံ: - Master node မှာ user pods တွေ မရောက်စေချင်ဘူး
• Dedicated node တစ်ခု သီးသန့် ထားချင်တယ်
• Special hardware ရှိတဲ့ node ကို protect လုပ်ချင်တယ်
# Node မှာ taint ထည့်တာ
kubectl taint nodes node1 dedicated=gpu:NoSchedule
# Pod က toleration ပေးတာ
apiVersion: v1
kind: Pod
metadata:
name: gpu-pod
spec:
tolerations:
- key: "dedicated"
operator: "Equal"
value: "gpu"
effect: "NoSchedule"
containers:
- name: ml-app
image: ml-app:v1
Taint Effects:
- NoSchedule - pod အသစ်တွေ မရောက်ဘူး
• PreferNoSchedule - တတ်နိုင်ရင် မရောက်စေချင်ဘူး
• NoExecute - ရှိပြီးသား pods တွေကိုပါ ထုတ်မယ်
3️⃣ Pod Affinity/Anti-Affinity (Pod က Pod ကို လိုက်တာ/ရှောင်တာ) အဓိပ္ပာယ်:
- Pod က "ငါ ဒီ pod နဲ့ အတူ run ချင်တယ် / အတူ မ run ချင်ဘူး" လို ပြောတာ
• Pod-to-Pod relationship ဖြစ်တယ် အသုံးပြုပုံ: Pod Affinity (အတူ run ချင်တာ): - Frontend နဲ့ cache အတူတူ node မှာ run ချင်တယ် (latency လျှော့ဖို)
• App နဲ့ sidecar အတူ run ချင်တယ် Pod Anti-Affinity (ခွဲပြီး run ချင်တာ): - Database replicas တွေကို different nodes မှာ သီးခြား run ချင်တယ် (HA အတွက်)
• Same app ရဲ့ pods တွေကို spread လုပ်ချင်တယ် Example - Affinity:
apiVersion: v1
kind: Pod
metadata:
name: frontend
spec:
affinity:
podAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: app
operator: In
values:
- cache
topologyKey: kubernetes.io/hostname
containers:
- name: web
image: nginx
Example - Anti-Affinity:
apiVersion: v1
kind: Pod
metadata:
name: db-replica-1
spec:
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: app
operator: In
values:
- database
topologyKey: kubernetes.io/hostname
containers:
- name: postgres
image: postgres:14
📊 ကွာခြားချက် Summary Table
| Feature | ဘာကို Control လုပ်လဲ | ဘယ်သူ ဆုံးဖြတ်လဲ | Use Case |
| Node Affinity | Pod → Node | Pod က node ကို ရွေးတယ် | GPU, SSD, specific hardware လိုချင်တဲ့ pods |
| Taint/Toleration | Node → Pod | Node က pod ကို filter လုပ်တယ် | Master nodes, dedicated nodes protect လုပ်တာ |
| Pod Affinity | Pod → Pod (အတူ) | Pod က pod နဲ့ နီးချင်တယ် | Latency sensitive apps |
| Pod Anti-Affinity | Pod → Pod (ခွဲမယ်) | Pod က pod နဲ့ ဝေးချင်တယ် | HA, replica spreading |
✅ Node Affinity → SSD node ရွေးဖို
✅ Pod Anti-Affinity → Pods တွေကို ခွဲဖို Scenario 2: ML Training Cluster လိုချင်တာ: - GPU nodes တွေကို dedicated လုပ်ချင်တယ် - ML pods တွေပဲ GPU nodes မှာ run မယ် သုံးရမယ့် Techniques:
✅ Taint on GPU nodes → အခြား pods မရောက်စေဖို
✅ Toleration on ML pods → GPU nodes မှာ run နိုင်ဖို
✅ Node Affinity → GPU node ကို target လုပ်ဖို Scenario 3: Web App with Redis Cache လိုချင်တာ: - Frontend နဲ့ Redis cache အတူတူ node မှာ run မယ် - Latency လျှော့ချင်တယ် သုံးရမယ့် Technique:
✅ Pod Affinity → Frontend က Redis pod နဲ့ အတူ run မယ် 💡 မှတ်သားစရာ Key Points 1. Node Affinity = "Pod က node ကို ရွေးတယ်" (Pull) 2. Taint/Toleration = "Node က pod ကို filter လုပ်တယ်" (Push away) 3. Pod Affinity = "Pod က pod နဲ့ နီးချင်/ဝေးချင်တယ်" (Relationship)
တွဲသုံးလိုရတယ်: - တစ်ခုတည်းသုံးလည်း ရတယ်
• 2-3 ခု တွဲသုံးလည်း ရတယ်
• Complex scheduling requirements အတွက် တွဲသုံးတာ ပိုကောင်းတယ်