BM: Baca dalam Bahasa Melayu
World K2: Trays & Orders
ReplicaSets keep the count
You will learn: how a ReplicaSet keeps the right number of pods, and how it counts them.
Checked with Kubernetes 1.37 on 31 Oct 2026
The problem
Lunch time. You want 3 trays out, always. One tray slips and falls. Who notices, and who makes a new one?
Pick one answer.
Watch
The board says want 3, see 3. Deleting a pod makes it see 2, so it makes 1 more.
Want 3. See 3. All good.
dev-workerOpen- trays-7tmqp
- trays-nzvvz
dev-worker2Open- trays-cg4fl
A ReplicaSet: The tray counter: keeps the right number of pods with matching labels. counts trays, again and again. Want 3, see 2? It makes 1 more. Tap delete on a tray and watch the board.
Try it
A ReplicaSet has 3 parts: how many (replicas), which trays count (selector), how to make one (template). Here the labels do not match. Fix it.
Fix the manifest, then press Apply.
Hint
The template’s label must match the selector, word for word.Try it
The rush is coming. Ask the ReplicaSet for 5 trays.
kind-dev namespace defaultdev-control-planeOpenManagerNo trays here.
dev-workerOpendev-worker2OpenHint
kubectl scale rs trays --replicas=5 changes the count on the order.Predict
The ReplicaSet wants 3. You start one more pod by hand, with the label app=tray. What happens?
Pick one answer.
Check
kind-dev namespace defaultextra was created, then deleted at once. It matched app=tray, so it made 4. Labels decide what counts.
You did it!
You can now explain how a ReplicaSet keeps the count.
Go deeper (optional)
You will rarely write a ReplicaSet yourself. A Deployment makes them for you, and adds safe updates. That is the next lesson.
Real rep (optional): on a throwaway cluster, apply a ReplicaSet, delete one pod, then run kubectl describe rs trays. Its Events show each new pod.
Bahasa Melayu
Waktu makan tengah hari. Anda mahu 3 dulang keluar, sentiasa. Satu dulang tergelincir dan jatuh. Siapa perasan, dan siapa buat yang baharu?
ReplicaSet mengira dulang, berulang kali. Mahu 3, nampak 2? Ia buat 1 lagi. Tekan delete pada satu dulang dan perhati papan.
ReplicaSet ada 3 bahagian: berapa banyak (replicas), dulang mana dikira (selector), cara buat satu (template). Di sini label tak sepadan. Baiki.
Waktu puncak hampir tiba. Minta ReplicaSet sediakan 5 dulang.
kubectl scale rs trays --replicas=5 tukar bilangan dalam pesanan.ReplicaSet mahu 3. Anda mulakan satu pod lagi dengan tangan, berlabel app=tray. Apa jadi?
extra dicipta, kemudian terus dipadam. Ia sepadan dengan app=tray, jadi jumlahnya 4. Label tentukan apa yang dikira.
Kini anda boleh terangkan cara ReplicaSet jaga bilangan.
You finished this before. Practice is always welcome!
Official docs: Kubernetes: ReplicaSet · kubectl scale
You've learned for 25 minutes. A short break helps your brain.
Sprint done! Great focus. Stretch for a minute?