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
AnalysisTemplatewith a metric query and success condition. - Reference it in the Rollout canary steps.
- From CI, set the image and watch
kubectl argo rollouts statusfor 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.99Workflow
.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
fiGotchas
- A failed analysis marks the Rollout Degraded and aborts;
rollouts statusexits non-zero so CI fails too. - Argo auto-reverts the canary weight on abort; no manual rollback step is needed.
Related guides
How to Set Metric Gates on a Canary in GitHub ActionsSet metric gates on a canary release driven from GitHub Actions so each traffic increase proceeds only when e…
How to Check Latency After Deploy With Datadog in GitHub ActionsQuery the Datadog metrics API after a deploy in GitHub Actions to read p95 latency over a bake window and fai…