Infrastructure as Code
Terraform Canary Deployment 2026
Zero-Downtime Infrastructure Deployments mit Terraform. Canary, Blue-Green, automatisches Rollback und Observability für sichere Produktions-Updates.
Deployment-Strategien
Canary
Progressiver Rollout: 5% → 25% → 50% → 100%. Frühe Fehlererkennung bei minimaler Impact.
Blue-Green
Zwei identische Umgebungen. Instant-Switch mit sofortigem Rollback.
Terraform Implementierung
AWS ALB mit Weighted Routing
# Terraform: Canary Traffic Splitting
resource "aws_lb_target_group" "blue" {
name = "blue-tg"
port = 80
protocol = "HTTP"
vpc_id = aws_vpc.main.id
}
resource "aws_lb_target_group" "green" {
name = "green-tg"
port = 80
protocol = "HTTP"
vpc_id = aws_vpc.main.id
}
# Weighted Routing (80% Blue, 20% Green)
resource "aws_lb_listener_rule" "canary" {
listener_arn = aws_lb_listener.https.arn
priority = 100
action {
type = "forward"
forward {
target_group {
arn = aws_lb_target_group.blue.arn
weight = 80
}
target_group {
arn = aws_lb_target_group.green.arn
weight = 20
}
}
}
}Health Checks & Auto-Rollback
- • HTTP Health Probes: 200 OK vor Traffic-Shift
- • Error Rate Monitoring: Rollback bei > 0.1% 5xx Errors
- • Latency Gates: p99 Latenz < 500ms
- • Prometheus Metrics: Business KPIs als Gates
Argo Rollouts Integration
# Argo Rollout: Progressive Delivery
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
name: my-app
spec:
replicas: 10
strategy:
canary:
steps:
- setWeight: 10
- pause: {duration: 2m}
- setWeight: 25
- pause: {duration: 5m}
- analysis:
templates:
- templateName: success-rate
- setWeight: 50
- pause: {duration: 10m}
- setWeight: 100