Day 5: Progressive delivery with Argo Rollouts
Goal: Show a new version to only part of the traffic first (canary), let an analysis stop a broken version automatically, and check a version in a preview before switching over (blue-green) · Duration: approx. 60 min · Prerequisite: Day 4
Briefing
- A Deployment replaces pods gradually, but only checks whether they are ready – not whether they work correctly. A pod that answers every request with 500 is still “Ready”.
- Argo Rollouts replaces the Deployment with the resource Rollout, with two strategies:
| Strategy | Process | When |
|---|---|---|
| Canary | the new version gradually gets a larger share (25 %, 50 %, …), with pauses and checks in between | services with lots of traffic, errors show up under real load |
| Blue-green | the new version runs completely alongside, a preview Service shows it, switch-over in one go | fast way back, tests before switching over |
- An AnalysisTemplate describes how “healthy” is measured: a Prometheus query, an HTTP call or a Job whose exit code counts. If the analysis fails, the rollout aborts and switches back – without humans.
- Without traffic routing (Ingress, Gateway API, mesh), Argo Rollouts controls the share via the number of pods: 25 % of 4 replicas = 1 pod with the new version. Prometheus only arrives on Day 10; today a Job does the measuring.
Drill 1: Installing Argo Rollouts
# on cp1
mkdir -p ~/cnpe/tag05 && cd ~/cnpe/tag05
# chart from the Argo repo of Day 3
# controller.priorityClassName platform service (Day 2)
# dashboard.* web UI on port 31000
helm install argo-rollouts argo/argo-rollouts --version 2.43.12 -n argo-rollouts --create-namespace \
--set controller.priorityClassName=plattform-kritisch \
--set dashboard.enabled=true --set dashboard.service.type=NodePort --set dashboard.service.nodePort=31000
k -n argo-rollouts rollout status deploy/argo-rollouts --timeout=200s
# kubectl plugin: kubectl looks for programs with the prefix kubectl- in the PATH
ARCH=$(dpkg --print-architecture)
sudo curl -sSfL -o /usr/local/bin/kubectl-argo-rollouts \
https://github.com/argoproj/argo-rollouts/releases/download/v1.10.2/kubectl-argo-rollouts-linux-$ARCH
sudo chmod 755 /usr/local/bin/kubectl-argo-rollouts
k argo rollouts version --shortExpected (abridged):
STATUS: deployed
deployment "argo-rollouts" successfully rolled out
kubectl-argo-rollouts: v1.10.2+be8a622
You reach the dashboard at
http://172.16.0.126:31000.
Save your progress? Sign up for free
Drill 2: The first canary
Team Blue’s service kasse uses the project’s demo image:
it answers on /color with its colour – so you can see which
version is answering.
# on cp1
cat > kasse.yaml <<'EOF'
apiVersion: argoproj.io/v1alpha1
kind: Rollout # instead of Deployment – identical pod template
metadata:
name: kasse
namespace: team-blue
spec:
replicas: 4
revisionHistoryLimit: 3
selector:
matchLabels: {app: kasse}
template:
metadata:
labels: {app: kasse}
spec:
containers:
- name: kasse
image: argoproj/rollouts-demo:blue
ports: [{containerPort: 8080}]
resources:
requests: {cpu: 20m, memory: 32Mi}
limits: {cpu: 100m, memory: 64Mi}
strategy:
canary:
steps:
- setWeight: 25 # 1 of 4 pods new
- pause: {} # wait until someone says "promote"
- setWeight: 50
- pause: {duration: 30s} # wait 30 s, then continue
- setWeight: 75
- pause: {duration: 30s}
---
apiVersion: v1
kind: Service
metadata:
name: kasse
namespace: team-blue
spec:
selector: {app: kasse}
ports: [{port: 80, targetPort: 8080}]
EOF
k apply -f kasse.yaml
sleep 40
# --no-color without colour codes, good for logs and copies
k argo rollouts get rollout kasse -n team-blue --no-colorExpected (abridged):
rollout.argoproj.io/kasse created
service/kasse created
Name: kasse
Namespace: team-blue
Status: ✔ Healthy
Strategy: Canary
Step: 6/6
SetWeight: 100
ActualWeight: 100
Images: argoproj/rollouts-demo:blue (stable)
...
The first version starts without steps – there is nothing yet to compare it with. Now the new version:
# on cp1
# swap the image (corresponds to a new tag in Git)
k argo rollouts set image kasse -n team-blue kasse=argoproj/rollouts-demo:yellow
sleep 20
k argo rollouts get rollout kasse -n team-blue --no-color
# 40 requests from a test pod: who answers?
k -n team-blue run probe --rm -i --restart=Never --image=curlimages/curl:8.17.0 --command -- \
sh -c 'for i in $(seq 1 40); do curl -s http://kasse/color; echo; done' 2>/dev/null \
| grep -o -E 'blue|yellow' | sort | uniq -cExpected (abridged):
rollout "kasse" image updated
Name: kasse
Namespace: team-blue
Status: ॥ Paused
Message: CanaryPauseStep
Strategy: Canary
Step: 1/6
SetWeight: 25
ActualWeight: 25
Images: argoproj/rollouts-demo:blue (stable)
argoproj/rollouts-demo:yellow (canary)
...
NAME KIND STATUS AGE INFO
⟳ kasse Rollout ॥ Paused 66s
├──# revision:2
│ └──⧉ kasse-7d5f8d4688 ReplicaSet ✔ Healthy 21s canary
│ └──□ kasse-7d5f8d4688-2lkg4 Pod ✔ Running 20s ready:1/1
└──# revision:1
└──⧉ kasse-74d7b45696 ReplicaSet ✔ Healthy 66s stable
├──□ kasse-74d7b45696-4njcs Pod ✔ Running 66s ready:1/1
├──□ kasse-74d7b45696-9cr7w Pod ✔ Running 66s ready:1/1
└──□ kasse-74d7b45696-nf9gv Pod ✔ Running 66s ready:1/1
26 blue
13 yellow
A third yellow instead of a quarter – the Service distributes per connection, not exactly by share. For exact percentages you need traffic routing. The rollout is now waiting for you:
# on cp1
# release the next step; the 30 s pauses then run out by themselves
k argo rollouts promote kasse -n team-blue
sleep 75
k argo rollouts status kasse -n team-blue --timeout 60sExpected:
rollout 'kasse' promoted
Healthy
Save your progress? Sign up for free
Drill 3: An analysis stops the error
The analysis specifically calls the new version. For
this, the rollout gets a second Service, kasse-canary,
whose selector Argo Rollouts itself points at the canary pods.
# on cp1
cat > analyse.yaml <<'EOF'
apiVersion: argoproj.io/v1alpha1
kind: AnalysisTemplate
metadata:
name: fehlerquote
namespace: team-blue
spec:
args:
- name: service # passed in by the rollout
metrics:
- name: http-fehler
count: 3 # measure three times ...
interval: 10s # ... 10 s apart
failureLimit: 1 # more than 1 failure = analysis failed
provider:
job: # Job: exit code 0 = successful
spec:
backoffLimit: 0
template:
spec:
restartPolicy: Never
containers:
- name: pruefen
image: curlimages/curl:8.17.0
command: ["sh", "-c"]
args:
- |
fehler=0
for i in $(seq 1 20); do
code=$(curl -s -o /dev/null -w "%{http_code}" http://{{args.service}}/color)
[ "$code" = "200" ] || fehler=$((fehler+1))
done
echo "Fehler: $fehler von 20"
[ $fehler -eq 0 ]
---
apiVersion: v1
kind: Service
metadata:
name: kasse-canary
namespace: team-blue
spec:
selector: {app: kasse} # Argo Rollouts adds the hash of the canary version
ports: [{port: 80, targetPort: 8080}]
EOF
k apply -f analyse.yamlIn the rollout, the analysis replaces the manual pause, and the
canary Service is added. The image is now set to yellow –
the way it is running:
# on cp1
cat > kasse-strategie.yaml <<'EOF'
strategy:
canary:
canaryService: kasse-canary # this Service always points at the canary pods
steps:
- setWeight: 25
- analysis: # instead of pause: {} – decides by itself
templates:
- templateName: fehlerquote
args:
- name: service
value: kasse-canary
- setWeight: 50
- pause: {duration: 30s}
- setWeight: 75
- pause: {duration: 30s}
EOF
# replace the old strategy block with the new one and set the image to yellow
# sed '/^ strategy:/,/^---/{/^---/!d}' deletes from "strategy:" up to just before "---"
sed -i '/^ strategy:/,/^---/{/^---/!d}' kasse.yaml
sed -i "/^---/e cat kasse-strategie.yaml" kasse.yaml
sed -i 's#rollouts-demo:blue#rollouts-demo:yellow#' kasse.yaml
k apply -f kasse.yaml
k -n team-blue get svc kasse-canary -o jsonpath='{.spec.selector}{"\n"}'Expected:
rollout.argoproj.io/kasse configured
service/kasse unchanged
{"app":"kasse","rollouts-pod-template-hash":"7d5f8d4688"}
Now a broken version – bad-red answers most requests
with HTTP 500:
# on cp1
k argo rollouts set image kasse -n team-blue kasse=argoproj/rollouts-demo:bad-red
sleep 75
k argo rollouts get rollout kasse -n team-blue --no-color | head -12
k -n team-blue get analysisrun
# output of the check jobs
for j in $(k -n team-blue get jobs -o name); do k -n team-blue logs $j; doneExpected (abridged):
rollout "kasse" image updated
Name: kasse
Namespace: team-blue
Status: ✖ Degraded
Message: RolloutAborted: Rollout aborted update to revision 3: Step-based analysis phase error/failed: Metric "http-fehler" assessed Failed due to failed (2) > failureLimit (1)
Strategy: Canary
Step: 0/6
SetWeight: 0
ActualWeight: 0
Images: argoproj/rollouts-demo:yellow (stable)
...
NAME STATUS AGE
kasse-656bf77d85-3-1 Failed 69s
Fehler: 16 von 20
Fehler: 17 von 20
After two failed measurements, Argo Rollouts aborted and set the
share to 0: all requests go to yellow again.
Degraded remains until someone corrects the desired version
– here back to yellow:
# on cp1
k argo rollouts set image kasse -n team-blue kasse=argoproj/rollouts-demo:yellow
sleep 15
k argo rollouts get rollout kasse -n team-blue --no-color | head -4Expected:
rollout "kasse" image updated
Name: kasse
Namespace: team-blue
Status: ✔ Healthy
Under Argo CD, this step is a git revert – as on Day
3.
Save your progress? Sign up for free
Drill 4: Blue-green with preview
# on cp1
cat > lager.yaml <<'EOF'
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
name: lager
namespace: team-blue
spec:
replicas: 2
revisionHistoryLimit: 2
selector:
matchLabels: {app: lager}
template:
metadata:
labels: {app: lager}
spec:
containers:
- name: lager
image: argoproj/rollouts-demo:blue
ports: [{containerPort: 8080}]
resources:
requests: {cpu: 20m, memory: 32Mi}
limits: {cpu: 100m, memory: 64Mi}
strategy:
blueGreen:
activeService: lager # gets the real traffic
previewService: lager-preview # shows the new version before switching over
autoPromotionEnabled: false # switch over only on command
scaleDownDelaySeconds: 30 # keep the old version 30 s longer (fast way back)
---
apiVersion: v1
kind: Service
metadata:
name: lager
namespace: team-blue
spec:
selector: {app: lager}
ports: [{port: 80, targetPort: 8080}]
---
apiVersion: v1
kind: Service
metadata:
name: lager-preview
namespace: team-blue
spec:
selector: {app: lager}
ports: [{port: 80, targetPort: 8080}]
EOF
k apply -f lager.yaml
sleep 30
k argo rollouts set image lager -n team-blue lager=argoproj/rollouts-demo:green
sleep 30
k argo rollouts get rollout lager -n team-blue --no-color | grep -E 'Status:|ReplicaSet'
k -n team-blue run probe --rm -i --restart=Never --image=curlimages/curl:8.17.0 --command -- \
sh -c 'echo aktiv: $(curl -s http://lager/color); echo vorschau: $(curl -s http://lager-preview/color)' 2>/dev/nullExpected:
rollout.argoproj.io/lager created
service/lager created
service/lager-preview created
rollout "lager" image updated
Status: ॥ Paused
│ └──⧉ lager-6dfb94bf87 ReplicaSet ✔ Healthy 31s preview
└──⧉ lager-7fc7454dbd ReplicaSet ✔ Healthy 62s stable,active
aktiv: "blue"
vorschau: "green"
Both versions run completely. Testers (or an analysis with
prePromotionAnalysis) check the preview; customers still
see blue. Switching over:
# on cp1
k argo rollouts promote lager -n team-blue
sleep 10
k -n team-blue run probe --rm -i --restart=Never --image=curlimages/curl:8.17.0 --command -- \
sh -c 'echo aktiv: $(curl -s http://lager/color)' 2>/dev/null
k argo rollouts get rollout lager -n team-blue --no-color | grep -E 'Status:|ReplicaSet'
sleep 35
k -n team-blue get rs -l app=lagerExpected:
rollout 'lager' promoted
aktiv: "green"
Status: ✔ Healthy
│ └──⧉ lager-6dfb94bf87 ReplicaSet ✔ Healthy 54s stable,active
└──⧉ lager-7fc7454dbd ReplicaSet ✔ Healthy 85s delay:16s
NAME DESIRED CURRENT READY AGE
lager-6dfb94bf87 2 2 2 90s
lager-7fc7454dbd 0 0 0 2m1s
Switching over is a change of the Service selector – instantly for
everyone. The old version kept running for another 30 seconds
(delay:16s showed the remainder), then it was scaled to
0.
Save your progress? Sign up for free
Exercise: Reading a rollout
Time limit: 5 minutes. Without the plugin, find out which revision of
kasse is stable, which image it has and how the last
AnalysisRun ended.
Solution
# on cp1
# status of the rollout: hash of the stable version, phase
k -n team-blue get rollout kasse -o jsonpath='{.status.stableRS} {.status.phase}{"\n"}'
# ReplicaSet with this hash and its image
H=$(k -n team-blue get rollout kasse -o jsonpath='{.status.stableRS}')
k -n team-blue get rs kasse-$H -o jsonpath='{.spec.template.spec.containers[0].image}{"\n"}'
# AnalysisRuns with result
k -n team-blue get analysisrun -o custom-columns=NAME:.metadata.name,PHASE:.status.phase,MESSAGE:.status.messageExpected (abridged):
7d5f8d4688 Healthy
argoproj/rollouts-demo:yellow
NAME PHASE MESSAGE
kasse-656bf77d85-3-1 Failed Metric "http-fehler" assessed Failed due to failed (2) > failureLimit (1)
Save your progress? Sign up for free
Challenge
Time limit: 10 minutes. A team wants to convert an existing Deployment to a Rollout without the running pods restarting. How does that work, and what happens to the Deployment?
Solution
A Rollout can reference an existing Deployment
instead of having its own pod template: spec.workloadRef
with apiVersion: apps/v1, kind: Deployment,
name: … and without template. Argo Rollouts
takes over the template and starts its own pods. After that, the team
scales the Deployment to 0 (scaleDown: progressively in the
workloadRef does this step by step). So a restart cannot be
avoided entirely – but without a gap, because the old pods keep running
until the new ones are ready. Read up:
k explain rollout.spec.workloadRef.
Save your progress? Sign up for free
Checkpoint
# on cp1
# both rollouts healthy
k -n team-blue get rollouts -o custom-columns=NAME:.metadata.name,PHASE:.status.phase,STRATEGIE:.spec.strategy
# kasse on yellow, lager on green
k -n team-blue get rollout kasse -o jsonpath='{.spec.template.spec.containers[0].image}{"\n"}'
k -n team-blue get rollout lager -o jsonpath='{.spec.template.spec.containers[0].image}{"\n"}'
# the analysis template exists
k -n team-blue get analysistemplate fehlerquote -o nameExpected (abridged):
NAME PHASE STRATEGIE
kasse Healthy map[canary:map[canaryService:kasse-canary steps:[map[setWeight ...
lager Healthy map[blueGreen:map[activeService:lager autoPromotionEnabled:fal ...
argoproj/rollouts-demo:yellow
argoproj/rollouts-demo:green
analysistemplate.argoproj.io/fehlerquote
Interview Note
- Canary or blue-green? Canary limits the damage to a portion of users and needs no double capacity; blue-green needs double capacity, but switches there and back in one step and allows tests on the preview.
- Why is the readiness probe not enough? It checks “answers”, not “answers correctly”. An analysis measures behaviour (error rate, latency) and decides automatically.
- How exact is 25 % without traffic routing? As exact as the pod count and the Service’s distribution; for exact percentages you need Ingress, Gateway API or a mesh.
Enterprise Note
- Analyses against Prometheus instead of Jobs (error rate and p95 latency of the canary version) – Day 10.
- Traffic routing via Gateway API or service mesh for exact shares and header-based routing (internal testers first).
- Rollouts under Argo CD: the health check for
Rolloutis built in; an aborted rollout shows up in Argo CD asDegraded. - Provide analysis templates centrally from the platform as a ClusterAnalysisTemplate, so that every team uses the same yardstick.