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

Canary

  • Shift a growing share of traffic to the new version, steps define the progression
  • When the last step finishes the canary becomes the new stable
strategy:
  canary:
    maxSurge: "25%"
    maxUnavailable: 0
    steps:
    - setWeight: 10
    - pause: {duration: 2m}
    - setWeight: 40
    - pause: {}
    - setWeight: 80
    - pause: {duration: 5m}

Fields

  • steps - ordered list
  • maxSurge / maxUnavailable - default 25% each
  • canaryService / stableService
  • trafficRouting - nginx, istio, alb, …
  • analysis - background analysis

Step types

  • setWeight - percent of traffic to canary
  • pause: {duration: 10m} - timed pause
  • pause: {} - indefinite, needs promote
  • analysis - run an analysis and block until it passes
  • experiment
  • setCanaryScale - set canary replicas independent of weight
    • replicas: 1, weight: 25 or matchTrafficWeight: true
steps:
- setCanaryScale:
    replicas: 1
- setWeight: 10
- pause: {duration: 5m}
- analysis:
    templates:
    - templateName: smoke-tests
    args:
    - name: service-name
      value: my-app-canary
- setWeight: 50
  • Common pattern: longer pauses as weight goes up

Traffic splitting

  • Without trafficRouting weight is approximated with pod counts (e.g. 20% of 5 replicas = 1 canary pod)
  • With NGINX the controller creates a canary ingress with canary-weight annotation matching setWeight
trafficRouting:
  nginx:
    stableIngress: my-app-ingress
    annotationPrefix: nginx.ingress.kubernetes.io

Automated promotion / rollback

  • Background analysis runs alongside the steps
  • startingStep - step index analysis starts at
  • Failed analysis aborts the rollout and scales canary down, traffic goes back to stable
strategy:
  canary:
    analysis:
      templates:
      - templateName: success-rate
      - templateName: latency
      startingStep: 2
      args:
      - name: service-name
        value: my-app-canary
    steps:
    - setWeight: 10
    - pause: {duration: 5m}
    - setWeight: 20
    - pause: {duration: 5m}
  • Inline analysis step: only continues if it succeeds

Example with NGINX

strategy:
  canary:
    canaryService: nginx-canary
    stableService: nginx-stable
    trafficRouting:
      nginx:
        stableIngress: nginx-ingress
    steps:
    - setWeight: 10
    - pause: {duration: 30s}
    - setWeight: 25
    - pause: {duration: 30s}
    - setWeight: 50
    - pause: {}

Notes

  • Uses fewer resources than blue-green
  • Real traffic validates the new version
  • kubectl argo rollouts promote moves past an indefinite pause, --full skips everything