Use when implementing zero-downtime deployments, setting up blue-green deployment strategies, managing traffic switching between versions, or testing new versions before full rollout - focuses on deployment strategies for production safety
☐ Learn the blue-green concept ☐ Identify infrastructure requirements ☐ Plan deployment workflow ☐ Define success criteria for version switch
Blue-Green concept:
Benefits:
☐ Deploy new version (creates new revision) ☐ Test new revision with direct URL ☐ Gradually shift traffic to new revision ☐ Monitor metrics during shift
Deploy new version without traffic:
# Deploy new revision with zero traffic
gcloud run deploy myapp \
--image gcr.io/PROJECT_ID/myapp:v2.0.0 \
--no-traffic \
--region us-central1
# Get revision name
gcloud run revisions list --service myapp --region us-central1
Test new revision:
# Get direct URL to new revision
REVISION_URL=$(gcloud run revisions describe REVISION_NAME \
--service myapp \
--region us-central1 \
--format="value(status.url)")
# Test new revision
curl $REVISION_URL/health
Gradual traffic shift:
# Shift 10% traffic to new version (canary)
gcloud run services update-traffic myapp \
--to-revisions REVISION_NEW=10,REVISION_OLD=90 \
--region us-central1
# If successful, shift 50%
gcloud run services update-traffic myapp \
--to-revisions REVISION_NEW=50,REVISION_OLD=50 \
--region us-central1
# If still successful, shift 100%
gcloud run services update-traffic myapp \
--to-revisions REVISION_NEW=100 \
--region us-central1
Instant rollback if needed:
# Revert all traffic to old version
gcloud run services update-traffic myapp \
--to-revisions REVISION_OLD=100 \
--region us-central1
☐ Deploy new version with minimal traffic (1-5%) ☐ Monitor error rates and latency ☐ Gradually increase traffic percentage ☐ Complete rollout or rollback based on metrics
Canary deployment steps:
# Step 1: Deploy with 5% traffic
gcloud run services update-traffic myapp \
--to-revisions new=5,old=95
# Step 2: Monitor for 15 minutes
# Check error rate, latency, user feedback
# Step 3: If good, increase to 25%
gcloud run services update-traffic myapp \
--to-revisions new=25,old=75
# Step 4: If good, increase to 50%
gcloud run services update-traffic myapp \
--to-revisions new=50,old=50
# Step 5: If good, complete rollout
gcloud run services update-traffic myapp \
--to-revisions new=100
# If issues at any step, rollback
gcloud run services update-traffic myapp \
--to-revisions old=100
☐ Create deployment for green version ☐ Test green deployment with service selector ☐ Update service to route to green ☐ Keep blue deployment for rollback
Blue deployment (current):
apiVersion: apps/v1