Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

🏠 Back to Blog

Rollout Strategies

Argo Rollouts is a controller plus CRDs that add progressive delivery (blue-green, canary, analysis) on top of what a plain Deployment can do (only rolling update / recreate).

Rollout vs Deployment

  • Rollout replaces Deployment. Same spec (replicas, selector, template, revisionHistoryLimit), different apiVersion/kind and strategy
  • Rollout adds:
    • blueGreen and canary strategies
    • weighted traffic shifting (needs ingress / service mesh)
    • metrics-based analysis and automated rollback
    • manual pause / promote / abort
  • Use a Deployment when a simple rolling update is enough
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
  name: my-app
spec:
  replicas: 5
  revisionHistoryLimit: 2
  selector:
    matchLabels:
      app: my-app
  template:
    metadata:
      labels:
        app: my-app
    spec:
      containers:
      - name: my-app
        image: my-app:v1
  strategy:
    canary:
      steps:
      - setWeight: 20
      - pause: {duration: 1m}

Strategies

  • Canary
    • gradually shift traffic to the new version via steps
    • can use analysis between steps
    • less resource usage
  • Blue-Green
    • two full ReplicaSets, activeService + previewService
    • traffic switches all at once on promotion
    • instant rollback, but double the resources
strategy:
  blueGreen:
    activeService: my-app-active
    previewService: my-app-preview
    autoPromotionEnabled: false

Status

  • phase: Healthy, Progressing, Degraded, Paused
  • Useful status fields:
    • currentStepIndex - current canary step
    • currentPodHash
    • stableRS - the stable ReplicaSet
    • conditions
kubectl argo rollouts get rollout my-app --watch
kubectl argo rollouts list rollouts

Operations (kubectl plugin)

kubectl argo rollouts promote my-app          # next step
kubectl argo rollouts promote my-app --full   # skip remaining steps
kubectl argo rollouts abort my-app            # back to stable
kubectl argo rollouts pause my-app
kubectl argo rollouts resume my-app
kubectl argo rollouts restart my-app
kubectl argo rollouts undo my-app --to-revision=3
  • kubectl rollout undo does not work on a Rollout, use the plugin
  • Aborted rollout stays Degraded until the pod template is changed back (or retry)

Traffic Management

  • Without trafficRouting, canary weight is only approximated by replica counts
  • With it, controller adjusts ingress / mesh weights
  • Needs two services: stableService and canaryService. The controller edits their selectors with the rollouts-pod-template-hash
  • Supported: NGINX, Istio, ALB, SMI, Traefik, etc.

NGINX

strategy:
  canary:
    canaryService: my-app-canary
    stableService: my-app-stable
    trafficRouting:
      nginx:
        stableIngress: my-app-ingress
    steps:
    - setWeight: 20
    - pause: {duration: 1m}
  • stableIngress points at an ingress whose backend is the stable service
  • The controller creates a second ingress (<name>-canary) with nginx.ingress.kubernetes.io/canary: "true" and canary-weight

Istio

strategy:
  canary:
    canaryService: my-app-canary
    stableService: my-app-stable
    trafficRouting:
      istio:
        virtualService:
          name: my-app-vsvc
          routes:
          - primary
  • The VirtualService route (primary) lists stable and canary destinations with weights 100/0; the controller rewrites them
  • Istio also supports header-based routing and mirroring (shadow traffic)

Notes

  • Start small (5-10%), use several small steps
  • Add analysis so bad canaries abort automatically