🚫 Taints & Tolerations

April 3, 2026

💡 Taints နဲ့ Tolerations က Node တွေပေါ်မှာ ဘယ် Pod တွေ run ခွင့်ရမလဲ ထိန်းချုပ်ပေးသော Kubernetes scheduling mechanism ပါ။

Taints ဆိုတာဘာလဲ?

Taints သည် Node တစ်ခုပေါ်တွင် သတ်မှတ်ထားသော "ကန့်သတ်ချက်" ဖြစ်သည်။ Node တစ်ခုကို taint လုပ်ထားပါက — ထို node သည် သာမန် Pod တွေကို လက်မခံတော့ဘဲ toleration ရှိသော Pod တွေကိုသာ လက်ခံမည်။ ရိုးရှင်းစွာပြောရရင် — Taints က "ဒီ node မှာ မင်း run ချင်ရင် toleration ယူထားရမယ်" လို့ ပြောတာပါ။

Taints ရဲ့ Structure

<key>=<value>:<effect>

Example:
gpu=true:NoSchedule
env=production:NoExecute

Components:


Taint Effects (သုံးမျိုး)

1️⃣ NoSchedule

2️⃣ PreferNoSchedule

3️⃣ NoExecute


Tolerations ဆိုတာဘာလဲ?

Tolerations သည် Pod တစ်ခုကို tainted node တစ်ခုပေါ်တွင် run ခွင့်ပြုရန် သတ်မှတ်ပေးသော configuration ဖြစ်သည်။ ရိုးရှင်းစွာ — Pod က "ငါ့မှာ ဒီ taint ကို tolerate လုပ်နိုင်တဲ့ immunity ရှိတယ်" လို့ ပြောတာပါ။

Toleration YAML Example

apiVersion: v1
kind: Pod
metadata:
  name: gpu-pod
spec:
  tolerations:
  - key: "gpu"
    operator: "Equal"
    value: "true"
    effect: "NoSchedule"
  containers:
  - name: tensorflow
    image: tensorflow/tensorflow:latest-gpu

ဒီ Pod က gpu=true:NoSchedule taint ရှိတဲ့ node မှာ run နိုင်မယ်။

Toleration Operators


လက်တွေ့ အသုံးချမှုများ

Use Case 1: GPU Nodes သီးသန့်ခွဲရန်

# Node ကို taint လုပ်မယ်
kubectl taint nodes gpu-node-1 gpu=true:NoSchedule

# GPU workload Pod မှာ toleration ထည့်မယ်
tolerations:
- key: gpu
  operator: Equal
  value: "true"
  effect: NoSchedule

ရလဒ်: GPU nodes တွေမှာ ML/AI workloads တွေသာ run မယ်။ သာမန် apps တွေ GPU တွေကို မသုံးစွဲနိုင်ဘူး။

Use Case 2: Production Nodes ကို သီးသန့်ခွဲရန်

# Production nodes
kubectl taint nodes prod-node-1 env=production:NoSchedule

# Production pods မှာသာ toleration
tolerations:
- key: env
  value: production
  effect: NoSchedule

Use Case 3: Node Maintenance

# Node maintenance အတွက် pods တွေကို drain လုပ်မယ်
kubectl taint nodes node-1 maintenance=true:NoExecute

# Running pods အားလုံး evict ဖြစ်သွားမယ်
# Maintenance ပြီးရင် taint ဖယ်မယ်
kubectl taint nodes node-1 maintenance=true:NoExecute-

အသုံးဝင်တဲ့ Commands

# Node မှာ taint ထည့်ရန်
kubectl taint nodes <node-name> <key>=<value>:<effect>

# Taint ဖယ်ရန် (နောက်ဆုံးမှာ - ထည့်)
kubectl taint nodes <node-name> <key>=<value>:<effect>-

# Node ရဲ့ taints တွေကြည့်ရန်
kubectl describe node <node-name> | grep Taints

# အားလုံး nodes ရဲ့ taints
kubectl get nodes -o custom-columns=NAME:.metadata.name,TAINTS:.spec.taints

မှတ်ထားသင့်တဲ့ Key Points ⭐