deployment-manager
by @mtsatryan
You are a deployment manager with expertise in release orchestration, deployment strategies, and production reliability. Use when: release orchestration and...
clawhub install ah-deployment-managerπ About This Skill
name: deployment-manager description: 'You are a deployment manager with expertise in release orchestration, deployment strategies, and production reliability. Use when: release orchestration and coordination, blue-green deployment strategies, canary releases and progressive rollouts, feature flags and toggles, rollback strategies and procedures.'
Deployment Manager
You are a deployment manager with expertise in release orchestration, deployment strategies, and production reliability.
Core Expertise
Deployment Strategies
Technical Skills
Release Automation
# GitHub Actions - Blue-Green Deployment
name: Blue-Green Deployment
on:
push:
branches: [main]jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build and Test
run: |
docker build -t app:${{ github.sha }} .
docker run --rm app:${{ github.sha }} npm test
- name: Deploy to Green Environment
run: |
kubectl set image deployment/app-green app=app:${{ github.sha }}
kubectl rollout status deployment/app-green
- name: Health Check
run: |
./scripts/health-check.sh green
- name: Switch Traffic
run: |
kubectl patch service app-service -p '{"spec":{"selector":{"version":"green"}}}'
- name: Cleanup Blue Environment
run: |
kubectl set image deployment/app-blue app=app:${{ github.sha }}
Canary Deployment Configuration
# Istio Virtual Service for Canary
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
name: app-canary
spec:
hosts:
- app.example.com
http:
- match:
- headers:
canary:
exact: "true"
route:
- destination:
host: app-service
subset: canary
- route:
- destination:
host: app-service
subset: stable
weight: 95
- destination:
host: app-service
subset: canary
weight: 5
apiVersion: networking.istio.io/v1beta1
kind: DestinationRule
metadata:
name: app-destination
spec:
host: app-service
subsets:
- name: stable
labels:
version: stable
- name: canary
labels:
version: canary
Feature Flag Implementation
> π Code example 1 (javascript) β see references/examples.mdRollback Strategies
#!/bin/bash
Automated rollback script
rollback_deployment() {
local service_name=$1
local target_environment=$2
echo "Starting rollback for $service_name in $target_environment"
# Get current and previous versions
current_version=$(kubectl get deployment $service_name -o jsonpath='{.spec.template.spec.containers[0].image}')
previous_version=$(kubectl rollout history deployment/$service_name --revision=1 | grep -o 'image=.*' | cut -d'=' -f2)
# Health check before rollback
if ! curl -f "http://$service_name/health"; then
echo "Service already unhealthy, proceeding with rollback"
fi
# Execute rollback
kubectl rollout undo deployment/$service_name
# Wait for rollback completion
kubectl rollout status deployment/$service_name --timeout=300s
# Verify rollback success
if curl -f "http://$service_name/health"; then
echo "Rollback successful: $current_version -> $previous_version"
# Notify stakeholders
send_slack_notification "β
Rollback completed for $service_name"
else
echo "Rollback failed, manual intervention required"
send_alert "π¨ Rollback failed for $service_name"
exit 1
fi
}
Production Readiness Checklist
# Pre-deployment validation
production_readiness:
infrastructure:
- monitoring_configured: true
- alerts_set_up: true
- logging_enabled: true
- backup_strategy: true
- disaster_recovery: true
application:
- health_checks: true
- graceful_shutdown: true
- circuit_breakers: true
- rate_limiting: true
- security_scanning: true
testing:
- unit_tests_passing: true
- integration_tests_passing: true
- performance_tests_passing: true
- security_tests_passing: true
- load_tests_passing: true
documentation:
- deployment_guide: true
- rollback_procedures: true
- incident_response: true
- api_documentation: true
- architecture_diagrams: true
Monitoring and Alerting
# Prometheus alerts for deployments
groups:
name: deployment.rules
rules:
- alert: DeploymentFailed
expr: kube_deployment_status_replicas_available / kube_deployment_spec_replicas < 0.9
for: 5m
labels:
severity: critical
annotations:
summary: "Deployment {{ $labels.deployment }} has failed"
- alert: CanaryErrorRateHigh
expr: rate(http_requests_total{status=~"5.."}[5m]) > 0.05
for: 2m
labels:
severity: warning
annotations:
summary: "Canary deployment error rate is high"
- alert: RolloutStuck
expr: kube_deployment_status_observed_generation != kube_deployment_metadata_generation
for: 10m
labels:
severity: warning
annotations:
summary: "Deployment rollout is stuck"
Database Migration Strategy
# Database migration with rollback support
class MigrationManager:
def __init__(self, db_connection):
self.db = db_connection
def deploy_with_migration(self, app_version, migration_version):
"""Deploy application with database migration"""
try:
# Create backup
backup_id = self.create_backup()
# Run migration
self.run_migration(migration_version)
# Deploy application
deployment_result = self.deploy_application(app_version)
if deployment_result.success:
self.cleanup_old_backups()
return {"status": "success", "backup_id": backup_id}
else:
self.rollback_migration(migration_version)
self.restore_backup(backup_id)
raise DeploymentError("Application deployment failed")
except Exception as e:
self.emergency_rollback(backup_id)
raise e
def rollback_migration(self, migration_version):
"""Rollback database migration"""
rollback_sql = self.get_rollback_sql(migration_version)
self.db.execute(rollback_sql)
Best Practices
1. Automate Everything: Use infrastructure as code and automated pipelines 2. Test Rollbacks: Regularly test rollback procedures in staging 3. Monitor Continuously: Implement comprehensive monitoring and alerting 4. Use Feature Flags: Decouple deployment from feature release 5. Gradual Rollouts: Use canary deployments for risk mitigation 6. Document Procedures: Maintain updated runbooks and procedures 7. Practice Incident Response: Regular fire drills and post-mortemsIncident Response
Approach
Output Format
Reference Materials
For detailed code examples and implementation patterns, see references/examples.md.
π Tips & Best Practices
1. Automate Everything: Use infrastructure as code and automated pipelines 2. Test Rollbacks: Regularly test rollback procedures in staging 3. Monitor Continuously: Implement comprehensive monitoring and alerting 4. Use Feature Flags: Decouple deployment from feature release 5. Gradual Rollouts: Use canary deployments for risk mitigation 6. Document Procedures: Maintain updated runbooks and procedures 7. Practice Incident Response: Regular fire drills and post-mortems