Scavenger uses blue-green deployment for zero-downtime updates with automatic rollback on failure.
- Blue: Current production deployment (active)
- Green: New deployment (standby)
- Service:
scavengerLoadBalancer switching between blue and green viaslotlabel selector - Manifests:
k8s/blue-green-deployment.yaml
| Script | Purpose |
|---|---|
scripts/blue-green-deploy.sh |
Full deployment pipeline with auto-rollback |
scripts/monitor-deployment.sh |
Standalone deployment health monitor |
- Update Green: Set new image on the green Deployment
- Scale Up: Scale green to match current blue replica count
- Wait Ready:
kubectl rollout statusuntil all green pods pass readiness probes - Smoke Tests: Poll
/healthvia a curl pod (up to 30 attempts × 10s) - Switch Traffic: Patch service selector from
slot: blue→slot: green - Stabilize: Wait 15s for in-flight connections to drain
- Monitor: Run
monitor-deployment.shfor 120s (configurable viaMONITOR_DURATION) - Scale Down Blue: Scale blue to 0 replicas; keep for instant rollback
./scripts/blue-green-deploy.sh scavenger:v1.2.3| Variable | Default | Description |
|---|---|---|
NAMESPACE |
scavenger-prod |
Target namespace |
SMOKE_TEST_URL |
http://localhost/health |
URL for smoke tests |
MONITOR_DURATION |
120 |
Seconds to monitor after traffic switch |
ERROR_THRESHOLD |
10 |
Max errors in tail-100 logs before rollback |
Trigger via GitHub Actions by passing IMAGE_TAG and ENVIRONMENT inputs.
The deploy script traps errors via trap rollback ERR. Rollback is triggered when:
- Smoke tests fail after 30 attempts
monitor-deployment.shdetects error count above threshold
# Switch traffic back to blue
kubectl patch service scavenger \
-n scavenger-prod \
-p '{"spec":{"selector":{"slot":"blue"}}}'
# Restore blue replica count
kubectl scale deployment scavenger-blue --replicas=3 -n scavenger-prodmonitor-deployment.sh runs in-loop after traffic switch and reports:
- Pod readiness count
- Error count from recent logs
- Restart count
- CPU and memory averages (via Prometheus, if available)
# Monitor green slot for 3 minutes
NAMESPACE=scavenger-prod DURATION=180 ./scripts/monitor-deployment.sh green# Check rollout status
kubectl rollout status deployment/scavenger-green -n scavenger-prod
# Tail live logs
kubectl logs -f -l app=scavenger,slot=green -n scavenger-prod
# Check active slot
kubectl get service scavenger -n scavenger-prod \
-o jsonpath='{.spec.selector.slot}'The scavenger-hpa targets scavenger-blue by default. After a successful deployment where green becomes active, update the HPA target:
kubectl patch hpa scavenger-hpa -n scavenger-prod \
-p '{"spec":{"scaleTargetRef":{"name":"scavenger-green"}}}'