Fawkes Dojo Module 10: Deployment Strategies
π― Module Overview
Belt Level: π’ Green Belt - GitOps & Deployment Module: 2 of 4 (Green Belt) Duration: 60 minutes Difficulty: Intermediate Prerequisites:
- Module 9: GitOps with ArgoCD complete
- Understanding of Kubernetes Deployments
- Familiarity with service routing
- Basic knowledge of load balancing
π Learning Objectives
By the end of this module, you will:
- β Understand different deployment strategies and when to use each
- β Implement blue-green deployments with Kubernetes
- β Configure canary deployments with traffic splitting
- β Execute rolling updates with zero downtime
- β Implement recreate deployments for stateful apps
- β Use feature flags for progressive rollouts
- β Choose the right strategy for different scenarios
DORA Capabilities Addressed:
- β CD2: Automate deployment process (advanced)
- β Work in Small Batches
- β Team Experimentation
π Part 1: Deployment Strategy Overview
The Problem: High-Risk Deployments
Traditional "Big Bang" deployment:
Old Version (100% traffic) β SWITCH β New Version (100% traffic)
β
If something breaks:
ALL users affected
Immediate rollback needed
High stress, high risk
Result: Fear of deploying, slow release cycles, weekend deployments
The Solution: Progressive Deployment Strategies
Different strategies for different needs:
| Strategy | Risk | Downtime | Complexity | Best For |
|---|---|---|---|---|
| Recreate | High | Yes | Low | Development, stateful apps |
| Rolling Update | Medium | No | Low | Most applications |
| Blue-Green | Low | No | Medium | Production, quick rollback |
| Canary | Very Low | No | High | Critical apps, gradual rollout |
| A/B Testing | Very Low | No | High | Feature testing, experiments |
π΅π’ Part 2: Blue-Green Deployment
What is Blue-Green?
Run two identical production environments:
- Blue: Current production version
- Green: New version being deployed
Switch traffic from Blue β Green when ready.
βββββββββββββββ
β Users β
ββββββββ¬βββββββ
β
ββββββββΌβββββββββββββββββββββββ
β Load Balancer/Router β
β (Initially β Blue) β
ββββββββ¬βββββββββββββββββββββββ
β
βββββ΄βββββ
β β
ββββΌβββ βββΌββββ
βBlue β βGreenβ
βv1.0 β βv2.0 β
β100% β β 0% β
βββββββ βββββββ
[Deploy & Test Green]
β
ββββββββββββββββββββββββ
β Switch Traffic β
β Blue β Green β
ββββββββββββββββββββββββ
β
βββββββ βββββββ
βBlue β βGreenβ
βv1.0 β βv2.0 β
β 0% β β100% β
βββββββ βββββββ
Benefits
- β Instant rollback (switch back to Blue)
- β Zero downtime
- β Test in production before switching
- β Simple conceptually
Drawbacks
- β 2x infrastructure cost during deployment
- β Database migrations tricky
- β All-or-nothing switch
π οΈ Part 3: Hands-On Lab - Blue-Green Deployment
Step 1: Deploy Blue Environment
Create blue-deployment.yaml:
apiVersion: apps/v1
kind: Deployment
metadata:
name: myapp-blue
labels:
app: myapp
version: blue
spec:
replicas: 3
selector:
matchLabels:
app: myapp
version: blue
template:
metadata:
labels:
app: myapp
version: blue
spec:
containers:
- name: myapp
image: myapp:v1.0
ports:
- containerPort: 8080
env:
- name: VERSION
value: "v1.0-blue"
resources:
requests:
memory: "128Mi"
cpu: "100m"
limits:
memory: "256Mi"
cpu: "200m"
---
apiVersion: v1
kind: Service
metadata:
name: myapp
spec:
selector:
app: myapp
version: blue # Points to blue initially
ports:
- port: 80
targetPort: 8080
type: LoadBalancer
Deploy:
kubectl apply -f blue-deployment.yaml
# Verify
kubectl get pods -l version=blue
kubectl get svc myapp
Step 2: Deploy Green Environment
Create green-deployment.yaml:
apiVersion: apps/v1
kind: Deployment
metadata:
name: myapp-green
labels:
app: myapp
version: green
spec:
replicas: 3
selector:
matchLabels:
app: myapp
version: green
template:
metadata:
labels:
app: myapp
version: green
spec:
containers:
- name: myapp
image: myapp:v2.0 # New version
ports:
- containerPort: 8080
env:
- name: VERSION
value: "v2.0-green"
resources:
requests:
memory: "128Mi"
cpu: "100m"
limits:
memory: "256Mi"
cpu: "200m"
Deploy Green (without switching traffic):
kubectl apply -f green-deployment.yaml
# Verify both running
kubectl get pods -l app=myapp
Step 3: Test Green Environment
Create a test service to access Green directly:
apiVersion: v1
kind: Service
metadata:
name: myapp-green-test
spec:
selector:
app: myapp
version: green
ports:
- port: 80
targetPort: 8080
type: LoadBalancer
Test Green:
kubectl apply -f green-test-service.yaml
# Get test service URL
TEST_URL=$(kubectl get svc myapp-green-test -o jsonpath='{.status.loadBalancer.ingress[0].hostname}')
# Run tests
curl http://$TEST_URL/health
curl http://$TEST_URL/version
# Should return: v2.0-green
# Run load test
ab -n 1000 -c 10 http://$TEST_URL/
Step 4: Switch Traffic to Green
Update the main service selector:
# Patch service to point to green
kubectl patch service myapp -p '{"spec":{"selector":{"version":"green"}}}'
# Verify switch
kubectl get svc myapp -o yaml | grep version
# Should show: version: green
# Test from user perspective
PROD_URL=$(kubectl get svc myapp -o jsonpath='{.status.loadBalancer.ingress[0].hostname}')
curl http://$PROD_URL/version
# Should return: v2.0-green
Step 5: Rollback if Needed
If issues found, instant rollback:
# Switch back to blue
kubectl patch service myapp -p '{"spec":{"selector":{"version":"blue"}}}'
# Verify
curl http://$PROD_URL/version
# Should return: v1.0-blue
# Total rollback time: ~5 seconds!
Step 6: Clean Up Old Version
Once confident in Green:
# Scale down blue
kubectl scale deployment myapp-blue --replicas=0
# Or delete entirely
kubectl delete deployment myapp-blue
kubectl delete service myapp-green-test
π Part 4: Rolling Update Deployment
What is Rolling Update?
Gradually replace pods with new version, one (or few) at a time.
Initial State:
[v1] [v1] [v1] [v1] [v1] (5 pods)
Step 1:
[v1] [v1] [v1] [v1] [v2] (1 pod updated)
β
New pod
Step 2:
[v1] [v1] [v1] [v2] [v2] (2 pods updated)
Step 3:
[v1] [v1] [v2] [v2] [v2] (3 pods updated)
Step 4:
[v1] [v2] [v2] [v2] [v2] (4 pods updated)
Step 5:
[v2] [v2] [v2] [v2] [v2] (All pods updated)
Benefits
- β Zero downtime
- β Gradual rollout (detect issues early)
- β No extra infrastructure needed
- β Built into Kubernetes
Drawbacks
- β Both versions run simultaneously
- β Rollback slower than blue-green
- β May cause issues if versions incompatible
Implementing Rolling Update
apiVersion: apps/v1
kind: Deployment
metadata:
name: myapp
spec:
replicas: 5
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1 # Max 1 extra pod during update
maxUnavailable: 1 # Max 1 pod can be unavailable
selector:
matchLabels:
app: myapp
template:
metadata:
labels:
app: myapp
spec:
containers:
- name: myapp
image: myapp:v2.0
ports:
- containerPort: 8080
livenessProbe:
httpGet:
path: /health
port: 8080
initialDelaySeconds: 10
periodSeconds: 5
readinessProbe:
httpGet:
path: /ready
port: 8080
initialDelaySeconds: 5
periodSeconds: 3
Controlling Rolling Update Speed
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 2 # Update 2 pods at a time
maxUnavailable: 0 # Keep all pods available
# This means:
# - Always maintain at least 5 pods available
# - Can temporarily have up to 7 pods (5 + 2 surge)
# - Faster rollout but more resources used
Conservative rollout:
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
# This means:
# - Update only 1 pod at a time
# - Never reduce capacity
# - Slower but safer
Performing Rolling Update
# Update image version
kubectl set image deployment/myapp myapp=myapp:v2.0
# Watch the rollout
kubectl rollout status deployment/myapp
# Expected output:
Waiting for deployment "myapp" rollout to finish: 1 out of 5 new replicas have been updated...
Waiting for deployment "myapp" rollout to finish: 2 out of 5 new replicas have been updated...
Waiting for deployment "myapp" rollout to finish: 3 out of 5 new replicas have been updated...
Waiting for deployment "myapp" rollout to finish: 4 out of 5 new replicas have been updated...
Waiting for deployment "myapp" rollout to finish: 4 of 5 updated replicas are available...
deployment "myapp" successfully rolled out
# Verify
kubectl get pods -l app=myapp
Pausing and Resuming Rollout
# Start rollout
kubectl set image deployment/myapp myapp=myapp:v2.0
# Pause after first pod
kubectl rollout pause deployment/myapp
# Verify mixed versions
kubectl get pods -l app=myapp -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.spec.containers[0].image}{"\n"}{end}'
# Run smoke tests on new version
# If good, resume
kubectl rollout resume deployment/myapp
# If bad, rollback
kubectl rollout undo deployment/myapp
π¦ Part 5: Canary Deployment
What is Canary?
Release new version to small subset of users first, gradually increase if successful.
Phase 1: 5% canary
ββββββββββββββββββββ
95% β [v1] [v1] [v1] ... (19 pods)
5% β [v2] (1 pod)
Phase 2: 25% canary (if healthy)
βββββββββββββββββββββββββββββββββ
75% β [v1] [v1] [v1] ... (15 pods)
25% β [v2] [v2] [v2] ... (5 pods)
Phase 3: 50% canary
ββββββββββββββββββββ
50% β [v1] [v1] ... (10 pods)
50% β [v2] [v2] ... (10 pods)
Phase 4: 100% canary
ββββββββββββββββββββ
0% β (Blue removed)
100% β [v2] [v2] ... (20 pods)
Benefits
- β Lowest risk (expose to small % first)
- β Real user feedback before full rollout
- β Can monitor metrics for issues
- β Gradual, controlled rollout
Drawbacks
- β Complex to implement correctly
- β Need sophisticated traffic routing
- β Requires monitoring and analysis
Canary with Native Kubernetes
Basic canary using ReplicaSet ratios:
# Deploy baseline (v1.0)
kubectl apply -f - <<EOF
apiVersion: apps/v1
kind: Deployment
metadata:
name: myapp-baseline
spec:
replicas: 19 # 95% of traffic
selector:
matchLabels:
app: myapp
template:
metadata:
labels:
app: myapp
version: v1.0
spec:
containers:
- name: myapp
image: myapp:v1.0
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: myapp-canary
spec:
replicas: 1 # 5% of traffic
selector:
matchLabels:
app: myapp
template:
metadata:
labels:
app: myapp
version: v2.0
canary: "true"
spec:
containers:
- name: myapp
image: myapp:v2.0
---
apiVersion: v1
kind: Service
metadata:
name: myapp
spec:
selector:
app: myapp # Matches both versions
ports:
- port: 80
targetPort: 8080
EOF
Problem with this approach: Traffic split not guaranteed (depends on load balancer).
Canary with Istio (Advanced)
For precise traffic control:
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
name: myapp
spec:
hosts:
- myapp
http:
- match:
- headers:
x-canary:
exact: "true"
route:
- destination:
host: myapp
subset: canary
- route:
- destination:
host: myapp
subset: baseline
weight: 95
- destination:
host: myapp
subset: canary
weight: 5
---
apiVersion: networking.istio.io/v1beta1
kind: DestinationRule
metadata:
name: myapp
spec:
host: myapp
subsets:
- name: baseline
labels:
version: v1.0
- name: canary
labels:
version: v2.0
π¨ Part 6: Recreate Deployment
What is Recreate?
Shut down all old pods, then start new ones.
Phase 1: Running
[v1] [v1] [v1] [v1] [v1]
Phase 2: Terminate all
[ ] [ ] [ ] [ ] [ ] β DOWNTIME
Phase 3: Start new
[v2] [v2] [v2] [v2] [v2]
When to Use
- β Development/test environments
- β Stateful apps that can't run mixed versions
- β Database migrations that break compatibility
- β When downtime is acceptable
Drawbacks
- β Downtime (seconds to minutes)
- β All-or-nothing deployment
Implementation
apiVersion: apps/v1
kind: Deployment
metadata:
name: myapp
spec:
replicas: 3
strategy:
type: Recreate # Simple!
selector:
matchLabels:
app: myapp
template:
metadata:
labels:
app: myapp
spec:
containers:
- name: myapp
image: myapp:v2.0
# Update deployment
kubectl apply -f deployment.yaml
# Observe behavior
kubectl get pods -w
# Output:
myapp-v1-abc 1/1 Running 0 5m
myapp-v1-def 1/1 Running 0 5m
myapp-v1-ghi 1/1 Running 0 5m
myapp-v1-abc 1/1 Terminating 0 5m
myapp-v1-def 1/1 Terminating 0 5m
myapp-v1-ghi 1/1 Terminating 0 5m
myapp-v1-abc 0/1 Terminating 0 5m
myapp-v1-def 0/1 Terminating 0 5m
myapp-v1-ghi 0/1 Terminating 0 5m
myapp-v2-jkl 0/1 Pending 0 0s
myapp-v2-mno 0/1 Pending 0 0s
myapp-v2-pqr 0/1 Pending 0 0s
myapp-v2-jkl 0/1 ContainerCreating 0 1s
myapp-v2-mno 0/1 ContainerCreating 0 1s
myapp-v2-pqr 0/1 ContainerCreating 0 1s
myapp-v2-jkl 1/1 Running 0 10s
myapp-v2-mno 1/1 Running 0 10s
myapp-v2-pqr 1/1 Running 0 10s
π― Part 7: Choosing the Right Strategy
Decision Matrix
| Scenario | Recommended Strategy | Reason |
|---|---|---|
| Development environment | Recreate or Rolling | Fast, simple |
| Stateless web app | Rolling Update or Blue-Green | Zero downtime, safe |
| Critical production app | Canary | Gradual, low risk |
| Microservice | Rolling Update | Standard, works well |
| Database migration | Blue-Green or Recreate | Handle schema changes |
| Breaking API changes | Blue-Green with versioning | Quick rollback |
| Feature testing | Canary or A/B | Real user feedback |
| Overnight batch job | Recreate | Downtime acceptable |
Example Decision Tree
START
β
βΌ
Can you accept downtime?
β
ββ YES β Recreate β
β
ββ NO
β
βΌ
Is this super critical?
β
ββ YES β Canary π¦
β
ββ NO
β
βΌ
Need instant rollback?
β
ββ YES β Blue-Green π΅π’
β
ββ NO β Rolling Update π
πͺ Part 8: Practical Exercise
Exercise: Implement Multiple Deployment Strategies
Objective: Deploy same application using 3 different strategies
Scenario: You have a web application with:
- Frontend (stateless)
- API (stateless)
- Database (stateful)
Requirements:
- Deploy frontend with Blue-Green
- Deploy API with Canary (10% β 50% β 100%)
- Deploy database with Recreate (maintenance window)
- Document decision reasoning
- Demonstrate rollback for each
Starter Template:
# frontend-bluegreen.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: frontend-blue
# TODO: Complete blue-green setup
---
# api-canary.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: api-baseline
# TODO: Complete canary setup
---
# database-recreate.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: database
spec:
strategy:
type: Recreate
# TODO: Complete recreate setup
Validation Criteria:
- [ ] Frontend: Blue and Green deployed, traffic switchable
- [ ] API: Canary at 10%, metrics monitored, promotable
- [ ] Database: Recreate strategy, downtime measured
- [ ] All: Rollback procedures documented and tested
- [ ] Decision matrix: Justify each strategy choice
π Part 9: Knowledge Check
Quiz Questions
-
What is the main benefit of Blue-Green deployment?
-
[ ] Lowest cost
- [x] Instant rollback
- [ ] No infrastructure changes
-
[ ] Automatic testing
-
In a Rolling Update, what does maxSurge: 2 mean?
-
[ ] Maximum 2 pods total
- [ ] Update 2 pods per minute
- [x] Can have 2 extra pods temporarily during update
-
[ ] Must have 2 pods available
-
When should you use Recreate strategy?
-
[ ] Production critical apps
- [ ] Never, it's deprecated
- [x] When downtime is acceptable or for incompatible versions
-
[ ] Only for initial deployment
-
What's the primary advantage of Canary deployment?
-
[ ] Fastest deployment
- [ ] Simplest to implement
- [x] Lowest risk with gradual rollout
-
[ ] Requires least infrastructure
-
In Blue-Green, when do you delete the Blue environment?
-
[ ] Immediately after switching
- [ ] Never
- [x] After Green is validated in production
-
[ ] Before deploying Green
-
What's required for precise canary traffic control?
-
[ ] Multiple data centers
- [x] Advanced routing (like Istio or ingress controller)
- [ ] Minimum 100 pods
-
[ ] Manual intervention
-
Which strategy has the highest infrastructure cost during deployment?
-
[x] Blue-Green
- [ ] Rolling Update
- [ ] Canary
-
[ ] Recreate
-
What's the main drawback of Rolling Update?
- [ ] Requires downtime
- [ ] Very complex
- [x] Both versions run simultaneously
- [ ] Can't rollback
Answers: 1-B, 2-C, 3-C, 4-C, 5-C, 6-B, 7-A, 8-C
π― Part 10: Module Summary & Next Steps
What You Learned
β Deployment Strategies: Blue-Green, Rolling, Canary, Recreate β Blue-Green: Instant rollback with parallel environments β Rolling Update: Gradual replacement with zero downtime β Canary: Progressive rollout with risk mitigation β Decision Making: Choose right strategy for scenario β Implementation: Hands-on with Kubernetes
DORA Capabilities Achieved
- β CD2: Automated deployment (advanced patterns)
- β Work in Small Batches: Gradual rollouts
- β Team Experimentation: Safe testing in production
Key Takeaways
- No one-size-fits-all - Different apps need different strategies
- Balance risk and complexity - More safety = more complexity
- Zero downtime is achievable - Most strategies support it
- Rollback is critical - Always have an escape hatch
- Test in production - Canary and Blue-Green enable this safely
Real-World Impact
"After implementing deployment strategies:
- Deployment confidence: 60% β 95%
- Production incidents from deploys: 15 per month β 2 per month
- Rollback time: 30 minutes β 30 seconds (Blue-Green)
- User impact from bad deploys: 100% β 5% (Canary)
We now deploy during business hours with confidence."
- Platform Team, Financial Services
π Additional Resources
Documentation
Tools
- Flagger - Progressive delivery operator
- Spinnaker - Multi-cloud CD platform
- Argo Rollouts - Advanced K8s deployments
π Module Completion
Assessment Checklist
-
[ ] Conceptual Understanding
-
[ ] Explain each deployment strategy
- [ ] Choose appropriate strategy for scenarios
-
[ ] Understand trade-offs
-
[ ] Practical Skills
-
[ ] Implement Blue-Green deployment
- [ ] Configure Rolling Update parameters
- [ ] Set up basic Canary deployment
-
[ ] Execute rollback procedures
-
[ ] Hands-On Lab
-
[ ] Deploy using multiple strategies
- [ ] Switch traffic between versions
-
[ ] Perform successful rollback
-
[ ] Quiz
- [ ] Score 80% or higher (6/8 questions)
Certification Credit
Upon completion, you earn:
- 5 points toward Green Belt certification (50% complete)
- Badge: "Deployment Strategist"
- Skill Unlocked: Advanced Deployment Patterns
ποΈ Green Belt Progress
Green Belt: GitOps & Deployment
ββββββββββββββββββββββββββββββββββββββββββ
Module 9: GitOps with ArgoCD ββββββββββββ 25% β
Module 10: Deployment Strategies ββββββββββββ 50% β
Module 11: Progressive Delivery ββββββββββββ 0%
Module 12: Rollback & Incident ββββββββββββ 0%
ββββββββββββββββββββββββββββββββββββββββββ
Halfway to Green Belt! π
Next Module Preview: Module 11 - Progressive Delivery (Automated canary analysis, metrics-driven rollout, Argo Rollouts)
π Congratulations! You now know how to deploy applications safely using multiple strategies!
Ready for Module 11? Let's learn Progressive Delivery with automated analysis! π
Fawkes Dojo - Where Platform Engineers Are Forged Version 1.0 | Last Updated: October 2025 License: MIT | https://github.com/paruff/fawkes