๐ Scenario 04: Blue-Green Deployment Hero
"Visual, Interactive Deployment Strategies Defeat Chaos!"
๐ SCENARIO OVERVIEW
The Deployment Challenge
Chaos Agent has discovered that manual deployments are causing service downtime and user complaints! Deployment failures lead to user errors, and there's no rollback capability when things go wrong. Your team needs a visual, interactive way to manage deployment strategies with zero downtime.
The Deployment Hero Solution
Deploy a visual, interactive demonstration showcasing multiple Kubernetes deployment strategies including Blue-Green, Rolling, and Canary deployments with real-time pod management and self-healing capabilities. Experience deployment strategies that ensure zero downtime and instant rollbacks!
What You'll Build
- ๐ Visual & Interactive Deployment Demo with real-time pod visualization
- ๐ต๐ด Blue-Green Deployment Strategy with instant traffic switching
- ๐ Progressive Rollout Strategy with gradual pod replacement
- ๐ฏ Canary Deployment Strategy with safe testing approach
- ๐ก๏ธ Self-Healing Demonstrations with automatic pod recreation
โฑ๏ธ TIME ALLOCATION
| Activity | Duration | Type |
|---|---|---|
| Live Demo (Instructor) | 10 minutes | ๐ Watch |
| Your Deployment Setup | 5 minutes | ๐ ๏ธ Hands-on |
| Interactive Strategy Testing | 15 minutes | ๐ฎ Interactive |
| Self-Healing Demonstrations | 5 minutes | ๐ก๏ธ Testing |
| Total | 35 minutes |
๐ฏ LEARNING OBJECTIVES
By completing this scenario, you will:
โ
Master multiple Kubernetes deployment strategies
โ
Understand zero-downtime deployment techniques
โ
Experience visual deployment management
โ
Learn self-healing and high availability concepts
โ
Implement instant rollback capabilities
โ
Defeat Chaos Agent's deployment downtime attacks! ๐
๐งจ THE CHAOS AGENT'S DEPLOYMENT ATTACK
"Deployment failed! Users are seeing errors! Your manual deployments are causing downtime and user complaints! Your deployment process is a mess!" ๐
What Chaos Agent Exploits: - โ Manual deployments causing service downtime - โ No rollback capability when deployments fail - โ Users experience errors during updates - โ No testing environment for new versions - โ Single point of failure during deployments - โ No visual feedback on deployment progress
๐ฆธโโ๏ธ THE DEPLOYMENT HERO'S RESPONSE
"Not anymore! My visual, interactive deployment strategies will ensure zero-downtime updates and instant rollbacks. Watch as I demonstrate multiple deployment strategies with real-time pod management!" ๐ฆธโโ๏ธ๐
How Deployment Hero Wins: - โ Visual deployment management - Real-time pod visualization - โ Zero-downtime deployments - Blue-green traffic switching - โ Instant rollback capability - One-click reversion - โ Self-healing demonstrations - Automatic pod recreation - โ Multiple strategy support - Blue-green, rolling, canary - โ Interactive controls - Real-time strategy switching - โ Health monitoring - Live status updates
๐ FILE STRUCTURE
scenarios/04-blue-green/
โโโ README.md # This comprehensive guide
โโโ deploy-strategies.sh # Deployment strategy management
โโโ backend/
โ โโโ app.py # Flask API with K8s integration
โ โโโ requirements.txt # Python dependencies
โ โโโ Dockerfile # Backend container
โโโ frontend/
โ โโโ src/ # React TypeScript application
โ โโโ package.json # Node.js dependencies
โ โโโ Dockerfile # Frontend container
โโโ k8s/
โ โโโ blue-deployment.yaml # Blue deployment (stable)
โ โโโ green-deployment.yaml # Green deployment (new)
โ โโโ service.yaml # Load balancer service
โ โโโ rbac.yaml # RBAC permissions
โโโ docker-compose.yml # Local development setup
๐ QUICK START (For Participants)
Prerequisites
- โ Scenario 3 completed (auto-scaling should still be running)
- โ Kubernetes cluster running (Docker Desktop, Minikube, or cloud)
- โ Node.js installed for frontend development
- โ kubectl configured and working
Step 1: Environment Setup (2 minutes)
# Navigate to blue-green scenario
cd scenarios/04-blue-green
# Install backend dependencies
pip3 install -r backend/requirements.txt
# Install frontend dependencies
cd frontend
npm install
cd ..
Step 2: Deploy Blue-Green Demo (3 minutes)
# Apply Kubernetes manifests
kubectl apply -f k8s/
# Start the backend API
cd backend
python app.py &
cd ..
# Start the frontend
cd frontend
npm start &
cd ..
Expected Output:
๐ BLUE-GREEN DEPLOYMENT DEMO STARTING
======================================================================
๐ Creating namespace: deployment-demo
โ
Namespace created
๐ต Deploying blue deployment (stable version)...
โ
Blue deployment ready
๐ด Deploying green deployment (new version)...
โ
Green deployment ready
๐ Creating load balancer service...
โ
Service created
๐ Starting backend API...
โ
Backend API running on port 5000
๐จ Starting frontend application...
โ
Frontend running on port 3000
======================================================================
๐ BLUE-GREEN DEPLOYMENT DEMO READY!
โ
Interactive deployment strategies available!
======================================================================
๐ฏ ACCESS YOUR DEPLOYMENT DEMO:
๐ป Frontend: http://localhost:3000
๐ง Backend API: http://localhost:5000
โธ๏ธ Kubernetes: kubectl get pods -n deployment-demo
Step 3: Access Your Deployment Demo (Immediate)
๐ Frontend Application:
๐ป Primary: http://localhost:3000
๐ง Backend API:
๐ง API: http://localhost:5000
โธ๏ธ Kubernetes Dashboard:
# Check deployment status
kubectl get pods -n deployment-demo
# View services
kubectl get svc -n deployment-demo
# Monitor deployments
kubectl get deployments -n deployment-demo
Step 4: Interactive Deployment Strategies (15 minutes)
- ๐ต๐ด Blue-Green Switch:
- Click "Switch to Green" button
- Watch all pods become green instantly
-
Experience zero-downtime deployment
-
๐ Progressive Rollout:
- Click "Progressive Rollout" button
- Observe pods gradually change from blue to green
-
See controlled, gradual deployment
-
๐ฏ Canary Testing:
- Click "Canary Deployment" button
- See 2 green pods among 8 blue pods
-
Experience safe testing with minimal risk
-
๐ Reset to 50/50:
- Click "Reset to 50/50" button
- Return to balanced state with 5 blue and 5 green pods
Step 5: Self-Healing Demonstrations (5 minutes)
- ๐ก๏ธ Kill Pod Test:
- Click "๐ก๏ธ Kill Pod" button on any pod
- Watch the pod disappear
-
Observe Kubernetes recreate it automatically
-
๐ก๏ธ Health Monitoring:
- Monitor real-time health status updates
- See color-coded status indicators
- Experience automatic health checks
๐ฌ LIVE DEMO WALKTHROUGH (For Instructors)
Demo Script Overview
Part 1: Deployment Chaos Exposed (3 minutes)
# Show deployment failures
./demo-script.sh
What Students See: 1. Manual deployment causing downtime 2. Users experiencing errors 3. No rollback capability 4. "This is deployment chaos!"
Part 2: Deployment Hero Saves the Day (4 minutes)
# Deploy the visual demo
kubectl apply -f k8s/
python backend/app.py &
cd frontend && npm start &
Key Teaching Points: - ๐ Visual deployment management - ๐ Zero-downtime strategies - ๐ Instant rollback capability - ๐ Self-healing demonstrations
Part 3: Interactive Strategy Testing (3 minutes)
- Demonstrate blue-green switching
- Show progressive rollout
- Test canary deployment
- Highlight self-healing
๐ DEPLOYMENT STRATEGIES
1. Blue-Green Deployment
# Blue deployment (stable)
apiVersion: apps/v1
kind: Deployment
metadata:
name: blue-deployment
namespace: deployment-demo
spec:
replicas: 5
selector:
matchLabels:
app: demo-app
version: blue
template:
metadata:
labels:
app: demo-app
version: blue
spec:
containers:
- name: app
image: demo-app:blue
ports:
- containerPort: 8080
# Green deployment (new)
apiVersion: apps/v1
kind: Deployment
metadata:
name: green-deployment
namespace: deployment-demo
spec:
replicas: 0 # Start with 0 replicas
selector:
matchLabels:
app: demo-app
version: green
template:
metadata:
labels:
app: demo-app
version: green
spec:
containers:
- name: app
image: demo-app:green
ports:
- containerPort: 8080
2. Service Configuration
apiVersion: v1
kind: Service
metadata:
name: demo-service
namespace: deployment-demo
spec:
selector:
app: demo-app
version: blue # Initially route to blue
ports:
- port: 80
targetPort: 8080
type: ClusterIP
3. Deployment Strategy Script
#!/bin/bash
# deploy-strategies.sh
case $1 in
"blue-green")
# Switch to blue-green (5 blue, 5 green)
kubectl scale deployment blue-deployment --replicas=5 -n deployment-demo
kubectl scale deployment green-deployment --replicas=5 -n deployment-demo
;;
"green")
# Switch to green (0 blue, 10 green)
kubectl scale deployment blue-deployment --replicas=0 -n deployment-demo
kubectl scale deployment green-deployment --replicas=10 -n deployment-demo
kubectl patch service demo-service -n deployment-demo --type='merge' -p='{"spec":{"selector":{"version":"green"}}}'
;;
"rollout")
# Progressive rollout (3 blue, 7 green)
kubectl scale deployment blue-deployment --replicas=3 -n deployment-demo
kubectl scale deployment green-deployment --replicas=7 -n deployment-demo
;;
"canary")
# Canary deployment (8 blue, 2 green)
kubectl scale deployment blue-deployment --replicas=8 -n deployment-demo
kubectl scale deployment green-deployment --replicas=2 -n deployment-demo
;;
"kill")
# Kill random pod
kubectl get pods -n deployment-demo -o name | shuf -n 1 | xargs kubectl delete
;;
esac
๐งช DEPLOYMENT TESTING
Test 1: Blue-Green Switch
# Switch to green deployment
./deploy-strategies.sh green
# Verify traffic routing
kubectl get endpoints -n deployment-demo
Test 2: Progressive Rollout
# Start progressive rollout
./deploy-strategies.sh rollout
# Watch gradual transition
kubectl get pods -n deployment-demo -w
Test 3: Canary Testing
# Deploy canary version
./deploy-strategies.sh canary
# Test with limited traffic
curl http://demo-service.deployment-demo.svc.cluster.local
Test 4: Self-Healing
# Kill a random pod
./deploy-strategies.sh kill
# Watch automatic recreation
kubectl get pods -n deployment-demo -w
๐ DEPLOYMENT MONITORING
Real-time Pod Visualization
# Watch pod status
kubectl get pods -n deployment-demo -w
# Monitor deployment status
kubectl get deployments -n deployment-demo -w
# Check service endpoints
kubectl get endpoints -n deployment-demo
Health Monitoring
# Check pod health
kubectl describe pods -n deployment-demo
# View application logs
kubectl logs -f deployment/blue-deployment -n deployment-demo
kubectl logs -f deployment/green-deployment -n deployment-demo
Performance Metrics
# Monitor resource usage
kubectl top pods -n deployment-demo
# Check network connectivity
kubectl exec -it deployment/blue-deployment -n deployment-demo -- curl -I http://demo-service
๐ฏ SUCCESS CRITERIA
โ Scenario 04 Complete Checklist:
- โ Blue-green deployment demo deployed successfully
- โ Visual pod management interface working
- โ Blue-green switching operational
- โ Progressive rollout functional
- โ Canary deployment working
- โ Self-healing demonstrations verified
- โ Zero-downtime deployments confirmed
- โ Chaos Agent's deployment attacks defeated! ๐
Key Learning Outcomes:
- โ Multiple Deployment Strategies - Mastered blue-green, rolling, canary
- โ Zero-Downtime Deployments - Implemented seamless updates
- โ Visual Management - Experienced interactive deployment control
- โ Self-Healing - Understood automatic pod recreation
- โ Instant Rollback - Implemented quick reversion capability
- โ Health Monitoring - Applied real-time status tracking
๐ NEXT STEPS
What's Next:
- Scenario 05: GitOps with ArgoCD and Argo Rollouts
Production Deployment Strategies:
- Apply these deployment patterns to production applications
- Implement automated deployment pipelines
- Add comprehensive health monitoring
- Regular deployment strategy testing
๐ TROUBLESHOOTING
Common Deployment Issues:
Issue: Pods not switching colors
# Solution: Check deployment labels
kubectl get pods -n deployment-demo --show-labels
Issue: Service not routing traffic
# Solution: Check service selector
kubectl describe service demo-service -n deployment-demo
Issue: Frontend not connecting to backend
# Solution: Check API connectivity
kubectl exec -it deployment/blue-deployment -n deployment-demo -- curl http://demo-service
Issue: Self-healing not working
# Solution: Check pod events
kubectl get events -n deployment-demo --sort-by='.lastTimestamp'
๐ CONCLUSION
Congratulations! You've successfully defeated Chaos Agent's deployment attacks! ๐
What You've Accomplished:
- โ Implemented multiple deployment strategies (blue-green, rolling, canary)
- โ Created visual, interactive deployment management
- โ Achieved zero-downtime deployments
- โ Built instant rollback capabilities
- โ Demonstrated self-healing and high availability
Key Deployment Takeaways:
- Multiple strategies provide flexibility for different scenarios
- Zero-downtime deployments ensure continuous service availability
- Visual management improves deployment control and understanding
- Self-healing provides automatic recovery from failures
- Instant rollback enables quick recovery from deployment issues
You're now ready for the final challenge: GitOps with ArgoCD! ๐
Remember: In the world of Kubernetes deployments, strategy and automation are your weapons against chaos! ๐