Kubernetes Scheduling Concepts

September 3, 2026

🎯 Overview - အကျဉ်းချုပ် Kubernetes မှာ Pod တွေကို Node တွေမှာ ဘယ်လို schedule လုပ်မလဲဆိုတာ control လုပ်နိုင်တဲ့ နည်းလမ်း 3 မျိုး: 1️⃣ Node Affinity (Pod က Node ကို ရွေးချယ်တာ) အဓိပ္ပာယ်:

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 မှာ 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:


3️⃣ Pod Affinity/Anti-Affinity (Pod က Pod ကို လိုက်တာ/ရှောင်တာ) အဓိပ္ပာယ်:

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 AffinityPod → NodePod က node ကို ရွေးတယ်GPU, SSD, specific hardware လိုချင်တဲ့ pods
Taint/TolerationNode → PodNode က pod ကို filter လုပ်တယ်Master nodes, dedicated nodes protect လုပ်တာ
Pod AffinityPod → Pod (အတူ)Pod က pod နဲ့ နီးချင်တယ်Latency sensitive apps
Pod Anti-AffinityPod → Pod (ခွဲမယ်)Pod က pod နဲ့ ဝေးချင်တယ်HA, replica spreading
🎯 လက်တွေ့ ဥပမာ Scenarios Scenario 1: Production Database HA Setup လိုချင်တာ: - DB pods 3 ခု run မယ် - သီးခြား nodes 3 ခုမှာ run မယ် (HA) - SSD nodes မှာပဲ run မယ် သုံးရမယ့် Techniques:
✅ 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 အတွက် တွဲသုံးတာ ပိုကောင်းတယ်