Stage 4 · Provision
Continuous Delivery & GitOps
Progressive Delivery
Argo Rollouts, Flagger, canaries, blue-green deployments, and metric gates — deploying safely with automated rollbacks.
What Is Progressive Delivery?
Progressive delivery extends continuous delivery by gradually exposing new versions to users and automatically rolling back if errors are detected. Instead of deploying to 100% of traffic at once, you deploy to 5%, observe metrics, then promote to more traffic.
This approach reduces the risk of deployments. Bad code reaches a small percentage of users before being automatically rolled back. The entire process is automated — no human intervention required.
Argo Rollouts
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
name: webapp
spec:
replicas: 10
strategy:
canary:
steps:
- setWeight: 5
- pause: { duration: 5m }
- setWeight: 20
- pause: { duration: 10m }
- setWeight: 50
- pause: { duration: 10m }
- setWeight: 100
analysis:
templates:
- templateName: success-rate
args:
- name: service-name
value: webappThe Rollout resource replaces the Deployment resource. The canary strategy defines steps: deploy to 5% of traffic, wait 5 minutes, promote to 20%, and so on. The analysis template checks metrics at each step.
apiVersion: argoproj.io/v1alpha1
kind: AnalysisTemplate
metadata:
name: success-rate
spec:
args:
- name: service-name
metrics:
- name: success-rate
interval: 1m
count: 5
successCondition: result[0] >= 0.99
failureLimit: 3
provider:
prometheus:
address: http://prometheus:9090
query: |
sum(rate(http_requests_total{service="{{args.service-name}}",code=~"2.."}[5m]))
/
sum(rate(http_requests_total{service="{{args.service-name}}"}[5m]))The AnalysisTemplate defines what metrics to check and what thresholds to use. If the success rate drops below 99% three times, the rollout is automatically rolled back. The query runs every minute for 5 iterations.
Canary Deployments
A canary deployment sends a small percentage of traffic to the new version. If metrics are healthy, traffic is gradually increased. If metrics degrade, traffic is shifted back to the old version.
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
name: webapp
spec:
strategy:
canary:
canaryService: webapp-canary
stableService: webapp-stable
trafficRouting:
nginx:
stableIngress: webapp-ingress
additionalIngressAnnotations:
canary-by-header: X-Canary
steps:
- setWeight: 10
- pause: { duration: 5m }
- setWeight: 30
- pause: { duration: 10m }
- setWeight: 100The canaryService and stableService point to different Services. trafficRouting configures nginx to split traffic. The canary-by-header annotation allows testing the canary version by setting a header.
Blue-Green Deployments
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
name: webapp
spec:
strategy:
blueGreen:
activeService: webapp-active
previewService: webapp-preview
autoPromotionEnabled: false
prePromotionAnalysis:
templates:
- templateName: smoke-test
scaleDownDelaySeconds: 300Blue-green creates two identical environments. The activeService serves production traffic. The previewService serves the new version for testing. autoPromotionEnabled: false requires manual approval before switching traffic.
Metric Gates
apiVersion: argoproj.io/v1alpha1
kind: AnalysisTemplate
metadata:
name: latency-gate
spec:
metrics:
- name: p99-latency
interval: 1m
count: 3
successCondition: result[0] < 500
failureLimit: 2
provider:
prometheus:
address: http://prometheus:9090
query: |
histogram_quantile(0.99,
sum(rate(http_request_duration_seconds_bucket{service="{{args.service}}"}[5m])) by (le)
) * 1000This metric gate checks p99 latency. If latency exceeds 500ms twice, the rollout is rolled back. The query converts seconds to milliseconds for the comparison. Multiple metrics can be checked simultaneously.
Flagger
apiVersion: flagger.app/v1beta1
kind: Canary
metadata:
name: webapp
spec:
targetRef:
apiVersion: apps/v1
kind: Deployment
name: webapp
progressDeadlineSeconds: 600
service:
port: 80
targetPort: 8080
analysis:
interval: 1m
threshold: 3
maxWeight: 50
stepWeight: 10
metrics:
- name: request-success-rate
thresholdRange:
min: 99
interval: 1m
- name: request-duration
thresholdRange:
max: 500
interval: 1mFlagger is an alternative to Argo Rollouts. It automatically creates canary deployments and gradually shifts traffic. The analysis checks request success rate and duration. Flagger supports Istio, Linkerd, and other service meshes.
Canary deployments are simpler to implement and require less infrastructure than blue-green. Start with canary for most applications. Use blue-green for zero-downtime requirement where instant rollback is needed.
Metric gates need Prometheus, Datadog, or similar metrics infrastructure. Without observability, progressive delivery cannot detect failures and reverts to blind deployment.
Mark this lesson complete to store local progress and unlock a cleaner resume path the next time you visit.