🚫 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:
- key — Taint ရဲ့အမည် (e.g., gpu, env, dedicated)
- value — တန်ဖိုး (e.g., true, production)
- effect — ဘာဖြစ်မလဲ (NoSchedule, PreferNoSchedule, NoExecute)
Taint Effects (သုံးမျိုး)
1️⃣ NoSchedule
- အသစ် Pod တွေကို ဒီ node မှာ schedule မလုပ်ဘူး
- ရှိပြီးသား running pods တွေကို မထိဘူး
- Toleration ရှိမှသာ အသစ် schedule လုပ်ခွင့်ရမယ်
2️⃣ PreferNoSchedule
- Soft version — မတတ်နိုင် မတတ်ရာမှသာ schedule လုပ်မယ်
- အခြား node မရှိရင် ဒီမှာလဲ schedule လုပ်နိုင်တယ်
- Hard rule မဟုတ်ဘဲ preference ပါ
3️⃣ NoExecute
- အသစ် Pod schedule မလုပ်ဘူး + ရှိပြီးသား pods တွေကိုပါ evict လုပ်မယ်
- Toleration မရှိတဲ့ running pods တွေကို ဖယ်ထုတ်မယ်
- အင်မတန်ပြင်းထန်သော effect — သတိထားရမယ်!
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
- Equal — key, value, effect အားလုံး match ရမယ်
- Exists — key ရှိရုံနဲ့ တန် (value မစစ်)
လက်တွေ့ အသုံးချမှုများ
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 ⭐
- Taints = Node ပေါ်တင် သတ်မှတ်သည် ("ဒီ node က picky ဖြစ်တယ်")
- Tolerations = Pod ပေါ်တင် သတ်မှတ်သည် ("ငါ့မှာ immunity ရှိတယ်")
- NoSchedule = အသစ်တွေ မလာစေဘူး
- PreferNoSchedule = မတတ်နိုင်မှ လာခွင့်ပေး
- NoExecute = အသစ်မလာစေဘူး + ရှိပြီးသားကို ဖယ်မယ်
- Master node မှာ default taint ရှိတယ် — node-role.kubernetes.io/master:NoSchedule
- Taints/Tolerations က node affinity နဲ့ ကွဲတယ် — affinity က "ငါဒီမှာ run ချင်တယ်", taints က "မင်းမလာခွင့်ဘူး"