BM: Baca dalam Bahasa Melayu
World K2: Trays & Orders
Blue/green and canary with Deployments
You will learn: blue/green with a Service selector switch, and a canary with replica counts.
Checked with Kubernetes 1.37 on 31 Oct 2026
The problem
Menu version 2 is ready. You want it live in one second. If it is bad, gone in one second. With plain Kubernetes objects, how?
Pick one answer.
Watch
kind-dev namespace defaultblue/green deployment: Two full kitchens. Test the new one, then flip the sign so everyone goes there. Flip back to undo.: two full Deployments run side by side. The Service selector says version=blue, so only blue trays get customers.
Try it
Your turn. service-green.yaml is the same order number, pointing at green. Apply it. Then ask the shop again from client.
kind-dev namespace defaultshop2/2 ready
dev-control-planeOpenManagerNo trays here.
dev-workerOpen- client
- shop·gl7xh
- shop·68n9z
dev-worker2Open- shop·kw9rw
- shop·nhlrr
Hint
kubectl apply -f service-green.yaml, then kubectl exec client -- wget -qO- -T 5 http://shop.Predict
Green has a bug. How fast can you go back to blue?
Pick one answer.
Watch
kind-dev namespace defaultcanary release: A few users get the new version first, like a few customers tasting a new dish. All good? Serve more.: a second Deployment with the same app: shop label, but only 1 tray. The Service picks all 4, so about 1 in 4 customers tastes version 2.
Try it
Real traffic, real errors. Move customers to version 2 step by step. Roll back before 150 of them hit the bug.
Send a few users to v2. Watch the graph. Roll back if errors jump.
Users now: 100% on v1 (old), 0% on v2 (new).
v1 (old) v2 (new)
Minute 0
Users who hit a v2 error: 0 (limit 150)
Numbers, minute by minute
No traffic yet.
Hint
The version 2 line jumps over the alarm line? Press Roll back.Check
Blue/green or canary? Sort each fact.
Drag a card into a box. Or tap the card, then tap the box.
You did it!
You can now run blue/green and canary releases with plain Deployments.
Go deeper (optional)
Where the story breaks: a real tray is a running program. A stall is a whole computer. A replica canary is rough: 1 of 4 is 25%, not 5%. For exact shares, use Gateway API weights (World K3) or Argo Rollouts (World K7).
Real rep (optional): on a throwaway cluster, switch a Service selector, then switch it back.
Bahasa Melayu
Menu versi 2 sudah siap. Anda mahu ia hidup dalam satu saat. Kalau rosak, hilang dalam satu saat. Dengan objek Kubernetes biasa, bagaimana?
Blue/green: dua Deployment penuh berjalan sebelah-menyebelah. Selector Service tulis version=blue, jadi hanya dulang blue dapat pelanggan.
Giliran anda. service-green.yaml ialah nombor pesanan yang sama, tapi tuju ke green. Apply fail itu. Kemudian tanya kedai sekali lagi dari client.
kubectl apply -f service-green.yaml, kemudian kubectl exec client -- wget -qO- -T 5 http://shop.Green ada bug. Secepat mana anda boleh kembali ke blue?
Canary: Deployment kedua dengan label app: shop yang sama, tapi hanya 1 dulang. Service pilih keempat-empatnya, jadi lebih kurang 1 daripada 4 pelanggan rasa versi 2.
Trafik sebenar, ralat sebenar. Alihkan pelanggan ke versi 2 langkah demi langkah. Rollback sebelum 150 orang kena bug.
Blue/green atau canary? Susun setiap fakta.
Kini anda boleh jalankan keluaran blue/green dan canary dengan Deployment biasa.
You finished this before. Practice is always welcome!
Official docs: Kubernetes: Canary deployments (Managing Workloads) · Kubernetes: Service selectors
You've learned for 25 minutes. A short break helps your brain.
Sprint done! Great focus. Stretch for a minute?