BM: Baca dalam Bahasa Melayu
World K5: Lunch Rush
Taints, tolerations and spread
You will learn: how to lock a stall, give some trays the key, and spread trays out.
Checked with Kubernetes 1.37 on 31 Oct 2026
The problem
Stall dev-worker2 has the big oven. It is for oven dishes only. But shop trays keep landing there. How do you keep them out?
Pick one answer.
Watch
kind-dev namespace defaultA taint: A lock on a stall. Trays without the key stay away. is a lock on a stall. This one came from kubectl taint nodes dev-worker2 oven=big:NoSchedule. All shop trays went to dev-worker.
Try it
A toleration: A key on a tray. It opens a stall's lock, but does not pull the tray there. is the key, carried by the tray. Hand the oven key to oven-tray. Then place every tray.
Tap a tray, then tap a stall. Or drag the tray.
Waiting trays
Keys (tolerations)
- stall-a
- oven-stall
- Pending
Trays that fit on no stall wait here.
Hint
Tap the key, then tap oven-tray. Now it may enter oven-stall.Predict
A tray has the oven key, but no sign (no nodeSelector). Where can it land?
Pick one answer.
Try it
oven.yaml has both: the key and the sign. Apply it. Then check which stall it chose.
kind-dev namespace defaultdev-control-planeOpenManagerNo trays here.
dev-workerOpen- shop·bcbf7
- shop·tbgr4
- shop·w6dzr
dev-worker2OpenNo trays here.
Hint
Typekubectl apply -f oven.yaml, then kubectl get pod oven -o wide.Watch
Don’t put all trays in one stall. topology spread: Spread trays across stalls, so one closing stall hurts less. keeps stalls even. maxSkew: 1 means stall counts differ by 1 at most. 4 trays, 2 stalls: which split is allowed?
Pick one answer.
In YAML, inside the pod template:
topologySpreadConstraints:
- maxSkew: 1
topologyKey: kubernetes.io/hostname
whenUnsatisfiable: ScheduleAnyway
labelSelector:
matchLabels: { app: shop }Check
True or not? Sort each sentence.
Drag a card into a box. Or tap the card, then tap the box.
You did it!
You can now lock a stall, hand out keys, and spread trays out.
Go deeper (optional)
Effects: NoSchedule, PreferNoSchedule (try to avoid) and NoExecute (also evicts). A minus at the end removes a taint: kubectl taint nodes dev-worker2 oven=big:NoSchedule-. With whenUnsatisfiable: DoNotSchedule, spread becomes a hard rule. Then a locked stall can still count as a domain. Read the docs before you use it.
Real rep (optional): taint a kind worker, then remove it again.
Bahasa Melayu
Node (gerai) dev-worker2 ada ketuhar besar. Ia untuk hidangan ketuhar sahaja. Tapi pod (dulang) kedai asyik mendarat di situ. Macam mana nak halang mereka?
Taint ialah kunci pada gerai. Yang ini datang daripada kubectl taint nodes dev-worker2 oven=big:NoSchedule. Semua pod kedai pergi ke dev-worker.
Toleration ialah anak kunci, dibawa oleh pod. Beri anak kunci ketuhar kepada oven-tray. Kemudian letak setiap pod.
Satu pod ada anak kunci ketuhar, tapi tiada papan tanda (tiada nodeSelector). Di mana ia boleh mendarat?
oven.yaml ada kedua-duanya: anak kunci dan papan tanda. Apply fail itu. Kemudian semak gerai mana yang ia pilih.
kubectl apply -f oven.yaml, kemudian kubectl get pod oven -o wide.Jangan letak semua pod dalam satu gerai. Topology spread jaga gerai seimbang. maxSkew: 1 maksudnya bilangan pod antara gerai beza paling banyak 1. 4 pod, 2 gerai: pembahagian mana yang dibenarkan?
Dalam YAML, di dalam templat pod:
topologySpreadConstraints:
- maxSkew: 1
topologyKey: kubernetes.io/hostname
whenUnsatisfiable: ScheduleAnyway
labelSelector:
matchLabels: { app: shop }
Betul atau tidak? Asingkan setiap ayat.
Kini anda boleh kunci gerai, beri anak kunci, dan sebarkan pod.
You finished this before. Practice is always welcome!
Official docs: Kubernetes: taints and tolerations · Kubernetes: pod topology spread · kubectl taint
You've learned for 25 minutes. A short break helps your brain.
Sprint done! Great focus. Stretch for a minute?