deployment-strategies
1
总安装量
1
周安装量
#41478
全站排名
安装命令
npx skills add https://github.com/latestaiagents/agent-skills --skill deployment-strategies
Agent 安装分布
mcpjam
1
claude-code
1
replit
1
windsurf
1
zencoder
1
Skill 文档
Deployment Strategies
Deploy with confidence using progressive delivery and safe rollback.
Strategy Comparison
| Strategy | Risk | Complexity | Rollback Speed | Best For |
|---|---|---|---|---|
| Rolling | Medium | Low | Medium | Standard updates |
| Blue-Green | Low | Medium | Instant | Critical services |
| Canary | Low | High | Fast | High-traffic services |
| Feature Flags | Lowest | Medium | Instant | A/B testing, gradual rollout |
Rolling Deployment
How It Works
Initial: [v1] [v1] [v1] [v1] [v1]
Step 1: [v2] [v1] [v1] [v1] [v1] # Replace 1 pod
Step 2: [v2] [v2] [v1] [v1] [v1] # Replace 2nd pod
Step 3: [v2] [v2] [v2] [v1] [v1] # Continue...
Final: [v2] [v2] [v2] [v2] [v2] # All replaced
Kubernetes Configuration
apiVersion: apps/v1
kind: Deployment
metadata:
name: api-service
spec:
replicas: 5
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1 # Max pods above desired during update
maxUnavailable: 0 # Never reduce below desired count
template:
spec:
containers:
- name: api
image: api-service:v2
readinessProbe:
httpGet:
path: /health
port: 8080
initialDelaySeconds: 5
periodSeconds: 5
livenessProbe:
httpGet:
path: /health
port: 8080
initialDelaySeconds: 15
periodSeconds: 10
Best Practices
â Always set readinessProbe
â Use maxUnavailable: 0 for zero downtime
â Monitor error rates during rollout
â Have rollback command ready
Blue-Green Deployment
How It Works
Before:
âââââââââââââââââââââââââââââââââââââââââââ
â Load Balancer â
â â â
â â¼ â
â [Blue Environment - v1] â Active â
â [Green Environment - idle] â
âââââââââââââââââââââââââââââââââââââââââââ
Deploy to Green:
âââââââââââââââââââââââââââââââââââââââââââ
â Load Balancer â
â â â
â â¼ â
â [Blue Environment - v1] â Active â
â [Green Environment - v2] Testing â
âââââââââââââââââââââââââââââââââââââââââââ
Switch Traffic:
âââââââââââââââââââââââââââââââââââââââââââ
â Load Balancer â
â â â
â â¼ â
â [Blue Environment - v1] Standby â
â [Green Environment - v2] â Active â
âââââââââââââââââââââââââââââââââââââââââââ
Kubernetes Implementation
# Blue deployment (current production)
apiVersion: apps/v1
kind: Deployment
metadata:
name: api-blue
labels:
version: blue
spec:
replicas: 5
template:
metadata:
labels:
app: api
version: blue
---
# Green deployment (new version)
apiVersion: apps/v1
kind: Deployment
metadata:
name: api-green
labels:
version: green
spec:
replicas: 5
template:
metadata:
labels:
app: api
version: green
---
# Service points to active version
apiVersion: v1
kind: Service
metadata:
name: api
spec:
selector:
app: api
version: blue # Switch to 'green' to cutover
ports:
- port: 80
targetPort: 8080
Switch Traffic
# Cutover to green
kubectl patch service api -p '{"spec":{"selector":{"version":"green"}}}'
# Rollback to blue
kubectl patch service api -p '{"spec":{"selector":{"version":"blue"}}}'
Canary Deployment
How It Works
Phase 1: 1% canary
ââââââââââââââââââââââââââââââââââââââââââââââââââââââââ
â [Production v1] ââââââââââââââââââââââââââââââââ 99% â
â [Canary v2] â 1% â
ââââââââââââââââââââââââââââââââââââââââââââââââââââââââ
Phase 2: 10% canary
ââââââââââââââââââââââââââââââââââââââââââââââââââââââââ
â [Production v1] ââââââââââââââââââââââââââââ 90% â
â [Canary v2] ââââ 10% â
ââââââââââââââââââââââââââââââââââââââââââââââââââââââââ
Phase 3: 50% canary
ââââââââââââââââââââââââââââââââââââââââââââââââââââââââ
â [Production v1] ââââââââââââââ 50% â
â [Canary v2] ââââââââââââââ 50% â
ââââââââââââââââââââââââââââââââââââââââââââââââââââââââ
Phase 4: Full rollout
ââââââââââââââââââââââââââââââââââââââââââââââââââââââââ
â [Production v2] ââââââââââââââââââââââââââââ 100% â
ââââââââââââââââââââââââââââââââââââââââââââââââââââââââ
Kubernetes with Istio
# VirtualService for traffic splitting
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
name: api
spec:
hosts:
- api
http:
- route:
- destination:
host: api
subset: stable
weight: 90
- destination:
host: api
subset: canary
weight: 10
---
# DestinationRule defines subsets
apiVersion: networking.istio.io/v1beta1
kind: DestinationRule
metadata:
name: api
spec:
host: api
subsets:
- name: stable
labels:
version: v1
- name: canary
labels:
version: v2
Canary Analysis
# Argo Rollouts analysis
apiVersion: argoproj.io/v1alpha1
kind: AnalysisTemplate
metadata:
name: success-rate
spec:
metrics:
- name: success-rate
interval: 1m
successCondition: result[0] >= 0.99
provider:
prometheus:
address: http://prometheus:9090
query: |
sum(rate(http_requests_total{status!~"5.*",app="api",version="{{args.version}}"}[5m]))
/
sum(rate(http_requests_total{app="api",version="{{args.version}}"}[5m]))
Feature Flags
How It Works
Code deployed but inactive:
âââââââââââââââââââââââââââââââââââââââââââââââââââââââ
â if (featureFlags.isEnabled("new-checkout")) { â
â return newCheckoutFlow(); // 0% of users â
â } else { â
â return oldCheckoutFlow(); // 100% of users â
â } â
âââââââââââââââââââââââââââââââââââââââââââââââââââââââ
Gradually enable:
- 1% â Internal users only
- 5% â Beta users
- 25% â Random subset
- 50% â Half of traffic
- 100% â Fully enabled
Implementation Example
from launchdarkly import LDClient
ld_client = LDClient("sdk-key")
def checkout(user, cart):
# Check feature flag
if ld_client.variation("new-checkout-flow", user, False):
return new_checkout(user, cart)
else:
return legacy_checkout(user, cart)
Rollout Strategy
# Feature flag configuration
flag: new-checkout-flow
environments:
production:
rollout:
- date: "2026-01-15"
percentage: 1
targets: ["internal"]
- date: "2026-01-17"
percentage: 10
targets: ["beta-users"]
- date: "2026-01-20"
percentage: 50
- date: "2026-01-25"
percentage: 100
kill_switch: true # Can instantly disable
Choosing a Strategy
âââââââââââââââââââââââââââââââââââââââââââââââââââââââ
â What type of change? â
ââââââââââââââââââââââââââââââ¬âââââââââââââââââââââââââ¤
â Infrastructure/config â Database migration â
â â â â â
â â¼ â â¼ â
â Rolling Update â Blue-Green + â
â â Feature Flag â
ââââââââââââââââââââââââââââââ¼âââââââââââââââââââââââââ¤
â User-facing feature â High-risk change â
â â â â â
â â¼ â â¼ â
â Feature Flag + â Canary with â
â Canary â Auto-rollback â
ââââââââââââââââââââââââââââââ´âââââââââââââââââââââââââ
Deployment Checklist
### Pre-Deployment
- [ ] Code reviewed and approved
- [ ] Tests passing
- [ ] Runbook updated
- [ ] Rollback plan documented
- [ ] Monitoring dashboards ready
- [ ] On-call notified
### During Deployment
- [ ] Watch error rates
- [ ] Watch latency
- [ ] Check logs for errors
- [ ] Verify feature works
### Post-Deployment
- [ ] All pods healthy
- [ ] Smoke tests passing
- [ ] No alert spikes
- [ ] Update deployment log
Emergency Rollback
# Kubernetes rollback
kubectl rollout undo deployment/api-service
# To specific revision
kubectl rollout undo deployment/api-service --to-revision=3
# Check history
kubectl rollout history deployment/api-service
# Blue-green instant switch
kubectl patch service api -p '{"spec":{"selector":{"version":"blue"}}}'
# Feature flag kill switch
curl -X PATCH https://api.launchdarkly.com/flags/new-checkout \
-H "Authorization: api-key" \
-d '{"on": false}'