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
RolloutreplacesDeployment. Same spec (replicas,selector,template,revisionHistoryLimit), differentapiVersion/kindandstrategyRolloutadds:blueGreenandcanarystrategies- weighted traffic shifting (needs ingress / service mesh)
- metrics-based analysis and automated rollback
- manual pause / promote / abort
- Use a
Deploymentwhen 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
- gradually shift traffic to the new version via
- Blue-Green
- two full ReplicaSets,
activeService+previewService - traffic switches all at once on promotion
- instant rollback, but double the resources
- two full ReplicaSets,
strategy:
blueGreen:
activeService: my-app-active
previewService: my-app-preview
autoPromotionEnabled: false
Status
phase:Healthy,Progressing,Degraded,Paused- Useful
statusfields:currentStepIndex- current canary stepcurrentPodHashstableRS- the stable ReplicaSetconditions
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 undodoes not work on aRollout, use the plugin- Aborted rollout stays
Degradeduntil the pod template is changed back (orretry)
Traffic Management
- Without
trafficRouting, canary weight is only approximated by replica counts - With it, controller adjusts ingress / mesh weights
- Needs two services:
stableServiceandcanaryService. The controller edits their selectors with therollouts-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}
stableIngresspoints at an ingress whose backend is the stable service- The controller creates a second ingress (
<name>-canary) withnginx.ingress.kubernetes.io/canary: "true"andcanary-weight
Istio
strategy:
canary:
canaryService: my-app-canary
stableService: my-app-stable
trafficRouting:
istio:
virtualService:
name: my-app-vsvc
routes:
- primary
- The
VirtualServiceroute (primary) lists stable and canary destinations with weights100/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