Skip to content
Latchkey

How to Verify a Canary With Argo Rollouts Analysis in GitHub Actions

Argo Rollouts can promote a canary step by step only when an AnalysisTemplate says its metrics are healthy, aborting and rolling back automatically otherwise.

Update the Rollout image from CI, then watch the rollout status; the canary AnalysisTemplate queries metrics between steps and fails the run if it aborts.

Steps

  • Define an AnalysisTemplate with a metric query and success condition.
  • Reference it in the Rollout canary steps.
  • From CI, set the image and watch kubectl argo rollouts status for Degraded.

AnalysisTemplate

analysis-template.yaml
apiVersion: argoproj.io/v1alpha1
kind: AnalysisTemplate
metadata:
  name: success-rate
spec:
  metrics:
    - name: success-rate
      interval: 1m
      failureLimit: 2
      provider:
        prometheus:
          address: http://prometheus.monitoring:9090
          query: |
            sum(rate(http_requests_total{app="web",code!~"5.."}[2m]))
            / sum(rate(http_requests_total{app="web"}[2m]))
      successCondition: result >= 0.99

Workflow

.github/workflows/ci.yml
- name: Roll out canary and watch analysis
  run: |
    kubectl argo rollouts set image web web=ghcr.io/acme/web:${{ github.sha }}
    if ! kubectl argo rollouts status web --timeout 600s; then
      echo "canary analysis failed; rollout aborted"; exit 1
    fi

Gotchas

  • A failed analysis marks the Rollout Degraded and aborts; rollouts status exits non-zero so CI fails too.
  • Argo auto-reverts the canary weight on abort; no manual rollback step is needed.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →