How do you implement a canary release with Argo Rollouts and automated analysis?
AdvancedProductionRelease Engineering and Progressive Delivery
Answer
Replace the Deployment with a Rollout that defines canary steps and an AnalysisTemplate querying Prometheus for the canary's success rate. If the analysis fails, Argo Rollouts aborts and rolls back to stable automatically.
apiVersion: argoproj.io/v1alpha1
kind: AnalysisTemplate
metadata: { name: success-rate }
spec:
metrics:
- name: success-rate
interval: 1m
count: 5
successCondition: result[0] >= 0.99
failureLimit: 1
provider:
prometheus:
address: http://prometheus.monitoring:9090
query: |
sum(rate(http_requests_total{app="shop-api",status!~"5.."}[2m]))
/ sum(rate(http_requests_total{app="shop-api"}[2m]))
Traffic splitting needs an ingress or mesh integration (NGINX, ALB, Istio, Gateway API) for precise percentages; without one, weight is approximated by pod ratio.
More on Release Engineering and Progressive Delivery
How do you do zero-downtime deployments on Kubernetes?IntermediateHow do you roll back safely when a deploy includes a database migration?AdvancedHow do you design an automated rollback trigger?AdvancedHow do you handle hotfixes in a trunk-based flow?IntermediateHow do you version and release libraries versus services?IntermediateWhat does a release train look like and when is it appropriate?Intermediate