Guides
Kubernetes पर Blue-Green vs Canary (आसान भाषा में)
By Ravindra Bagale, DevOps trainer · LinkedIn · Published: · Last updated:
Blue-green: Service selector flip. Canary: छोटी replicas पहले, फिर बढ़ो या abort.
Friends, blue-green flips the door; canary opens it a crack. Chala mitrano — keep the old pods warm until you trust the new ones.
मित्रांनो, blue-green दरवाजा पूर्ण उघडते; canary थोडा. Chala mitrano — जुने pods गरम ठेवा.
मित्रों, blue-green दरवाज़ा पूरा खोलता है; canary थोड़ा। Chala mitrano — पुराने pods गरम रखें।
Quick answer
Hold this vertical picture:
- blue+green.
- Service → blue.
- flip या canary replicas.
- endpoints/errors.
- finish या rollback.
Language: English · मराठी · हिंदी
Blue-green vs canary
दो शैलियाँ क्यों
Release fail; escape चाहिए.
Why: In-place undo छिपाता है.
What: flip vs percent.
How: labels + selector.
Example 1: Blue Deployment
Type this:
mkdir -p /tmp/bgc && printf '%s\n' 'apiVersion: apps/v1' 'kind: Deployment' 'metadata: {name: web-blue}' 'spec:' ' replicas: 2' ' selector: {matchLabels: {app: web, color: blue}}' ' template:' ' metadata: {labels: {app: web, color: blue}}' ' spec: {containers: [{name: web, image: public.ecr.aws/docker/library/nginx:1.27-alpine}]}' > /tmp/bgc/blue.yaml && grep color /tmp/bgc/blue.yaml | head -2
You will see:
selector: {matchLabels: {app: web, color: blue}}
What it means: Blue is the live color today.
Example 2: Green Deployment
Type this:
printf '%s\n' 'apiVersion: apps/v1' 'kind: Deployment' 'metadata: {name: web-green}' 'spec:' ' replicas: 2' ' selector: {matchLabels: {app: web, color: green}}' ' template:' ' metadata: {labels: {app: web, color: green}}' ' spec: {containers: [{name: web, image: public.ecr.aws/docker/library/nginx:1.27-alpine}]}' > /tmp/bgc/green.yaml && grep name /tmp/bgc/green.yaml | head -1
You will see:
metadata: {name: web-green}
What it means: Green sits idle until you flip the Service.
Example 3: Service points to blue
Type this:
printf '%s\n' 'apiVersion: v1' 'kind: Service' 'metadata: {name: web}' 'spec:' ' selector: {app: web, color: blue}' ' ports: [{port: 80}]' > /tmp/bgc/svc.yaml && grep color /tmp/bgc/svc.yaml
You will see:
selector: {app: web, color: blue}
What it means: Flip = change selector to green.
Concept 1: Blue-green
selector बदलें.
Why: Half update भ्रम.
What: patch green.
How: patch blue = rollback.
Example 4: Blue-green flip command
Type this:
printf '%s\n' 'kubectl patch svc web -p "{\"spec\":{\"selector\":{\"app\":\"web\",\"color\":\"green\"}}"'
You will see:
kubectl patch svc web -p "{"spec":{"selector":{"app":"web","color":"green"}}}"
What it means: All traffic moves in one step — Instant flip.
Example 8: Watch endpoints
Type this:
printf '%s\n' 'kubectl get endpoints web -o wide'
You will see:
kubectl get endpoints web -o wide
What it means: After a flip, endpoints must list the new pods.
Example 9: Rollback blue-green
Type this:
printf '%s\n' 'kubectl patch svc web -p "{\"spec\":{\"selector\":{\"app\":\"web\",\"color\":\"blue\"}}"'
You will see:
kubectl patch svc web -p "{"spec":{"selector":{"app":"web","color":"blue"}}}"
What it means: Flip back — old pods still warm.
Concept 2: Canary
थोड़ी नई pods.
Why: Exact % के लिए mesh.
What: 9+1 ≈ 10%.
How: scale 0 = abort.
Example 5: Canary weight idea
Type this:
printf '%s\n' 'canary: 10 percent pods on new version; 90 percent stay on stable'
You will see:
canary: 10 percent pods on new version; 90 percent stay on stable
What it means: Canary = small blast radius first.
Example 6: Two Deployments one Service (canary labels)
Type this:
printf '%s\n' 'Service selector app=web only; both stable and canary pods share app=web' 'Stable also has track=stable; canary has track=canary'
You will see:
Service selector app=web only; both stable and canary pods share app=web
Stable also has track=stable; canary has track=canary
What it means: Replica counts set the approximate percent.
Example 7: Canary scale math
Type this:
printf '%s\n' 'stable replicas=9; canary replicas=1 → about 10 percent'
You will see:
stable replicas=9; canary replicas=1 → about 10 percent
What it means: Exact percent needs a mesh; replica ratio is the beginner path.
Concept 3: चुनाव
capacity vs risk.
Why: गलत चुनाव महँगा.
What: 2× → BG; tight → canary.
How: cleanup.
Example 10: Rollback canary
Type this:
printf '%s\n' 'kubectl scale deploy/web-canary --replicas=0'
You will see:
kubectl scale deploy/web-canary --replicas=0
What it means: Remove canary pods; stable keeps 100%.
Example 11: When to pick which
Type this:
printf '%s\n' 'blue-green: need instant rollback and double capacity ok' 'canary: want gradual risk on one cluster capacity'
You will see:
blue-green: need instant rollback and double capacity ok
canary: want gradual risk on one cluster capacity
What it means: Infosys runbooks pick canary when capacity is tight.
Example 12: Cleanup
Type this:
printf '%s\n' 'kubectl delete -f svc.yaml -f blue.yaml -f green.yaml'
You will see:
kubectl delete -f svc.yaml -f blue.yaml -f green.yaml
What it means: Lab cleanup.
Release card
1 two Deploys 2 Service 3 flip/ratio 4 watch 5 rollback
Suppose: empty endpoints
Labels.
Suppose: wrong %
Replica counts.
Ravindra Bagale's Tip
At TCS and Capgemini, interviewers ask cost: blue-green needs roughly 2× pods during the flip; canary needs only a few extra.
TCS आणि Capgemini मध्ये विचारतात: blue-green flip दरम्यान ~2× pods; canary फक्त थोडी extra.
TCS और Capgemini में पूछते हैं: blue-green flip में ~2× pods; canary सिर्फ थोड़ी extra।
Check yourself (quiz)
Q1. BG switch?
selector
Q2. Canary?
small %
Q3. BG rollback?
back to blue
Q4. Canary rollback?
scale 0
Q5. BG cost?
2× pods
Q6. empty endpoints?
labels
Reading tracking
Mark this guide when you finish. Your browser remembers it on this device.
prepare → flip/canary → measure → finish/rollback.
Did you understand? Let us try it once more.
Frequently asked questions
Blue-green vs rolling update?
Rolling mixes versions in one Deployment; blue-green keeps two and flips.
Exact canary percent?
Service mesh / Ingress weights; replica ratio for labs.
Double cost?
Yes during blue-green overlap.
When canary?
Tight capacity or gradual risk.
Rollback speed?
Blue-green flip is fastest if blue still runs.
Helm?
Same ideas with chart values for colors/weights.