World map

 

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

You are here: cluster kind-dev namespace default
Two Deployments run: shop-blue and shop-green. The Service selector is app=shop,version=blue, so the client gets menu v1. Terminal output: $ kubectl get deployments NAME READY UP-TO-DATE AVAILABLE AGE shop-blue 2/2 2 2 16s shop-green 2/2 2 2 16s $ kubectl get service shop -o wide NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR shop ClusterIP 10.96.151.105 <none> 80/TCP 16s app=shop,version=blue $ kubectl exec client -- wget -qO- -T 5 http://shop <h1>Kedai Kancil menu v1</h1>

blue/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.

You are here: cluster kind-dev namespace default
Stalls: 3. Trays: 5 (5 ready). Waiting for a stall: 0.
  • shop2/2 ready
dev-control-planeOpenManager

No trays here.

dev-workerOpen
  • client
  • shop·gl7xh
  • shop·68n9z
dev-worker2Open
  • shop·kw9rw
  • shop·nhlrr
Time: +0s (sped up)

Predict

Green has a bug. How fast can you go back to blue?

Pick one answer.

Watch

You are here: cluster kind-dev namespace default
shop-stable has 3 pods and shop-canary has 1. The Service picks all 4 pods, because they all have app=shop. Terminal output: $ kubectl apply -f canary.yaml deployment.apps/shop-canary created $ kubectl rollout status deployment/shop-canary --timeout=120s Waiting for deployment "shop-canary" rollout to finish: 0 of 1 updated replicas are available... deployment "shop-canary" successfully rolled out $ kubectl get deployments NAME READY UP-TO-DATE AVAILABLE AGE shop-canary 1/1 1 1 4s shop-stable 3/3 3 3 20s $ kubectl get endpointslices -l kubernetes.io/service-name=shop NAME ADDRESSTYPE PORTS ENDPOINTS AGE shop-c8v4d IPv4 80 10.244.2.4,10.244.1.3,10.244.2.3 + 1 more... 20s

canary 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).

Error rate per minute
0%6%11%alarmminutes →

v1 (old) v2 (new)

Minute 0

Users who hit a v2 error: 0 (limit 150)

Numbers, minute by minute

No traffic yet.

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.