Skip to content

๐Ÿ”„ 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)

  1. ๐Ÿ”ต๐Ÿ”ด Blue-Green Switch:
  2. Click "Switch to Green" button
  3. Watch all pods become green instantly
  4. Experience zero-downtime deployment

  5. ๐Ÿ“ˆ Progressive Rollout:

  6. Click "Progressive Rollout" button
  7. Observe pods gradually change from blue to green
  8. See controlled, gradual deployment

  9. ๐ŸŽฏ Canary Testing:

  10. Click "Canary Deployment" button
  11. See 2 green pods among 8 blue pods
  12. Experience safe testing with minimal risk

  13. ๐Ÿ”„ Reset to 50/50:

  14. Click "Reset to 50/50" button
  15. Return to balanced state with 5 blue and 5 green pods

Step 5: Self-Healing Demonstrations (5 minutes)

  1. ๐Ÿ—ก๏ธ Kill Pod Test:
  2. Click "๐Ÿ—ก๏ธ Kill Pod" button on any pod
  3. Watch the pod disappear
  4. Observe Kubernetes recreate it automatically

  5. ๐Ÿ›ก๏ธ Health Monitoring:

  6. Monitor real-time health status updates
  7. See color-coded status indicators
  8. 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:

  1. 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! ๐Ÿ”„