Hour 6: Progressive Delivery and Automation
- Explain, in tool-neutral GitOps terms, the division of responsibilities between CI and CD: CI builds, tests and pushes the image, then opens a PR that changes the desired state (
apps/podinfo/overlays/*the image tag in it); Argo CD inside the cluster pulls and reconciles it. CI does not hold cluster credentials. - Replace podinfo's Deployment with an Argo Rollouts Rollout, using
setWeight/pausefor canary, and two Services, active / preview, for blue-green; understand the approximation that without traffic routing, “weight = replica ratio”. - Write AnalysisTemplate, and use Prometheus to query podinfo's
http_requests_totalcalculate the canary success rate, and let the AnalysisRun decide automatically whether to continue or abort, and carry out the real rollback in Git. - Configure Argo CD Image Updater (the v1.x
ImageUpdaterCRD), and distinguishargocdandgitwrite-back methods, and compare them with Flux's image automation. - Use Notifications triggers, templates and subscriptions to send sync-succeeded, sync-failed and degraded events to a local Webhook (zero cost) or Slack.
- Use the AppProject's sync windows to enforce change freezes, define drift policy (self-heal vs alert-only) and break-glass emergency change process; use PRs between environment directories to promote, and learn about Kargo.
1-hour time allocation table
| # | Time | Module | Core content | Animation / interaction | Lab (kind cluster lab) |
|---|---|---|---|---|---|
| 0 | Pre-class | Prep: Argo Rollouts and Prometheus | Minimal starting point; install the Rollouts controller and a slim Prometheus with Argo CD, plus the kubectl plugin | Environment self-check list | platform application Healthy |
| 1 | 00–06 | From CI to GitOps: Who Changes Git | Push vs pull model, CI opening a PR to change image tags, immutable tags and digests, credential boundaries | Pipeline flow: switching between push / pull mode | Simulate CI: branch + kustomize edit set image + PR |
| 2 | 06–13 | Argo Rollouts: Canary and Blue-Green | Rollout CRD, canary steps, blue-green active/preview, traffic management, Argo CD health and resource actions, Flagger comparison | Canary weight to replica conversion + blue-green switch | Convert podinfo to a Rollout and promote manually |
| 3 | 13–21 | AnalysisTemplate: Automatic Rollback | AnalysisTemplate / AnalysisRun, Prometheus provider, failureLimit, Inconclusive / Error, abort and Git rollback | Core animation: canary + AnalysisRun verdict promote / abort | Release a “bad version” and watch it abort automatically |
| 4 | 21–28 | Argo CD Image Updater | ImageUpdater CRD, update strategies, argocd vs git write-back, write-back branch and PR, Flux comparison | Tag selector: strategy + constraint → chosen version | dev automatically upgrades from 6.16.0 to 6.17.0 |
| 5 | 28–35 | Notifications: Notifications | Triggers (expr), templates, services, subscription annotations, oncePer, Rollouts notifications | Event → trigger → template → service | Local Webhook receiver gets the notification |
| 6 | 35–42 | Sync Windows and Change Freezes | allow / deny, manualSync, timeZone, syncOverrun; drift policy; break-glass process | Sync window evaluator | Freeze prod, manual override, write emergency changes back to Git |
| 7 | 42–50 | Environment Promotion: PR Flow and Promotion Tools | PR promotion from dev → staging → prod, promotion gates, Kargo (Warehouse / Freight / Stage) | Promotion board: Freight moving across environments | Generate promotion PRs with a script |
| 8 | 50–60 | Hours 1–6 Recap and End-to-End Drill | Linking hours 1–6: the full path from commit to production, and common breakpoints | End-to-end replay + troubleshooting tree | End-to-end drill |
| — | Post-class | Cheat sheet · Capstone lab | Build a complete delivery chain for podinfo: “automatic update → canary analysis → notification → PR promotion” | Final quiz (12 questions) | Capstone lab |
Knowledge Coverage Matrix
| Target skills | M1 | M2 | M3 | M4 | M5 | M6 | M7 | M8 | Key commands | Lab |
|---|---|---|---|---|---|---|---|---|---|---|
| Divide CI and CD responsibilities; change the desired state via PR | ✓ | · | · | ✓ | · | · | ✓ | ✓ | kustomize edit set image,gh pr create | Simulate CI PR |
| Canary and blue-green releases | · | ✓ | ✓ | · | · | · | · | ✓ | kubectl argo rollouts get/promote | Rollout conversion |
| Metric-based automatic abort and rollback | · | · | ✓ | · | · | · | · | ✓ | get analysisrun, PromQL | Bad version aborted |
| Automatic image updates and write-back | ✓ | · | · | ✓ | · | · | ✓ | · | get imageupdaters | dev auto-upgrade |
| Notifications and event subscriptions | · | · | · | · | ✓ | ✓ | · | ✓ | argocd admin notifications | Local Webhook |
| Change freezes, drift policy and emergency changes | · | · | · | · | · | ✓ | ✓ | ✓ | argocd proj windows | Freeze prod |
| Multi-environment promotion | ✓ | · | · | ✓ | · | ✓ | ✓ | ✓ | git diff overlays/ | Promotion PR |
Topics excluded from this lesson (and where to learn them)
| Topic | Why not in this lesson | Where to learn |
|---|---|---|
| GitHub Actions / GitLab CI pipeline syntax details | This lesson only cares about one interface: “how CI changes Git” | GitHub 8 hours · GitLab 8 hours |
| Prometheus alerting rules, Grafana dashboards, kube-prometheus-stack operations | This lesson only uses Prometheus as the AnalysisTemplate data source | Prometheus & Grafana 8 hours |
| Full configuration of Istio / Gateway API traffic splitting | Requires a service mesh or gateway controller, beyond 1 hour; this lesson explains the principles and gives a minimal example | Rollouts Traffic Management |
| ApplicationSet RollingSync (syncing in batches by environment) | Belongs to the ApplicationSet topic | Hour 3 |
| Secrets management (encrypted storage of Git credentials and Slack tokens) | Belongs to the security topic | Hour 5 |
| Controller sharding, performance tuning, OutOfSync loop diagnosis | Belongs to the scaling and troubleshooting topic | Hour 7 |
How to use this courseware
Theory · Diagrams · Animation · Commands · Labs · Production cases · Troubleshooting · Quiz · Voice · Video. It is recommended to read “Theory” and “Animation” first, then do the “Labs”. The animation in Module 3 is the core of this lesson.
Progress counts once the quiz score is ≥ 70% or you click “Mark module complete”; it is saved in this browser (if local storage is blocked, it is cleared on refresh).
The “Voice” tab uses the browser's built-in Web Speech API (en-US) to read the narration aloud; without a Chinese voice pack, the narration can still be read or passed to a TTS tool.
argo/argo-cd 10.18.0); Argo Rollouts v1.10.2 (chart argo/argo-rollouts 2.43.12; v1.11.0-rc1 is still a pre-release); Argo CD Image Updater v1.5.0 (chart argo/argocd-image-updater 1.5.0; 1.x changed to ImageUpdater CRD configuration; the latest 0.x maintenance branch is v0.19.0); Prometheus chart prometheus-community/prometheus 29.47.2 (Prometheus v3.16.0), optional kube-prometheus-stack 93.3.1; podinfo 6.17.0 / 6.16.0; Kargo v1.12.6; Flagger v1.45.0; Flux v2.10.0; kind v0.33.0. “Expected output” is marked as “example” if it was not actually run.Module 0 · Prep: Argo Rollouts and Prometheus (complete before class)
- kind cluster
lab(contextkind-lab), Argo CD installed as a Helm releaseargocdin namespaceargocd(Hour 1), with the values file at~/gitops-lab/bootstrap/argocd-values.yaml. - Your own GitHub repository
gitops-lab(local clone at~/gitops-lab), containingapps/podinfo/base/andapps/podinfo/overlays/dev|staging|prod/, plus an Applicationpodinfo-dev/podinfo-staging/podinfo-prod(from Hour 3, generated by ApplicationSetpodinfo(argocd/appsets/podinfo.yaml) with auto-sync and self-heal; from Hour 4 it belongs to the projectplatform). This lesson only modifies overlays and ApplicationSet, and does not directly modify the generated Application. - AppProject
platform(Hour 4) allows deploying cluster-level resources (CRDs, ClusterRoles). Without this project, this lesson's platform components can first be placed indefaultproject. - Resources: kind nodes need about 1.5 GB of extra memory (Rollouts controller about 100 MB, Prometheus about 300–500 MB, podinfo 4 replicas + load generator).
podinfo-dev.Minimal starting point (expand)
kind create cluster --name lab
helm repo add argo https://argoproj.github.io/argo-helm && helm repo update
mkdir -p ~/gitops-lab/bootstrap && cd ~/gitops-lab
cat > bootstrap/argocd-values.yaml <<'EOF'
configs:
params:
server.insecure: true # lab only: access via port-forward
EOF
helm upgrade --install argocd argo/argo-cd -n argocd --create-namespace \
--version 10.18.0 -f bootstrap/argocd-values.yaml --wait
kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath='{.data.password}' | base64 -d; echo
kubectl -n argocd port-forward svc/argocd-server 8080:443 &
argocd login localhost:8080 --username admin --insecure
# Repository layout (after creating an empty gitops-lab repository on GitHub)
mkdir -p apps/podinfo/base apps/podinfo/overlays/{dev,staging,prod} argocd/apps argocd/projects
cat > apps/podinfo/base/service.yaml <<'EOF'
apiVersion: v1
kind: Service
metadata:
name: podinfo
spec:
selector:
app: podinfo
ports:
- name: http
port: 9898
targetPort: http
EOF
cat > apps/podinfo/base/kustomization.yaml <<'EOF'
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- deployment.yaml # Module 2 will replace it with rollout.yaml
- service.yaml
EOF
for env in dev staging prod; do
cat > apps/podinfo/overlays/$env/kustomization.yaml <<EOF
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: podinfo-$env
resources:
- ../../base
images:
- name: ghcr.io/stefanprodan/podinfo
newTag: 6.16.0
EOF
done
apiVersion: apps/v1
kind: Deployment
metadata:
name: podinfo
spec:
replicas: 2
selector:
matchLabels:
app: podinfo
template:
metadata:
labels:
app: podinfo
spec:
containers:
- name: podinfod
image: ghcr.io/stefanprodan/podinfo:6.16.0
command: ["./podinfo", "--port=9898", "--port-metrics=9797"]
ports:
- { name: http, containerPort: 9898 }
- { name: http-metrics, containerPort: 9797 }
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: podinfo-dev
namespace: argocd
spec:
project: default
source:
repoURL: https://github.com/<you>/gitops-lab
targetRevision: main
path: apps/podinfo/overlays/dev
destination:
server: https://kubernetes.default.svc
namespace: podinfo-dev
syncPolicy:
automated: { prune: true, selfHeal: true }
syncOptions: [CreateNamespace=true]
git add . && git commit -m "minimal starting point for hour 6" && git push -u origin main kubectl apply -f argocd/apps/podinfo-dev.yaml argocd app wait podinfo-dev --health --timeout 180
If the repository is private, you first need to argocd repo add add credentials (Hour 2). If you do not have platform project, all of the following project: platform change to project: default.
Step 1: Check the existing environment
kubectl config use-context kind-lab argocd app list -o name kubectl -n podinfo-dev get deploy,svc,pod -o wide grep -n newTag ~/gitops-lab/apps/podinfo/overlays/*/kustomization.yaml
argocd/podinfo-dev argocd/podinfo-staging argocd/podinfo-prod NAME READY UP-TO-DATE AVAILABLE AGE deployment.apps/podinfo 2/2 2 2 3d … apps/podinfo/overlays/dev/kustomization.yaml:9: newTag: 6.17.0 apps/podinfo/overlays/prod/kustomization.yaml:9: newTag: 6.16.0 apps/podinfo/overlays/staging/kustomization.yaml:9: newTag: 6.16.0
newTag back to 6.16.0 and push: cd ~/gitops-lab/apps/podinfo/overlays/dev && kustomize edit set image ghcr.io/stefanprodan/podinfo:6.16.0 && git commit -am "dev: 6.16.0 for hour 6" && git push. The container name in the base keeps the one from Hour 1 podinfod.Step 2: Install the Argo Rollouts controller with Argo CD (platform components managed by GitOps)
Platform components also follow GitOps: in argocd/apps/ declare an Application that points to the official Helm chart. The Rollouts CRDs are large, so use ServerSideApply=true to avoid the annotation length limit of client-side apply.
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: argo-rollouts
namespace: argocd
spec:
project: platform
source:
repoURL: https://argoproj.github.io/argo-helm
chart: argo-rollouts
targetRevision: 2.43.12 # appVersion v1.10.2
helm:
valuesObject:
dashboard:
enabled: true # read-only UI, access via port-forward
destination:
server: https://kubernetes.default.svc
namespace: argo-rollouts
syncPolicy:
automated: { prune: true, selfHeal: true }
syncOptions: [CreateNamespace=true, ServerSideApply=true]
You can also directly kubectl apply -n argo-rollouts -f https://github.com/argoproj/argo-rollouts/releases/download/v1.10.2/install.yaml (the official manifest method). This lesson chooses Helm + Argo CD so that the platform components also have Git history.
Step 3: Install a slim Prometheus (the data source for AnalysisTemplate)
You only need one Prometheus server to scrape podinfo's metrics, so turn off Alertmanager, Pushgateway, node-exporter and kube-state-metrics. The chart's built-in kubernetes-pods scrape job will scrape pods with prometheus.io/scrape: "true" annotations, and map pod labels to metric labels (rollouts-pod-template-hash become rollouts_pod_template_hash) — Module 3 uses exactly this to tell canary from stable.
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: prometheus
namespace: argocd
spec:
project: platform
source:
repoURL: https://prometheus-community.github.io/helm-charts
chart: prometheus
targetRevision: 29.47.2 # Prometheus v3.16.0
helm:
valuesObject:
alertmanager: { enabled: false }
prometheus-pushgateway: { enabled: false }
prometheus-node-exporter: { enabled: false }
kube-state-metrics: { enabled: false }
server:
persistentVolume: { enabled: false }
retention: 6h
global:
scrape_interval: 15s # default is 1m, too slow for canary analysis
destination:
server: https://kubernetes.default.svc
namespace: monitoring
syncPolicy:
automated: { prune: true, selfHeal: true }
syncOptions: [CreateNamespace=true, ServerSideApply=true]
cd ~/gitops-lab git add argocd/apps/argo-rollouts.yaml argocd/apps/prometheus.yaml git commit -m "platform: argo-rollouts 2.43.12 + minimal prometheus 29.47.2" && git push # If you already have App of Apps (argocd/root.yaml, Hour 3), it is created automatically; otherwise apply manually: kubectl apply -f argocd/apps/argo-rollouts.yaml -f argocd/apps/prometheus.yaml argocd app wait argo-rollouts prometheus --health --timeout 300 kubectl get crd | grep argoproj.io | grep -E 'rollouts|analysis' kubectl -n monitoring get svc prometheus-server
analysisruns.argoproj.io 2026-11-17T02:10:11Z analysistemplates.argoproj.io 2026-11-17T02:10:11Z clusteranalysistemplates.argoproj.io 2026-11-17T02:10:11Z rollouts.argoproj.io 2026-11-17T02:10:12Z NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE prometheus-server ClusterIP 10.96.88.120 <none> 80/TCP 50s
app: podinfo, port http-metrics), and change the Prometheus address to http://kube-prometheus-stack-prometheus.monitoring:9090 (use your own release name). See the Prometheus & Grafana lesson.Step 4: Install the kubectl argo rollouts plugin
curl -LO https://github.com/argoproj/argo-rollouts/releases/download/v1.10.2/kubectl-argo-rollouts-linux-amd64 chmod +x kubectl-argo-rollouts-linux-amd64 sudo mv kubectl-argo-rollouts-linux-amd64 /usr/local/bin/kubectl-argo-rollouts kubectl argo rollouts version
kubectl-argo-rollouts: v1.10.2+… BuildDate: 2026-11-04T… GoVersion: go1.… Platform: linux/amd64
On macOS, use brew install argoproj/tap/kubectl-argo-rollouts. The plugin is just a client; ideally its version matches the controller.
Warm-up: answer from memory (30 seconds)
Whose changes does Argo CD's selfHeal revert?
Any change to a managed resource's spec that does not come from Git (kubectl edit, scale, set image…). This shapes many of this lesson's designs: the Rollouts promote / abort writes status or fields the controller manages itself, which selfHeal does not wipe out; whereas kubectl argo rollouts set image changing the spec, which gets reverted.
Why is a Deployment's RollingUpdate not enough?
It only checks whether Pods are Ready; it cannot “send 5% of traffic first, check metrics, then decide”, nor automatically roll back when metrics get worse. This is the value of Rollouts.
Module 1 · From CI to GitOps: Who Changes Git
- Explain the push model (CI directly
kubectl apply/helm upgrade) versus the pull model (an in-cluster agent pulls from Git), especially where the credentials live. - Design the flow “CI builds → pushes an immutable tag → opens a PR changing
apps/podinfo/overlays/dev/kustomization.yaml→ merge → Argo CD reconciles”, and explain why it is a PR rather than a direct push. - Distinguish the application code repository from the configuration (GitOps) repository, and know when they can be merged together.
What: what CI and CD each are responsible for
| Stage | Owner | Input | Output | Required permissions |
|---|---|---|---|---|
| CI (continuous integration) | GitHub Actions, GitLab CI, Jenkins… | Application code commit | Test report + immutable image ghcr.io/…/podinfo:6.17.0 (or digest) + a PR that changes the desired state | Push to the image registry; open a branch / PR to the GitOps repository |
| CD (continuous delivery / deployment) | In-cluster GitOps agent: Argo CD (or Flux) | Desired state in Git | Actual cluster state matches Git (Sync / Health) | Holds Kubernetes permissions only inside the cluster; read-only on Git |
In GitOps, the act of “deploying” is redefined as changing Git. CI no longer “deploys”; it just proposes a change (PR); after a person or rule approves the merge, CD takes care of converging the cluster. This way every deployment naturally has an author, a review record, a revertable commit and an auditable diff.
Why: why not let CI run kubectl apply directly
- credential boundary: the push model requires CI to hold cluster admin-level credentials (kubeconfig, cloud accounts). CI systems usually serve many repositories and contributors, making them high-value attack targets. In the pull model, cluster credentials never leave the cluster.
- drift: the push model only takes effect at the moment the pipeline runs; afterwards, if someone
kubectl editchanges it, nobody knows; the pull model continuously compares and can self-heal. - Rebuildability: if a cluster is deleted, the pull model only needs Argo CD reinstalled and pointed at the repository; the push model needs to “replay” all historical pipelines.
- Network direction: the pull model only requires outbound access from the cluster to Git; private clusters do not need to expose the API Server to CI.
How: standard flow (tool-agnostic)
- Developers push to the application repository commit code; CI runs tests and scans.
- CI builds the image and pushes it an immutable tag (a semantic version or Git SHA, for example
6.17.0,sha-3f2a1c9); it is best to record the digest. - CI, in the GitOps repository creates a branch and runs
kustomize edit set image ghcr.io/stefanprodan/podinfo:6.17.0(in theapps/podinfo/overlays/devdirectory), commits and opens a PR. - The dev environment can be configured for auto-merge (merge once checks pass); staging / prod are reviewed by people (Module 7).
- After merging, Argo CD discovers the new commit by polling (about 3 minutes by default) or via a Webhook, renders the overlay, detects OutOfSync and syncs automatically.
- The sync triggers the Rollout's canary (Modules 2, 3); results are reported via Notifications (Module 5).
When: how to split repositories
| Option | Suited for | Notes |
|---|---|---|
| Application repository + separate GitOps repository (this lesson) | Multiple teams, multiple environments, need independent permissions and auditing | CI needs write access to the GitOps repository (fine-grained PAT / GitHub App / Deploy Key) |
Single repository (code and deploy/ the directory together) | Small team, single service | Commits where CI changes manifests trigger CI again; need path filters or [skip ci] to prevent loops |
| Image automation controller changes Git (Module 4) | CI should not touch the GitOps repository at all | write permission moves to an in-cluster controller; version selection rules must be strict |
Compare with similar approaches
| Push model (CI deploys) | Pull model (GitOps: Argo CD / Flux) | |
|---|---|---|
| Cluster credentials | In CI | Only inside the cluster |
| Deployment record | Pipeline logs | Git commits + PR review |
| Drift detection | None | Continuous comparison, can self-heal or alert (Module 6) |
| Rollback | Re-run the old pipeline | git revert |
argocd app set --parameter image.tag=… to directly edit an Application, the desired state is no longer in Git; this is the push model in disguise. ② “Using latest tags to save effort” — changing tag content does not change Git, Argo CD sees no difference and cannot roll back; you must use immutable tags or digests. ③ “CI calls after the PR is merged argocd app sync to be faster” — this requires giving CI an Argo CD token; a better approach is to configure a Git Webhook (Hour 2).Architecture diagram: the boundary between CI and CD is a PR
Sequence: what one upgrade leaves behind in Git
Interactive animation: the same upgrade, push vs pull model
Select a mode and click “Play”. Watch where the credentials are, whether Git records the change, and what happens when someone makes a manual kubectl edit change afterwards.
Core commands and parameters
| Command | Purpose | Notes |
|---|---|---|
kustomize edit set image NAME=NEWNAME:TAG | Modify the kustomization.yaml's images: | Run in the overlay directory; can also use NAME@sha256:… to pin a digest. kubectl The built-in kustomize has no edit subcommand; a standalone kustomize CLI is required |
yq -i '.images[0].newTag = "6.17.0"' kustomization.yaml | Alternative when there is no kustomize CLI | The same applies to Helm values scenarios: yq -i '.image.tag = …' values/myapp/dev.yaml |
gh pr create --base main --head BRANCH | Open a PR on GitHub | --title,--body,--label; gh pr merge --auto --squash Enable auto-merge |
glab mr create | Open an MR on GitLab | You can also use git push -o merge_request.create push options |
crane digest IMAGE:TAG / docker buildx imagetools inspect | Get the image digest | Write the digest into Git to prevent “same tag, different content” |
argocd app diff podinfo-dev --revision BRANCH | Preview the cluster diff before merging | Can be added to PR checks and posted back to the PR as a comment |
cd ~/gitops-lab/apps/podinfo/overlays/dev kustomize edit set image ghcr.io/stefanprodan/podinfo:6.17.0 git diff
--- a/apps/podinfo/overlays/dev/kustomization.yaml +++ b/apps/podinfo/overlays/dev/kustomization.yaml @@ images: - name: ghcr.io/stefanprodan/podinfo - newTag: 6.16.0 + newTag: 6.17.0
GitHub Actions: open a PR after the build (snippet)
on:
push:
tags: ["v*"]
jobs:
bump-gitops:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
repository: <you>/gitops-lab
token: ${{ secrets.GITOPS_PR_TOKEN }} # only has contents/pull-requests write permission on gitops-lab
- name: Bump dev image
run: |
TAG="${GITHUB_REF_NAME#v}"
cd apps/podinfo/overlays/dev
kustomize edit set image ghcr.io/stefanprodan/podinfo:${TAG}
git switch -c ci/podinfo-${TAG}
git commit -am "dev: podinfo ${TAG}" && git push -u origin HEAD
gh pr create --fill --base main --label auto-merge
env:
GH_TOKEN: ${{ secrets.GITOPS_PR_TOKEN }}
Note:actions/checkout@v5 Same as the runner's built-in kustomize/gh Follow the official GitHub documentation; in production, it is recommended to use a GitHub App to generate short-lived tokens rather than a long-lived PAT. The GitLab equivalent is to use a Project Access Token to create an MR on the GitOps project; see GitLab lesson.
Lab 1: play the role of CI manually and submit an upgrade PR to dev (about 5 minutes)
This lab does not require actually writing CI — you run on your machine the commands that CI would run. For the real pipeline syntax, see the “Commands” page and the GitHub lesson.
argocd repo list kubectl -n argocd get secret -l argocd.argoproj.io/secret-type=repository -o name
A public repository may have no repository Secret at all — which shows Argo CD does not need write permission.
cd ~/gitops-lab && git switch main && git pull git switch -c ci/podinfo-6.17.0 cd apps/podinfo/overlays/dev kustomize edit set image ghcr.io/stefanprodan/podinfo:6.17.0 \ || sed -i 's/newTag: 6.16.0/newTag: 6.17.0/' kustomization.yaml # when there is no kustomize CLI kubectl kustomize . | grep image: git commit -am "dev: podinfo 6.17.0" && git push -u origin HEAD
image: ghcr.io/stefanprodan/podinfo:6.17.0 [ci/podinfo-6.17.0 5e1f2a7] dev: podinfo 6.17.0 1 file changed, 1 insertion(+), 1 deletion(-)
argocd app diff podinfo-dev --revision ci/podinfo-6.17.0
===== apps/Deployment podinfo-dev/podinfo ====== … < image: ghcr.io/stefanprodan/podinfo:6.16.0 --- > image: ghcr.io/stefanprodan/podinfo:6.17.0
At this point the cluster is still 6.16.0: the branch is not the one the Application tracks main.
gh pr create --base main --title "dev: podinfo 6.17.0" --body "CI simulated bump"
gh pr merge --squash --delete-branch
argocd app get podinfo-dev --refresh | grep -E 'Sync Status|Health Status'
kubectl -n podinfo-dev get pod -o jsonpath='{range .items[*]}{.spec.containers[0].image}{"\n"}{end}'
Sync Status: Synced to main (9a8b7c6) Health Status: Healthy ghcr.io/stefanprodan/podinfo:6.17.0 ghcr.io/stefanprodan/podinfo:6.17.0
cd ~/gitops-lab && git switch main && git pull git revert --no-edit HEAD && git push argocd app wait podinfo-dev --sync --health --timeout 180
In production, rollbacks should also go through a PR; for emergencies, see the break-glass process in Module 6.
Case 1: CI leaks a kubeconfig
Problem: A team's Jenkins stored a production cluster-admin kubeconfig, and a poisoned build plugin exfiltrated it. Fix: Migrate to the pull model: CI keeps only image registry push permission and PR permission on the GitOps repository (GitHub App, limited to a single repo); the cluster API Server switches to a private endpoint. Result: The worst outcome of a compromised CI becomes “submitting a PR that needs review”. Limitation: The GitOps repository itself becomes a high-value target; it needs branch protection, CODEOWNERS and signed commits.
Case 2: single-repo CI infinite loop
Problem: Code and deploy/ in the same repository; CI changes the tag and pushes, which triggers CI again, producing dozens of commits in a loop. Fix: Add paths-ignore: ["deploy/**"] to the workflow so bot commits skip CI; eventually the deployment manifests are split into a separate GitOps repository.
Case 3: latest tag causes “rollback has no effect”
Problem: Production uses :latest, and after the problem git revert had no effect — the content in Git never changed. Fix: All environments switched to semantic version tags + pinned digests (newTag: 6.17.0@sha256:… or digest: field), and the image registry enables immutable tags.
Common errors and fixes
PR has been merged, but Argo CD still shows the old version, Synced to an old commit
Cause: Argo CD by default polls the repository about every 3 minutes (timeout.reconciliation, Hour 2), and no Webhook is configured.
argocd app get podinfo-dev --refresh argocd app get podinfo-dev -o json | jq -r '.status.sync.revision'
Fix: Short term: use --refresh; long term, configure a Webhook on the GitOps repository pointing to /api/webhook.
remote: Permission to <you>/gitops-lab.git denied to github-actions[bot]. (403)
Cause: The workflow's default GITHUB_TOKEN only works for the current repository, and cannot write to another repository.
Fix: Use a fine-grained PAT or GitHub App token with contents: write and pull-requests: write for gitops-lab, stored as a Secret GITOPS_PR_TOKEN.
Error: unknown command "edit" for "kubectl kustomize"
Cause: The built-in kustomize in kubectl only supports build.
Fix: Install a standalone kustomize CLI, or use yq/sed to modify.
Argo CD sync succeeds, but the Pod stays in ImagePullBackOff: manifest unknown
Cause: CI opened the PR while the image push was still in progress, or the tag was misspelled.
kubectl -n podinfo-dev describe pod -l app=podinfo | grep -A3 Failed
Fix: Put “open PR” after the push step, and verify in a PR check that the image exists (crane digest).
1. In the dev overlay, pin podinfo to a digest (do not use a tag).
cd apps/podinfo/overlays/dev kustomize edit set image ghcr.io/stefanprodan/podinfo@sha256:<digest>
2. Without merging the branch, preview the differences podinfo-dev would produce on branch ci/x .
argocd app diff podinfo-dev --revision ci/x
The security team requires that “if the CI system is compromised, it cannot directly change production”. The current flow is that CI runs argocd app sync podinfo-prod. How would you redesign it?
Remove the Argo CD token from CI; CI only opens PRs. The prod overlay is protected by branch protection (CODEOWNERS + required review + required checks). Sync is done automatically by Argo CD (or manual sync + sync window, Module 6). To speed up the effect, configure a Git Webhook. This way, even if CI is compromised, the worst case is a single PR awaiting review.
Verified teaching video
Official documentation
- OpenGitOps principles
- Argo CD Best Practices (separating configuration and code repos)
- Git Webhook Configuration
Video storyboard (about 90 seconds)
This courseware cannot directly generate video/MP3; a storyboard and narration script are provided, which can be passed to a video tool.
Visual: in the CI box there is a red key (kubeconfig), with an arrow pointing directly at the cluster.
Narration: in the push model, the pipeline holds the cluster's key. The more places that hold keys, the greater the risk.
Visual: the key moves into Argo CD inside the cluster; CI only produces a PR, which shows newTag 6.16.0 → 6.17.0.
Narration: the pull model turns deployment into a commit. CI only proposes, review approves, and Argo CD executes in the cluster.
Visual: a merge commit and a revert commit appear on the timeline, and the cluster state beside it changes accordingly.
Narration: deployment is a commit, rollback is a reverse commit. Audit, review and rollback all reuse Git.
Module 2 · Argo Rollouts: Canary and Blue-Green
- Rewrite podinfo's Deployment as a
argoproj.io/v1alpha1Rollout, and understand how the controller manages one ReplicaSet per template version (stable / canary). - Write a canary
steps(setWeight,pause), and calculate how a weight converts into replica counts when there is no traffic routing; and use blueGreen'sactiveService/previewService. - Know how Argo CD displays Rollout health (paused → Suspended, aborted → Degraded), and resume / abort / promote-full etc. resource actions; understand which operations will be reverted by selfHeal.
What: the Rollout CRD
Argo Rollouts is a Kubernetes controller plus a set of CRDs (Rollout,AnalysisTemplate,ClusterAnalysisTemplate,AnalysisRun,Experiment). Rollout The spec.template,selector,replicas and Deployment are identical; the difference is in spec.strategy:
- canary: gradually shift traffic to the new ReplicaSet, following
stepssteps, and can insertpause(timed or indefinite),analysis,setCanaryScale,experimentand other steps. - blueGreen: the new version starts fully but receives no traffic;
previewServicepoints to the new version for verification, and after promote,activeServiceswitches at once, and the old version is scaled down afterscaleDownDelaySeconds(default 30 seconds).
The controller adds rollouts-pod-template-hash label to tell versions apart — this is also what the PromQL in Module 3 relies on to tell the canary apart.
Why: what a Deployment lacks
| Need | Deployment RollingUpdate | Rollout |
|---|---|---|
| Proportional rollout with a pause to observe | Not supported (can only pause the entire Deployment) | setWeight + pause |
| Automatic decision based on metrics | Only looks at readiness | AnalysisRun (Module 3) |
| Immediately return to the old version if there is a problem | rollout undo, requires a re-roll | abort: traffic instantly returns to the stable version that is still running |
| Precise traffic ratios / routing by header | Not supported | trafficRouting (Istio, NGINX, Gateway API plugins, etc.) |
How: without traffic routing, the “weight” is the replica ratio
This lab does not install a mesh; the Service podinfo selects both stable and canary Pods at the same time. The official docs state that in this case the controller will “do its best” to approximate using the replica ratio setWeight: 10 replicas, weight setWeight: 10 → 1 canary, 9 stable; setWeight: 41 → pick the integer with the smallest difference: canary 4, stable 6. With few replicas the precision is very poor: 4 replicas can only express 0 / 25 / 50 / 75 / 100%.
Configure trafficRouting with a trafficRouting, the behavior differs: the controller modifies the mesh / Ingress resource to set exact weights,the stable ReplicaSet keeps full replicas (so it can switch back instantly on abort); canary replicas = weight × total replicas; you also need canaryService and stableService two Services. The core controller no longer accepts new traffic providers; new implementations are provided as plugins (Gateway API is a plugin).
When: canary or blueGreen
- canary: stateless Web/API services, where you want to verify with a small part of real traffic.
- blueGreen: use it when a full smoke test is needed before switching traffic, or when the app cannot receive traffic from old and new versions at the same time (e.g. an incompatible session protocol). The cost is that resources briefly double.
- Neither fits: irreversible migrations with strong database schema dependencies — forward-compatible migrations must be done first.
Working with Argo CD
- Argo CD has built-in health checks for Rollouts: paused (
status.phase: Paused) shows as Suspended, in progress is Progressing, and after an abort is Degraded. - Built-in resource actions:
resume,abort,retry,pause,promote-full,skip-current-step,restart, can be run in the UI or inargocd app actions run. - selfHeal only compares fields that appear in Git. promote / abort change the status or controller-managed state and are not reverted; but
kubectl argo rollouts set imagechanging the spec gets reverted by Argo CD back to the value in Git —in GitOps, a version change can only be made in Git.
Comparison of similar tools: Argo Rollouts vs Flagger
| Argo Rollouts (v1.10.2) | Flagger (v1.45.0, Flux project) | |
|---|---|---|
| How it works | Uses Rollout CRD to replace Deployment (or use workloadRef to reference an existing Deployment) | Keeps your Deployment; uses Canary CRD to wrap it, and automatically generates -primary / -canary replicas and Services |
| Step orchestration | Explicit steps (setWeight, pause, analysis…) | Auto-advances according to stepWeight / maxWeight / interval its configured schedule |
| Metric analysis | AnalysisTemplate (Prometheus, Datadog, Web, Job, etc.) | Built-in request-success-rate / duration and MetricTemplate |
| Traffic routing | Optional; without routing, by replica ratio | Requires a mesh or Ingress (Istio, Linkerd, NGINX, Gateway API, etc.) |
| Ecosystem | Argo CD native health checks and UI extensions | Works most closely with Flux, but can also be used standalone |
setWeight: 10 is 10% of traffic” — without traffic routing and with few replicas, the actual ratio is determined by the replica count and is also affected by connection reuse. ② “Once a Rollout is aborted, the rollback is complete” — abort only switches traffic back to stable; Git still has the new version and the Application is Degraded, so you must roll back in Git (Module 3). ③ “Changing a Deployment into a Rollout needs no downtime” — direct replacement deletes the Deployment first and then creates the Rollout; for production migration, use workloadRef + scaleDown: progressively.Architecture diagram: objects managed by the Rollout controller
Flowchart: the two Services in blue-green
Interactive simulator: canary steps and replica conversion / blue-green switch
Choose the replica count and whether to enable traffic routing, then execute the steps one by one. Below each step, the controller's actions and the kubectl argo rollouts get approximate output.
Core commands and parameters (kubectl argo rollouts plugin)
| Command | Purpose | Is it safe under GitOps |
|---|---|---|
get rollout NAME --watch | Tree view of revision, ReplicaSets, Pods, AnalysisRuns, current step | Read-only |
status NAME | Outputs Healthy / Paused / Degraded; usable in scripts | Read-only |
promote NAME / --full | Skip the current pause / skip all remaining steps | Safe (does not change Git fields) |
abort NAME | Abort; traffic returns to stable | Safe; but Git still has the new version, so Git needs to be rolled back |
retry rollout NAME | Retry after abort | Safe |
set image / undo | Modify spec.template | Will be reverted by selfHeal, do not use in GitOps |
dashboard | Local UI (default port 3100) | Mainly read-only viewing |
argocd app actions run APP resume --kind Rollout | Execute actions via Argo CD RBAC | Recommended: permissions and audit live in Argo CD |
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
name: podinfo
spec:
replicas: 4
revisionHistoryLimit: 3
selector:
matchLabels:
app: podinfo
template:
metadata:
labels:
app: podinfo
annotations:
prometheus.io/scrape: "true" # Module 3: the slim Prometheus scrapes via annotations
prometheus.io/port: "9797"
spec:
containers:
- name: podinfod
image: ghcr.io/stefanprodan/podinfo:6.16.0
command: ["./podinfo", "--port=9898", "--port-metrics=9797", "--level=info"]
ports:
- { name: http, containerPort: 9898 }
- { name: http-metrics, containerPort: 9797 }
readinessProbe: # probes the metrics port; Module 3's random errors do not affect it
httpGet: { path: /healthz, port: 9797 }
periodSeconds: 5
livenessProbe:
httpGet: { path: /healthz, port: 9797 }
resources:
requests: { cpu: 10m, memory: 32Mi }
limits: { memory: 64Mi }
strategy:
canary:
steps:
- setWeight: 25
- pause: {duration: 30s}
- setWeight: 50
- pause: {} # indefinite pause: wait for manual promote
- setWeight: 75
- pause: {duration: 30s}
How to verify:kubectl kustomize apps/podinfo/overlays/dev | grep -A2 "kind: Rollout". Note: overlay's images: transformations also apply to Rollout (verified locally with kustomize v5); but commonLabels and strategic merge patches do not understand Rollout's structure; follow the official docs for rollout-transform configuration or openapi field.
Blue-green snippet
strategy:
blueGreen:
activeService: podinfo # user traffic
previewService: podinfo-preview # a Service you need to create separately (selector is also app: podinfo)
autoPromotionEnabled: false # switch only after a manual promote
scaleDownDelaySeconds: 30
Lab 2: convert podinfo to a Rollout and manually advance one canary (about 7 minutes)
rollout.yaml from the “Commands” page; save to apps/podinfo/base/, then:
cd ~/gitops-lab/apps/podinfo/base git rm -q deployment.yaml sed -i 's/- deployment.yaml.*/- rollout.yaml/' kustomization.yaml cat kustomization.yaml kubectl kustomize ../overlays/dev | grep -E '^kind:|image:'
resources:
- rollout.yaml
- service.yaml
kind: Service
kind: Rollout
image: ghcr.io/stefanprodan/podinfo:6.16.0
If your base comes from earlier lessons and differs, use this lesson's rollout.yaml as the reference, and confirm that the Service's selector is app: podinfo, port name http. The container name, consistent with Hour 1, is podinfod. podinfo also provides /metrics on the main port 9898, but this lesson additionally enables a separate metrics port 9797 (--port-metrics) and lets Prometheus scrape it: Module 3 turns on podinfo's random-error middleware, which applies to all routes on the main port (including /metrics and /healthz), while the metrics server on 9797 is unaffected.
cd ~/gitops-lab && git add -A && git commit -m "podinfo: Deployment -> Rollout (canary)" && git push argocd app sync podinfo-dev kubectl argo rollouts get rollout podinfo -n podinfo-dev
Name: podinfo
Namespace: podinfo-dev
Status: ✔ Healthy
Strategy: Canary
Step: 6/6
SetWeight: 100
ActualWeight: 100
Images: ghcr.io/stefanprodan/podinfo:6.16.0 (stable)
Replicas:
Desired: 4
Current: 4
Updated: 4
Ready: 4
Available: 4
NAME KIND STATUS AGE INFO
⟳ podinfo Rollout ✔ Healthy 40s
└──# revision:1
└──⧉ podinfo-6f8c9d5b7c ReplicaSet ✔ Healthy 40s stable
├──□ podinfo-6f8c9d5b7c-2xk8q Pod ✔ Running 40s ready:1/1
…
When the Rollout is created for the first time there is no “old version”; the controller creates everything at once without going through steps. With auto-sync prune enabled, the old Deployment will be deleted — at this moment podinfo has a brief Pod recreation; for production migration, use workloadRef.
cd ~/gitops-lab/apps/podinfo/overlays/dev kustomize edit set image ghcr.io/stefanprodan/podinfo:6.17.0 git commit -am "dev: podinfo 6.17.0" && git push argocd app get podinfo-dev --refresh >/dev/null kubectl argo rollouts get rollout podinfo -n podinfo-dev --watch
Status: ॥ Paused
Message: CanaryPauseStep
Strategy: Canary
Step: 3/6
SetWeight: 50
ActualWeight: 50
Images: ghcr.io/stefanprodan/podinfo:6.16.0 (stable)
ghcr.io/stefanprodan/podinfo:6.17.0 (canary)argocd app get podinfo-dev | grep -E 'Health Status|Rollout' argocd app actions list podinfo-dev --kind Rollout argocd app actions run podinfo-dev resume --kind Rollout --resource-name podinfo kubectl argo rollouts status podinfo -n podinfo-dev --timeout 3m
Health Status: Suspended argoproj.io Rollout podinfo-dev podinfo Suspended ACTION DISABLED abort false pause false promote-full false restart false resume false retry true skip-current-step false Healthy
You can also use kubectl argo rollouts promote podinfo -n podinfo-dev, both have the same effect; they differ in who controls permissions (Argo CD RBAC can grant it separately for action/argoproj.io/Rollout/resume).
kubectl argo rollouts set image podinfo podinfod=ghcr.io/stefanprodan/podinfo:6.15.0 -n podinfo-dev
sleep 20; kubectl -n podinfo-dev get rollout podinfo -o jsonpath='{.spec.template.spec.containers[0].image}{"\n"}'
ghcr.io/stefanprodan/podinfo:6.17.0
Argo CD self-heal changed the image back to 6.17.0 in Git. Conclusion: the version can only be changed through Git.
promote --full to speed it up):
cd ~/gitops-lab/apps/podinfo/overlays/dev kustomize edit set image ghcr.io/stefanprodan/podinfo:6.16.0 git commit -am "dev: back to 6.16.0" && git push && argocd app get podinfo-dev --refresh >/dev/null sleep 15; kubectl argo rollouts promote podinfo -n podinfo-dev --full
Case 1: migrate from Deployment to Rollout with no interruption
Problem: The production service has 30 replicas and cannot accept “delete the Deployment, then create a Rollout”. Fix: Following the official migration docs, first create a Rollout that references the existing Deployment (workloadRef: {apiVersion: apps/v1, kind: Deployment, name: podinfo, scaleDown: progressively}), once the Rollout's Pods are ready, gradually scale down the Deployment; after it is stable, move the template into the Rollout. Note: The Deployment stays in Git,replicas field must be removed from Git, or ignoreDifferences added; otherwise Argo CD will tug-of-war with the Rollouts controller.
Case 2: a “10% canary” with four replicas is actually 25%
Problem: The team configured setWeight: 10, but found that about 25% of requests went to the new version. Cause: Without traffic routing, with 4 replicas the minimum granularity is 1/4, so the controller rounds up to 1 canary Pod. Fix: Introduce trafficRouting for NGINX Ingress (or the Gateway API plugin) to split traffic precisely by weight, and at the same time use setCanaryScale to control the canary replica count.
Case 3: after a blue-green switch the old version disappears immediately, so a quick rollback is not possible
Problem:scaleDownDelaySeconds Set to 0; when a problem is found after switching, the blue version has already been scaled down. Fix: Keep the default 30 seconds or longer (for example 10 minutes), and pair it with postPromotionAnalysis: if analysis fails, traffic automatically switches back to the still-running old version.
Common errors and fixes
error: unable to recognize "…": no matches for kind "Rollout" in version "argoproj.io/v1alpha1"
Cause: The CRD is not installed yet, or the Application sync order is wrong.
kubectl get crd rollouts.argoproj.io argocd app get argo-rollouts
Fix: First make argo-rollouts Healthy; when using App of Apps, give it an earlier argocd.argoproj.io/sync-wave (Hour 2, 3), or add SkipDryRunOnMissingResource=true to the podinfo application.
Rollout stays Paused, Argo CD shows Suspended, with no error at all
Cause: It hit a pause: {} (indefinite pause). This is by design.
kubectl argo rollouts get rollout podinfo -n podinfo-dev | grep -E 'Step|Message'
Fix:promote or an Argo CD action resume. If you do not want the Application to show Suspended for a long time, change the pause to have a duration.
Argo CD and Rollouts keep modifying replicas back and forth; the Application flaps between Synced / OutOfSync
Cause: During an HPA or workloadRef migration,spec.replicas there are two writers.
Fix: Remove replicas from Git, or in the Application, for the Rollout / Deployment's /spec/replicas set ignoreDifferences and pair with RespectIgnoreDifferences=true.
The Rollout "podinfo" is invalid: spec.selector: Invalid value … `selector` does not match template `labels`
Cause: The overlay uses commonLabels to add labels to the template, but kustomize does not know the path of the Rollout's selector.
Fix: use labels: (without includeSelectors), or in kustomization introduce the official rollout-transform configuration.
1. Abort the Rollout in podinfo-dev via Argo CD (rather than the kubectl plugin).
argocd app actions run podinfo-dev abort --kind Rollout --resource-name podinfo
2. List the rollouts-pod-template-hash and replica count of each ReplicaSet in namespace podinfo-dev.
kubectl -n podinfo-dev get rs -L rollouts-pod-template-hash -o wide
The team wants “the new version first accessed internally using a Header X-Canary: 1 for 1 hour, then released to 5% externally”. Can this be achieved with only this lesson's Service selector? What is needed?
No. Routing by Header and an exact 5% both require trafficRouting: for example Istio (managedRoutes + setHeaderRoute step) or a Gateway API plugin / NGINX Ingress. Configure in the Rollout canaryService and stableService, with steps as setHeaderRoute → pause: {duration: 1h} → setWeight: 5. Without routing you can only approximate with the replica ratio, and Header is not supported.
Verified teaching video
Official documentation
Video storyboard (about 90 seconds)
Visual: the Deployment icon “morphs” into a Rollout; the Pod template part stays still, and a row of steps grows below.
Narration: a Rollout's Pod template is the same as a Deployment's; the difference is the release strategy: you can release step by step, or stop and wait.
Visual: 4 Pod cells, 1 turns yellow (canary), and a ratio bar shows 25%.
Narration: without traffic routing, the weight is the replica ratio. Four replicas can only express quarter-level granularity.
Visual: two sets of Pods for blue-green; the active Service's arrow jumps from blue to green.
Narration: blue-green uses two Services: preview verifies first; on promote, active switches in one go, and the old version scales down after a thirty-second delay.
Module 3 · AnalysisTemplate: Metric-Based Automatic Rollback
- Distinguish AnalysisTemplate (template),ClusterAnalysisTemplate (cluster-level template) and AnalysisRun (single execution), and read
interval,count,initialDelay,successCondition,failureLimit,consecutiveErrorLimit. - Use podinfo's
http_requests_total{status}to write a success-rate PromQL that only targets canary Pods (using therollouts_pod_template_hashlabel andpodTemplateHashValue: Latestparameters). - Explain the four outcomes of an AnalysisRun (Successful / Failed / Error / Inconclusive) and whether each makes the Rollout continue, abort or pause; and know why you still need to roll back in Git after an abort.
rate() and sum() (Prometheus lesson). Importance:★★★★★What: three objects
| Object | Scope | Analogy | Notes |
|---|---|---|---|
AnalysisTemplate | Namespace | Job template | Defines “what to measure, how often to measure, and how to decide it passes”; can be parameterized (args) |
ClusterAnalysisTemplate | Cluster | Shared template | Maintained uniformly by the platform team; a Rollout uses clusterScope: true to reference it |
AnalysisRun | Namespace | Job | Created by the Rollout at the right time; records each measurement's value and result, and finally Successful / Failed / Error / Inconclusive |
Why: automate “glancing at the monitor”
The bottleneck of manual canary is attention: releases at night, multiple services in parallel, and looking only at averages while ignoring the small canary Pod portion. AnalysisRun uses fixed queries, fixed thresholds and a fixed rhythm to judge; once it fails it aborts immediately — traffic returns to the still-running stable version within seconds.
How: the lifecycle of one background analysis
- Template change in Git → Rollout creates the canary ReplicaSet and executes
setWeight: 25. - When it reaches
startingStep, the controller creates an AnalysisRun based onstrategy.canary.analysis, and resolvesargsinto the actual value (for examplepodTemplateHashValue: Latest→7b54f1c9d8). - After waiting
initialDelay, everyintervala Prometheus query is executed; the result is a vector, so useresult[0]to take the value. - Meeting
successCondition→ this measurement is Successful; meetingfailureConditionor not meeting successCondition → Failed; query error → Error. - The failure count exceeds
failureLimit(default 0, meaning no failures are tolerated) → AnalysisRun Failed → Rollout abort: canary weight drops to zero; Rollout status is Degraded, and in Argo CD the Application Health becomes Degraded. - Consecutive errors exceed
consecutiveErrorLimit(default 4) → AnalysisRun Error, which also causes an abort. - All steps executed without analysis failing → the controller terminates the background analysis and records it as Successful; the canary becomes the new stable.
| AnalysisRun outcome | Rollout's reaction | Common causes |
|---|---|---|
| Successful | Continue / complete | Metrics meet target |
| Failed | abort, traffic returns to stable | Failure count > failureLimit |
| Error | abort | Prometheus unreachable, or an empty query result causing result[0] errors that consecutively exceed consecutiveErrorLimit |
| Inconclusive | Pause, waiting for a manual promote or abort | the value meets neither the success nor the failure condition, or consecutiveSuccessLimit is enabled (v1.8+) but has not reached |
When: background analysis, in-step analysis, pre/post blue-green analysis
- Background analysis (
strategy.canary.analysis): runs across the whole canary and keeps guarding — adopted in this lesson. - In-step analysis (
steps: - analysis:): starts only when that step is reached and blocks, suitable for “must finish one round of a load-test Job before going to 50%”. Withoutintervalit measures only once. - Blue-green:
prePromotionAnalysis(measured on preview before switching) andpostPromotionAnalysis(measured after switching; automatically switches back on failure). - Other providers: Web (HTTP JSON), Job (any script / smoke test), Datadog, New Relic, CloudWatch, Graphite, InfluxDB, Kayenta, etc., plus plugins.
rollouts_pod_template_hash="{{args.canary-hash}}" to select only the new version's Pods; the more rigorous approach is to also compare against stable (podTemplateHashValue: Stable).git revert, and the Rollout finds the new template matches stable and switches back directly without running steps. ② “The success rate is 100% when there is no traffic” — when there are no requests, 0/0 is NaN or an empty vector, so the measurement becomes Error or Failed; you must ensure traffic exists (load generator / synthetic probe) or handle NaN in the condition (e.g. isNaN(result[0]) || result[0] >= 0.95, use with caution). ③ “failureLimit: 1 means aborting on the first failure” — it means one failure is allowed; the second failure triggers the abort.Architecture diagram: AnalysisRun data path
State machine: how one measurement is counted
Core animation: canary + AnalysisRun verdict to promote or abort
Set the new version's real 5xx ratio, threshold and failureLimit, then play. Each tick represents 30 seconds: the controller advances the steps, while the AnalysisRun, after initialDelay queries Prometheus every 30 seconds. Watch when the failure count exceeds failureLimit, how traffic instantly returns to stable, and why you still need git revert.
Core commands and fields
| Command / field | Purpose | Notes |
|---|---|---|
kubectl -n NS get analysisrun | List AnalysisRuns and results | Name looks like podinfo-7b54f1c9d8-3-1 |
kubectl -n NS get analysisrun NAME -o yaml | View each measurement's value / phase | status.metricResults[].measurements |
kubectl argo rollouts get rollout NAME | The tree shows AnalysisRuns and ✔/✖ counts | The Message field shows the abort reason |
kubectl argo rollouts retry rollout NAME | Restart the current version after an abort | Use after fixing an environment problem (e.g. Prometheus is down) |
interval / count / initialDelay | Measurement cadence | Background analysis usually sets no count (runs until the release ends) |
successCondition / failureCondition | expr expression | result[0] >= 0.95; use a range query with all(result, # < 1000) |
failureLimit / consecutiveErrorLimit / consecutiveSuccessLimit | Tolerance | Defaults 0 / 4 / 0 (disabled) |
dryRun | Record only, does not affect the result | Observe a new metric before it goes live |
apiVersion: argoproj.io/v1alpha1
kind: AnalysisTemplate
metadata:
name: success-rate
spec:
args:
- name: canary-hash
- name: namespace
metrics:
- name: success-rate
initialDelay: 30s # wait for the canary Pod to be scraped a few times
interval: 30s
failureLimit: 1 # allow 1 failure; abort on the 2nd
successCondition: result[0] >= 0.95
provider:
prometheus:
address: http://prometheus-server.monitoring.svc.cluster.local
timeout: 20
query: |
sum(rate(http_requests_total{namespace="{{args.namespace}}",app="podinfo",
rollouts_pod_template_hash="{{args.canary-hash}}",status!~"5.."}[1m]))
/
sum(rate(http_requests_total{namespace="{{args.namespace}}",app="podinfo",
rollouts_pod_template_hash="{{args.canary-hash}}"}[1m]))
strategy:
canary:
analysis: # background analysis
templates:
- templateName: success-rate
startingStep: 1 # start from step 2 (the first pause)
args:
- name: canary-hash
valueFrom:
podTemplateHashValue: Latest
- name: namespace
valueFrom:
fieldRef:
fieldPath: metadata.namespace
steps:
- setWeight: 25
- pause: {duration: 2m}
- setWeight: 50
- pause: {duration: 2m}
- setWeight: 75
- pause: {duration: 1m}
How to verify PromQL: First run it in the Prometheus UI (kubectl -n monitoring port-forward svc/prometheus-server 9090:80, open http://localhost:9090), replace {{args.…}} with the actual value. Note: podinfo's http_requests_total has only status one business label, recorded by the HTTP middleware at the outermost layer, so it can see injected errors; the metrics port 9797 is a separate server and is not counted.
Lab 3: release a “bad version” and watch AnalysisRun abort it automatically (about 8 minutes)
cd ~/gitops-lab/apps/podinfo/base grep -q analysis-success-rate.yaml kustomization.yaml || sed -i '/- service.yaml/a - analysis-success-rate.yaml' kustomization.yaml kubectl kustomize ../overlays/dev | grep -E '^kind:' cd ~/gitops-lab && git add -A && git commit -m "podinfo: background analysis on canary success rate" && git push argocd app get podinfo-dev --refresh >/dev/null; argocd app wait podinfo-dev --health --timeout 300
Changing only strategy will not trigger the canary (the Pod template is unchanged).
for e in dev staging prod; do
kubectl -n podinfo-$e run loadgen --image=curlimages/curl:8.23.0 --restart=Never -- \
sh -c 'while true; do curl -s -o /dev/null http://podinfo:9898/; sleep 0.05; done'
done
kubectl -n monitoring port-forward svc/prometheus-server 9090:80 &
sleep 60
curl -s 'http://localhost:9090/api/v1/query' --data-urlencode \
'query=sum by (rollouts_pod_template_hash,status) (rate(http_requests_total{namespace="podinfo-dev"}[1m]))' | jq -r '.data.result[] | "\(.metric.rollouts_pod_template_hash) \(.metric.status) \(.value[1])"'
6f8c9d5b7c 200 18.9
PODINFO_RANDOM_ERROR=true (podinfo's built-in random-error middleware: about 1/3 of requests return 500/400/409, of which 5xx is about 1/9 ≈ 11%). Use a JSON patch, because it works equally well for CRDs such as Rollout:
cd ~/gitops-lab/apps/podinfo/overlays/dev
kustomize edit set image ghcr.io/stefanprodan/podinfo:6.17.0
cat >> kustomization.yaml <<'EOF'
patches:
- target: { kind: Rollout, name: podinfo }
patch: |-
- op: add
path: /spec/template/spec/containers/0/env
value: [{ name: PODINFO_RANDOM_ERROR, value: "true" }]
EOF
kubectl kustomize . | grep -A2 'env:'
git commit -am "dev: podinfo 6.17.0 (bad build simulation)" && git push
argocd app get podinfo-dev --refresh >/dev/null
kubectl argo rollouts get rollout podinfo -n podinfo-dev --watchkubectl -n podinfo-dev get analysisrun
AR=$(kubectl -n podinfo-dev get analysisrun -o name | tail -1)
kubectl -n podinfo-dev get $AR -o jsonpath='{range .status.metricResults[0].measurements[*]}{.phase}{" "}{.value}{"\n"}{end}'
NAME STATUS AGE podinfo-7b54f1c9d8-2-1 Failed 2m10s Successful [0.9312…] ← random fluctuation; may occasionally pass Failed [0.8843…] Failed [0.8917…]
Status: ✖ Degraded Message: RolloutAborted: Rollout aborted update to revision 2: Metric "success-rate" assessed Failed due to failed (2) > failureLimit (1) Strategy: Canary Step: 0/6 SetWeight: 0 ActualWeight: 0 Images: ghcr.io/stefanprodan/podinfo:6.16.0 (stable)
argocd app get podinfo-dev | grep -E 'Sync Status|Health Status'
Sync Status: Synced to main (b7e1d0a) Health Status: Degraded
Synced (cluster objects match Git) but Degraded (Rollout aborted). This is the trigger condition for the on-health-degraded notifications in Module 5.
cd ~/gitops-lab && git revert --no-edit HEAD && git push argocd app get podinfo-dev --refresh >/dev/null kubectl argo rollouts status podinfo -n podinfo-dev --timeout 2m argocd app get podinfo-dev | grep 'Health Status'
Healthy Health Status: Healthy
After revert, the template matches the stable ReplicaSet; the controller recovers directly without going through canary steps.
kubectl delete pod -A -l run=loadgen.Case 1: a low-traffic service is wrongly judged as failed
Problem: Night-time traffic is extremely low; the canary Pod gets only a few requests within 1 minute, and one occasional 500 drops the success rate to 80%, causing frequent aborts. Fix: Extend the query window to 5m; add the condition “judge only when request volume is sufficient” (a second metric counts requests; when volume is low, Inconclusive hands the decision to a human); or do not release during traffic troughs (sync window, Module 6).
Case 2: a Prometheus upgrade aborts all releases
Problem: During a platform Prometheus upgrade, all AnalysisRuns errored continuously, and releases for dozens of services were aborted. Fix: Make Prometheus itself highly available (two replicas + query frontend); avoid platform changes during release windows; after recovery, use kubectl argo rollouts retry to retry. Lesson: Analysis dependencies are also production dependencies.
Case 3: compare with stable instead of an absolute threshold
Problem: A service's baseline error rate is already 3% (a third-party dependency), so a fixed threshold of 0.99 always fails. Fix: Use podTemplateHashValue: Stable to also query stable's success rate at the same time; write the condition as “canary is not lower than stable minus 1 percentage point” (computed with a PromQL difference), or use an Experiment to run baseline and canary side by side.
Common errors and fixes
Metric "success-rate" assessed Error due to consecutiveErrors (5) > consecutiveErrorLimit (4): "Error Message: reflect: slice index out of range"
Cause: The query returns an empty vector (wrong labels, Prometheus has not scraped the canary Pod yet, or there is no traffic), causing result[0] a value to go out of range.
kubectl -n podinfo-dev get analysisrun -o yaml | grep -A3 'message' # Run the same query in the Prometheus UI to confirm the rollouts_pod_template_hash label exists
Fix: Check the Pod annotations prometheus.io/scrape/port; increase initialDelay; confirm there is traffic.
dial tcp: lookup prometheus-server.monitoring.svc.cluster.local: no such host
Cause: Wrong address or Prometheus is not deployed. Note that the request is sent by the Rollouts controller (in namespace argo-rollouts), so the NetworkPolicy must allow it to access monitoring.
kubectl -n monitoring get svc kubectl -n argo-rollouts logs deploy/argo-rollouts | grep -i analysis | tail
AnalysisRun stays Running, but the Rollout is complete and has no result
Cause: After the Rollout completes, the controller terminates the background analysis and records its status as Successful (unless failureLimit has already been violated). If the Rollout is stuck in an indefinite pause, the background analysis keeps running.
Fix: Confirm there is no pause: {} in steps, or promote manually.
args.canary-hash: value is required / failed to resolve {{args.namespace}}
Cause: The parameter declared in AnalysisTemplate has no default value, and the Rollout does not pass it (name mismatch).
Fix: Keep the parameter name exactly the same in the template and the Rollout; use kubectl kustomize to check the rendered result.
1. Output the value and result of each measurement in the latest AnalysisRun.
AR=$(kubectl -n podinfo-dev get analysisrun --sort-by=.metadata.creationTimestamp -o name | tail -1)
kubectl -n podinfo-dev get $AR -o jsonpath='{range .status.metricResults[*].measurements[*]}{.phase} {.value}{"\n"}{end}'2. After Prometheus recovers, retry the aborted release.
kubectl argo rollouts retry rollout podinfo -n podinfo-dev # or: argocd app actions run podinfo-dev retry --kind Rollout --resource-name podinfo
Canary at 25%, the canary Pod's 5xx is 12%, but AnalysisRun stays Successful. The query is sum(rate(http_requests_total{app="podinfo",status!~"5.."}[1m])) / sum(rate(http_requests_total{app="podinfo"}[1m])). What is the problem?
The query covers Pods of all versions, so bad traffic is diluted by stable: overall 5xx ≈ 25% × 12% = 3%, success rate about 0.97, above 0.95. You should add rollouts_pod_template_hash="{{args.canary-hash}}" (the parameter comes from podTemplateHashValue: Latest), and also restrict namespace to avoid mixing with Pods of the same hash from other environments.
Verified teaching video
Official documentation
Video storyboard (about 100 seconds)
Visual: one yellow canary Pod and three green stable Pods; metrics flow from the canary Pod to Prometheus; the rollouts_pod_template_hash label is highlighted.
Narration: first make sure only the canary is measured. The pod template hash label is the key that tells the old and new versions apart.
Visual: a line chart with a point every 30 seconds and a threshold line at 0.95; the first point is above the line, the next two are below it, and the failed counter goes 1 → 2.
Narration: failureLimit is the number of allowed failures. Beyond it, AnalysisRun judges the run as failed.
Visual: the ratio bar instantly returns to 100% green; the Argo CD card shows Synced plus Degraded; finally a git revert commit appears and the card turns Healthy.
Narration: aborting sends traffic back to stable immediately, but Git still has the bad version. The real rollback is a revert commit.
Module 4 · Argo CD Image Updater
- Explain Image Updater's working loop: read
ImageUpdaterCR → match Application → query image registry tags → select version by strategy → write back. - Understand the configuration change since v1.0: from Application annotations to
argocd-image-updater.argoproj.io/v1alpha1ImageUpdaterCRD (the annotation approach remains usable viauseAnnotations: truecompatibility). - Compare
argocdandgitthe two write-back methods, and usewriteBackTarget: kustomizationwith a write-back branch template to work with PR review; can be compared with Flux's image automation.
What: a controller that “changes Git on CI's behalf”
Argo CD Image Updater runs in the cluster where Argo CD is (it must be in the same cluster as the Application), periodically checks the image registry, and when it finds new tags matching the rules, updates the image the application uses. It is a project under argoproj-labs (not part of the Argo CD core distribution); as of 2026-11 the latest is v1.5.0; the 0.x line still has maintenance releases (v0.19.0), and new deployments should use 1.x.
v1.x configuration: ImageUpdater CRD
apiVersion: argocd-image-updater.argoproj.io/v1alpha1
kind: ImageUpdater
metadata:
name: podinfo-dev
namespace: argocd # must be the same namespace as the managed Application
spec:
commonUpdateSettings: # global defaults (can be overridden at applicationRefs / images level)
updateStrategy: semver
writeBackConfig:
method: "git:secret:gitops-lab-writer"
gitConfig:
branch: main
writeBackTarget: kustomization
applicationRefs:
- namePattern: podinfo-dev # supports wildcards and labelSelectors
images:
- alias: podinfo
imageName: ghcr.io/stefanprodan/podinfo:6.x # the part after the colon is the version constraint
Update strategy
| Strategy | Which tag is chosen | Suited for |
|---|---|---|
semver (default) | The highest semantic version that satisfies the constraint (e.g. 6.x,6.16.x) | Official release versions |
newest-build (formerly latest) | The most recently built tag (requires reading image metadata; used together with allowTags filtering) | The dev environment that uses a Git SHA as the tag |
digest | The latest digest of a mutable tag (such as stable) | Only usable for upstream images with mutable tags |
alphabetical (formerly name) | The lexicographically largest tag | Date-style tags |
calver | The latest in calendar-version format (such as vYYYY-0M-0D) | Calendar-version releases |
Write-back method: argocd vs git
argocd (default) | git | |
|---|---|---|
| Where to change | Directly modify the Application's source parameters in the cluster (similar to argocd app set --kustomize-image) | Commit to Git: the default write is .argocd-source-<appName>.yaml; writeBackTarget: kustomization when changing kustomization.yaml (equivalent to kustomize edit set image); Helm can use helmvalues:<path> |
| Persistence | Pseudo-persistent: when the Application is managed by Git (App of Apps), it will be overwritten at the next sync | Persistent, has commit history, can be reverted |
| Credentials | Only needs Kubernetes permissions | Needs Git write permission: by default reuses Argo CD's repository credentials (git:repocreds), or git:secret:<name> specify a Secret (must be in the same namespace as the CR) |
| GitOps purity | Desired state is not in Git | Conforms to GitOps |
Write-back branch: gitConfig.branch can be written as main:image-updater-{{.SHA256}} style “base branch:write branch”; the controller pushes commits to a new branch instead of writing directly to main — then CI or GitHub automatically opens a PR for that branch, which lets you combine automatic discovery with human review (Image Updater itself does not create PRs).
When: Image Updater, CI opening a PR, or Flux
| CI opens a PR (Module 1) | Argo CD Image Updater | Flux image automation | |
|---|---|---|---|
| Trigger | Immediately after the build completes | polling (--interval) or image registry Webhook | ImageRepository periodic scan |
| Configuration objects | Pipeline script | ImageUpdater CR (v1alpha1) | ImageRepository / ImagePolicy (image-reflector-controller) + ImageUpdateAutomation (image-automation-controller), API image.toolkit.fluxcd.io/v1, controller v1.3.0 (Flux v2.10.0) |
| How it changes Git | Arbitrary (script) | kustomization / Helm values / .argocd-source-* | setter marker comments in YAML # {"$imagepolicy": "ns:name"} |
| Suited for | versions map one-to-one to builds, and change notes need to be attached | upstream third-party images; dev environment auto-follows | Flux ecosystem |
Architecture diagram: one loop of Image Updater (git write-back)
Comparison: write back to main or to a branch
Interactive simulator: given a tag list, which one will Image Updater choose?
The tags in the image registry are examples (including pre-release, mutable and SHA tags). Choose a strategy and constraint, observe the filtering and selection process, and the diff the write-back would produce.
Core commands and configuration
| Command / field | Purpose | Notes |
|---|---|---|
kubectl -n argocd get imageupdaters | List CRs | The status records the most recent check and update |
kubectl -n argocd logs deploy/argocd-image-updater-controller | View the selection process | Deployment name follows the chart (kubectl -n argocd get deploy | grep image-updater) |
argocd-image-updater test IMAGE --semver-constraint 6.x | Test locally which tag would be selected | Changes nothing; can also be run inside the controller container |
allowTags / ignoreTags | Filter tags | regexp:^\d+\.\d+\.\d+$; ["latest","sha-*"] |
writeBackConfig.method | argocd / git / git:secret:NAME / git:repocreds | can be set at global or applicationRefs level |
gitConfig.writeBackTarget | kustomization[:path] / helmvalues[:path] | Default write .argocd-source-<app>.yaml |
useAnnotations: true | Keep the 0.x Application annotations | For use during migration; the configuration in the CR other than the selector is ignored at this time |
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: argocd-image-updater
namespace: argocd
spec:
project: platform
source:
repoURL: https://argoproj.github.io/argo-helm
chart: argocd-image-updater
targetRevision: 1.5.0 # appVersion v1.5.0, includes CRDs (crds.install: true)
destination:
server: https://kubernetes.default.svc
namespace: argocd # official recommendation: same namespace as Argo CD
syncPolicy:
automated: { prune: true, selfHeal: true }
syncOptions: [ServerSideApply=true]
apiVersion: argocd-image-updater.argoproj.io/v1alpha1
kind: ImageUpdater
metadata:
name: podinfo-dev
namespace: argocd
spec:
writeBackConfig:
method: "git:secret:gitops-lab-writer"
gitConfig:
branch: main
writeBackTarget: kustomization # modify overlays/dev/kustomization.yaml
applicationRefs:
- namePattern: podinfo-dev
images:
- alias: podinfo
imageName: ghcr.io/stefanprodan/podinfo:6.x
commonUpdateSettings:
updateStrategy: semver
ignoreTags: ["latest"]
Note: Kustomize write-back uses the Application's spec.source.path (apps/podinfo/overlays/dev) to locate kustomization.yaml; imageName Must match the images[].name in kustomization. ghcr.io and Docker Hub are built-in recognized registries, so public images usually need no extra configuration; when you hit 401 or rate limits, add credentials in registries configuration.
Lab 4: have dev automatically upgrade from 6.16.0 to 6.17.0 (about 7 minutes)
gitops-lab with Contents read/write permission.
kubectl -n argocd create secret generic gitops-lab-writer \ --from-literal=username=<you> --from-literal=password=<fine-grained-PAT>
In the lab, create it with kubectl; in production, store it encrypted as described in Hour 5 (Sealed Secrets / ESO).
cd ~/gitops-lab && mkdir -p argocd/image-updaters # save argocd/apps/image-updater.yaml and argocd/image-updaters/podinfo-dev.yaml git add argocd && git commit -m "platform: argocd-image-updater 1.5.0 + podinfo-dev updater" && git push kubectl apply -f argocd/apps/image-updater.yaml argocd app wait argocd-image-updater --health --timeout 180 kubectl apply -f argocd/image-updaters/podinfo-dev.yaml # you can also create another Application to manage this directory kubectl -n argocd get imageupdaters
NAME AGE podinfo-dev 10s
kubectl -n argocd logs deploy/argocd-image-updater-controller --since=5m | grep -iE 'podinfo|updat|commit' cd ~/gitops-lab && git pull && git log -1 --stat grep newTag apps/podinfo/overlays/dev/kustomization.yaml
… msg="Setting new image to ghcr.io/stefanprodan/podinfo:6.17.0" alias=podinfo application=podinfo-dev … msg="Successfully updated image 'ghcr.io/stefanprodan/podinfo:6.16.0' to 'ghcr.io/stefanprodan/podinfo:6.17.0'" … msg="Committing 1 parameter update(s) for application podinfo-dev" commit 4c2e… build: automatic update of podinfo-dev apps/podinfo/overlays/dev/kustomization.yaml | 2 +- newTag: 6.17.0
kubectl argo rollouts get rollout podinfo -n podinfo-dev --watch
branch to "main:image-updater-{{.SHA256}}", a branch is created when a new version appears, and you open a PR from that branch on GitHub. Since podinfo is already the latest 6.x, you can set dev back to 6.16.0 to observe.kubectl -n argocd delete imageupdater podinfo-dev.Case 1: argocd write-back is wiped out by App of Apps
Problem: The team used the default argocd write-back: Image Updater changed the Application, but the root application (App of Apps) self-healed and changed the Application back to the version in Git, and the two tugged back and forth every few minutes. Fix: switch to git write-back; wherever the Application itself is managed by Git, do not use argocd write-back.
Case 2: a pre-release tag went to production
Problem: The constraint was written as *, and upstream pushed 7.0.0-rc.1. Fix: Production uses only an exact minor-version constraint (6.16.x), and excludes pre-releases via allowTags: regexp:^\d+\.\d+\.\d+$ ; production goes through write-branch + PR.
Case 3: no longer updating after migrating to 1.x
Problem: After upgrading the chart to 1.x, all applications stopped updating. Cause: Starting from 1.0, configuration moved to ImageUpdater CRs; the original annotations no longer take effect automatically. Fix: Following the migration guide, create CRs for each group of applications; during the transition period, use useAnnotations: true + labelSelectors to read the legacy annotations.
Common errors and fixes
could not get tags from registry: … 401 Unauthorized / 429 Too Many Requests
Cause: Private images need credentials, or anonymous access is rate-limited.
Fix: In the chart values' config.registries section, configure credentials for this prefix via credentials: pullsecret:argocd/regcred etc., or in the CR's commonUpdateSettings.pullSecret field, specify it.
could not update application spec: … authentication required / Permission denied (publickey)
Cause: git write-back lacks write permission. By default it reuses Argo CD's repository credentials, and public repositories often have no credentials configured at all.
kubectl -n argocd get secret gitops-lab-writer -o jsonpath='{.data}' | jq 'keys'
Fix: The Secret must contain username/password (HTTPS) or sshPrivateKey (SSH), and be in the same namespace as the CR; method: "git:secret:gitops-lab-writer".
skipping app 'podinfo-dev' of type 'Directory' because it's not of supported source type
Cause: The Application's source is identified as a plain directory.
Fix: Confirm the path contains kustomization.yaml (Kustomize) or is a Helm chart.
The Application switches back and forth between two versions
Cause: The namePattern of two ImageUpdater CRs both match this application (the official docs explicitly state they will overwrite each other), or CI is also changing the same tag.
Fix: Ensure each application is matched by only one CR; make it explicit that “each field has only one writer”.
1. Without changing anything, test 6.16.x which tag the constraint would select for podinfo.
kubectl -n argocd exec deploy/argocd-image-updater-controller -- \ argocd-image-updater test ghcr.io/stefanprodan/podinfo --semver-constraint 6.16.x
2. Change podinfo-dev's write-back to image-updater- prefixed new branch.
kubectl -n argocd patch imageupdater podinfo-dev --type merge -p \
'{"spec":{"writeBackConfig":{"gitConfig":{"branch":"main:image-updater-{{.SHA256}}"}}}}'The platform team maintains 30 third-party components at once (ingress-nginx, cert-manager images, etc.); they want patch versions to enter dev automatically while minor versions require review. How would you design it?
dev: one ImageUpdater CR, uses labelSelectors to select dev applications, with the constraint X.Y.x (following only patch versions), git write-back directly to main. Minor versions: another CR only does discovery (constraint X.x), writing to main:image-updater-{{.SHA256}} branches, with a bot opening PRs for human review. All CRs are placed in Git and managed by Argo CD; ensure each application is matched by only one CR (distinguish them with different labels).
Verified teaching video
Official documentation
- Argo CD Image Updater documentation
- Update methods (write-back)
- Migration (annotations → CRD)
- Flux: Automate image updates to Git
Video storyboard (about 80 seconds)
Visual: a new tag card 6.17.0 appears in the image registry, and the controller's “radar” picks it up.
Narration: Image Updater periodically checks the image registry and only cares about tags that match the rules.
Visual: the tag list is filtered: latest, sha tags and pre-releases are struck out, and 6.17.0 is selected.
Narration: the strategy decides the choice: semver takes the highest version within the constraint, newest-build takes the latest build, and digest tracks the digest of a mutable tag.
Visual: two paths: argocd write-back only changes the Application in the cluster (dashed line, overwritten by App of Apps); git write-back produces a commit (solid line).
Narration: to conform to GitOps, write the version back to Git.
Module 5 · Notifications: Notification Triggers and Templates
- Explain the four concepts of notifications-controller: trigger (expr conditions),template (Go templates),service (Slack, Webhook, Email, Teams, GitHub…),subscription (annotation or global subscription).
- Use Helm values (
notifications.notifiers / templates / triggers) to configure a local Webhook service, and useoncePerto avoid duplicate notifications. - Be able to use
argocd admin notificationsto test triggers and templates offline, and know that Argo Rollouts has its own notifications (e.g. abort events).
What: Argo CD Notifications
Notifications was originally a standalone project and is now merged into Argo CD, as argocd-notifications-controller installed by default with the official Helm chart (notifications.enabled: true). It watches Application (and AppProject) objects, and all its configuration is placed in a ConfigMap argocd-notifications-cm and a Secret argocd-notifications-secret .
| Concept | Config key | Example |
|---|---|---|
| Service (where to send) | service.<type>[.<name>] | service.webhook.local,service.slack |
| Template (what to send) | template.<name> | Common message + service-specific fields (slack.attachments,webhook.<name>.body) |
| Trigger (when to send) | trigger.<name> | when: app.status.health.status == 'Degraded',send: [template] |
| Subscription (who subscribes) | Annotation notifications.argoproj.io/subscribe.<trigger>.<service>: <recipient>, or in cm subscriptions | multiple recipients separated by semicolons; added on an AppProject it applies to the whole project |
Official catalog provides commonly used triggers: on-created,on-deleted,on-deployed (sync succeeded and healthy, once per commit),on-health-degraded,on-sync-failed,on-sync-running,on-sync-status-unknown,on-sync-succeeded. Note: the Helm chart's templates / triggers defaults to empty; you need to define it yourself or apply the directory manifest separately.
Why: GitOps's “feedback loop”
In the push model, pipeline logs are the feedback; in the pull model, the person who merges the PR cannot see what happened in the cluster. Notifications send results back to people (Slack channel) and to systems (GitHub commit status, event bus, ticketing system). Module 3's “Synced but Degraded” especially needs notification, otherwise a bad version may sit in Git for a long time.
How: the processing flow of one notification
- The controller detects an Application change (e.g. health changes from Progressing to Degraded).
- For each trigger subscribed by the application, evaluate
whencondition (expr language; optional chaining?.preventsoperationStateerrors when empty). - If the condition is true and it has not been sent (deduplicated by the value of the
oncePerfield or by a change in condition status) → rendersendtemplates (Go template; can use.app,.context.argocdUrl,.serviceTypeetc.). - Hand it to the corresponding service to send; if the Webhook fails (network error or 5xx), it is retried
retryMaxtimes (default 3). - The sending state is recorded in the Application annotation
notified.notifications.argoproj.io, used for deduplication.
When: where subscriptions go
- Team's own applications: Application annotations (in Git alongside the Application).
- Whole team / project: AppProject annotations.
- Platform-level fallback (sync failed for all apps goes to #platform-alerts): in cm,
subscriptions, can be filtered byselectorlabels. - Rollout-level events (abort, pause, analysis failure): Argo Rollouts' built-in notification engine; ConfigMap
argo-rollouts-notification-configmap, triggers such ason-rollout-aborted, subscription annotations are added on the Rollout.
on-deployed (sync succeeded + Healthy) and on-health-degraded. ③ “A Slack token can be written in a ConfigMap” — secrets belong in argocd-notifications-secret, and in cm use $key to reference them.Architecture diagram: notifications-controller
Interactive simulator: which notifications does one event trigger?
Click “Application state change” below in turn, and observe each trigger's evaluation result,oncePer deduplication, and the Webhook request body sent. Note that during “health flapping”, on-deployed will not send repeatedly.
Core commands
| Command | Purpose |
|---|---|
argocd admin notifications trigger get | List configured triggers |
argocd admin notifications template get | List configured templates |
argocd admin notifications trigger run TRIGGER APP | Evaluate triggers for an application (without sending) |
argocd admin notifications template notify TEMPLATE APP --recipient SERVICE:RECIPIENT | Render and send once immediately, for debugging templates |
kubectl -n argocd logs deploy/argocd-notifications-controller | View send records and errors |
argocd admin The subcommand reads the cm/Secret in the cluster directly (using the current kubeconfig, adding -n argocd), without going through the API Server.
notifications:
argocdUrl: https://localhost:8080
notifiers:
service.webhook.local: |
url: http://webhook-sink.webhook-sink.svc.cluster.local:8080/argocd
headers:
- name: Content-Type
value: application/json
# service.slack: |
# token: $slack-token # value comes from argocd-notifications-secret
templates:
template.app-event: |
message: "{{.app.metadata.name}} sync={{.app.status.sync.status}} health={{.app.status.health.status}}"
webhook:
local:
method: POST
body: |
{"app":"{{.app.metadata.name}}","sync":"{{.app.status.sync.status}}",
"health":"{{.app.status.health.status}}","revision":"{{.app.status.sync.revision}}",
"url":"{{.context.argocdUrl}}/applications/{{.app.metadata.name}}"}
triggers:
trigger.on-deployed: |
- when: app.status?.operationState?.phase in ['Succeeded'] and app.status.health.status == 'Healthy'
oncePer: app.status.sync.revision
send: [app-event]
trigger.on-health-degraded: |
- when: app.status.health.status == 'Degraded'
send: [app-event]
trigger.on-sync-failed: |
- when: app.status?.operationState?.phase in ['Error', 'Failed']
send: [app-event]
metadata:
name: 'podinfo-{{.env}}' # existing form from Hour 3, keep unchanged
annotations:
notifications.argoproj.io/subscribe.on-deployed.local: ""
notifications.argoproj.io/subscribe.on-health-degraded.local: ""
notifications.argoproj.io/subscribe.on-sync-failed.local: ""
podinfo-dev / staging / prod are generated by the Hour 3 ApplicationSet; podinfo subscription annotations must be written in the ApplicationSet template— directly editing the generated Application will be reverted by the ApplicationSet controller. name The line should follow your Hour 3 template (parameter names may differ). When using the minimal starting point (a hand-written argocd/apps/podinfo-dev.yaml), add the annotation to that Application's metadata. The Webhook service has no concept of a “recipient”, so leave the subscription value as an empty string. The Slack form is subscribe.on-health-degraded.slack: my-channel.
Lab 5: send deployment events to a local Webhook receiver (about 7 minutes)
mendhak/http-https-echo will print received requests to the log; for lab use only):
kubectl create namespace webhook-sink kubectl -n webhook-sink create deployment webhook-sink --image=mendhak/http-https-echo:43 --port=8080 kubectl -n webhook-sink expose deployment webhook-sink --port=8080 kubectl -n webhook-sink rollout status deploy/webhook-sink
cd ~/gitops-lab helm upgrade argocd argo/argo-cd -n argocd --version 10.18.0 -f bootstrap/argocd-values.yaml --wait argocd admin notifications trigger get -n argocd argocd admin notifications template get -n argocd
NAME TEMPLATE CONDITION
on-deployed app-event app.status?.operationState?.phase in ['Succeeded'] and app.status.health.status == 'Healthy'
on-health-degraded app-event app.status.health.status == 'Degraded'
on-sync-failed app-event app.status?.operationState?.phase in ['Error', 'Failed']
NAME PREVIEW
app-event {{.app.metadata.name}} sync={{.app.status.sync.status}} health=…
If Argo CD itself is managed by Argo CD (self-managed, Hour 3), commit the values to Git instead.
argocd/apps/podinfo-dev.yaml):
git add argocd/appsets/podinfo.yaml && git commit -m "podinfo: subscribe local webhook" && git push
kubectl apply -f argocd/appsets/podinfo.yaml # or wait for the root application to sync
kubectl -n argocd get app podinfo-dev -o jsonpath='{.metadata.annotations}' | jq 'with_entries(select(.key|startswith("notifications")))'
argocd admin notifications trigger run on-deployed podinfo-dev -n argocd
argocd admin notifications template notify app-event podinfo-dev --recipient local: -n argocd
kubectl -n webhook-sink logs deploy/webhook-sink --tail=30 | grep -E '"path"|"body"'
CONDITION RESULT
app.status?.operationState?.phase in ['Succeeded'] and … true
"path": "/argocd",
"body": "{\"app\":\"podinfo-dev\",\"sync\":\"Synced\",\"health\":\"Healthy\",\"revision\":\"4c2e…\",…}",kubectl -n webhook-sink logs deploy/webhook-sink -f | grep --line-buffered '"body"'
"body": "{\"app\":\"podinfo-dev\",\"sync\":\"Synced\",\"health\":\"Degraded\",…}"
After revert, you will receive one more on-deployed (new revision).
argo-rollouts namespace's argo-rollouts-notification-configmap, trigger names such as on-rollout-aborted, and subscription annotations are added to the Rollout: notifications.argoproj.io/subscribe.on-rollout-aborted.local: "". The field format is the same as Argo CD's (same notifications-engine).Case 1: the channel is flooded with notifications
Problem: Using when: app.status.health.status == 'Healthy' as “deployment succeeded”, every time a Pod restarts the health goes Progressing → Healthy and it sends again. Fix: Add oncePer: app.status.sync.revision; for a single repository with multiple applications, the official recommendation is to use oncePer: app.status?.operationState.syncResult.revision.
Case 2: write deployment results back to GitHub
Problem: Developers cannot see on the application repository's commit page whether it has been deployed to dev. Fix: Use service.github (GitHub App credentials) and the github.status in the template to write a commit status on the commit; or use a Webhook to trigger GitHub repository_dispatch to continue the subsequent pipeline (e.g. run E2E on dev, then automatically open the staging promotion PR, Module 7).
Case 3: self-service notifications
Problem: Each team wants to use a different notification channel, but should not modify the configuration in the argocd namespace. Fix: Enable apps-in-any-namespace, and turn on notificationscontroller.selfservice.enabled: "true", teams put argocd-notifications-cm / Secret in their own namespace.
Common errors and fixes
failed to execute when condition: cannot fetch phase from <nil> (1:28)
Cause:status.operationState does not exist before the sync starts.
Fix: Use optional chaining app.status?.operationState?.phase.
notification service 'local' is not supported / config referenced xxx, but key does not exist in secret
Cause: The service name in the subscription annotation does not match service.webhook.<name> ; or $key does not exist in the Secret.
kubectl -n argocd get cm argocd-notifications-cm -o yaml | grep -n 'service\.' kubectl -n argocd logs deploy/argocd-notifications-controller | tail -20
Configuration is correct but no notification is ever received
Cause: There is no subscription (annotation misspelled, or added to the wrong object); or the condition was already true before the subscription and has already been recorded as notified.
kubectl -n argocd get app podinfo-dev -o jsonpath='{.metadata.annotations}' | jq
argocd admin notifications trigger run on-deployed podinfo-dev -n argocdPost "http://webhook-sink…": context deadline exceeded
Cause: A NetworkPolicy blocks outbound traffic from the argocd namespace, or the receiver is not ready.
Fix: Test with curl from the namespace where notifications-controller runs; allow the outbound traffic.
1. For team-a all applications under the AppProject, subscribe a Slack notification for sync failures (channel team-a-alerts).
kubectl -n argocd annotate appproject team-a \ notifications.argoproj.io/subscribe.on-sync-failed.slack=team-a-alerts
2. Without waiting for a real event, immediately send the app-event template to the local Webhook.
argocd admin notifications template notify app-event podinfo-dev --recipient local: -n argocd
The on-call team requires: alert only if any prod application is Degraded for more than 5 minutes, but alert on dev immediately. Can this be done with Notifications alone?
The trigger condition only looks at the current state; there is no native “lasts N minutes” semantics (you could compare time fields in expr, but it is not recommended). A better split: dev uses Notifications to send immediately to the team channel; for prod, use Argo CD's metrics argocd_app_info{health_status="Degraded"} write for: 5m alert rules in Prometheus/Alertmanager (see the Prometheus lesson), and let Alertmanager handle grouping, silencing and escalation.
Verified teaching video
Official documentation
Video storyboard (about 80 seconds)
Visual: the health status on the Application card changes from green to red Degraded, and a “bell” lights up.
Narration: a trigger is an expression; when the state satisfies the condition, the bell rings.
Visual: the template fills the application name, version and link into a block of JSON.
Narration: the template decides the message content; the same template can produce different formats for Slack and Webhook.
Visual: the Application's annotation works like a subscription switch pointing to the Webhook receiver; the request body appears in the log.
Narration: the subscription is written in an annotation and goes into Git along with the Application.
Module 6 · Sync Windows and Change Freezes
- Use the AppProject's sync windows (
kind: allow|deny, cronschedule,duration,applications/namespaces/clusters,manualSync,timeZone,syncOverrun) to implement release windows and holiday freezes, and infer whether syncing is allowed at a given moment. - Choose a different drift policy for different environments: self-heal (selfHeal), alert only (automatic sync without self-heal / manual sync + notification), and use
ignoreDifferencesto exclude legitimate “other writers”. - Define an break-glass emergency change process: restore service first, then within a time limit write the change back to Git, and finally re-enable automatic sync and confirm zero diff.
What: sync windows
Sync windows are defined in the AppProject's spec.syncWindows , and are rules that “allow or deny syncing for a given time period”. Each window consists of kind (allow / deny), a cron-format schedule (window start time),duration (how long it lasts), and selectors (applications,namespaces,clusters, supporting wildcards; multiple selectors are ORed by default, and in the UI you can check “Use AND operator” to make them ANDed).
Decision rules (official documentation)
- No window matches the application → all syncs are allowed.
- There is a matching allow window → only when some allow window is active is syncing allowed.
- There is a matching and active deny window → all syncs are forbidden.
- When an allow and a deny are active at the same time → deny takes precedence.
- Windows apply to both automatic sync and manual sync (self-heal is also a form of automatic sync);
manualSync: trueallow manual sync when blocked by this window (for emergency fixes). timeZoneSpecify the time zone for cron (default UTC);syncOverrun(newer versions) allows a sync that has already started to cross the window boundary and complete.- Window panel colors in the UI: red = sync forbidden, orange = manual only, green = allowed.
Why: change freezes and release windows
Typical needs: production is only released on weekday daytime (with staff on duty); all changes are frozen during major promotions, holidays and financial settlement periods; database-related applications are only allowed to sync in the nightly maintenance window. Without windows, Argo CD syncs as soon as a PR is merged — which is unacceptable during a freeze. The benefit of windows is that you do not need to change the process: PRs can still be merged, the Application shows OutOfSync, and it catches up automatically when the window opens.
Drift policy: self-heal or alert only
| Policy | Config | Behavior on drift | Suited for |
|---|---|---|---|
| Self-heal | automated: {selfHeal: true} | Manual changes are quickly reverted (selfHeal has backoff) | dev, staging, most stateless services; also a forced way to “prevent manual changes to production” |
| Automatic sync but only alert on drift | automated: {} (selfHeal false) + notification | Syncs when there is a new commit in Git; manual changes are kept and shown as OutOfSync, alerted via notifications / metrics | Migration period, or teams worried about automatic reversion |
| Manual sync + alert | None automated | Git changes and drift both only show as OutOfSync, waiting for a person to sync | Regulated environments, production that needs a human to press a button |
| Declare “not managed by me” | ignoreDifferences (+ RespectIgnoreDifferences=true) | Specified fields do not take part in comparison | replicas managed by HPA, fields injected by controllers, certificates generated by webhooks |
Implementation of alert-only: define in Notifications when: app.status.sync.status == 'OutOfSync' triggers (together with oncePer: app.status.sync.revision), or in Prometheus write argocd_app_info{sync_status="OutOfSync"} for for: alerts with
break-glass: emergency change process (recommended template)
- The first choice is still Git: emergency PR + emergency approval group (branch protection allows designated people to bypass, with audit records) + manual sync (window set to
manualSync: true). - When Git / CI is unavailable or too slow: declare an incident and record a ticket; turn off automatic sync for the related Application — note who manages this Application: when managed by App of Apps, turn off automatic sync of the root application first; when it is generated by ApplicationSet (podinfo-* in this lesson), the ApplicationSet controller will revert the manually changed syncPolicy to the template value, so you need to declare beforehand in the ApplicationSet
ignoreApplicationDifferences(jsonPointers/spec/syncPolicy), or first turn off the root application that manages the ApplicationSet, then temporarily modify the ApplicationSet's template; then use kubectl to repair directly. - Timed write-back: within the agreed time (e.g. 24 hours), write the fix in the cluster into a PR and merge it into Git; use
argocd app diffto confirm Git and the cluster have zero diff. - Restore reconciliation: re-sync the root application, which restores the child Application's syncPolicy to the definition in Git; confirm Synced / Healthy, close the incident and do a retrospective.
manualSync: true to bypass it manually. ② “Adding the window with the CLI is enough” — if the AppProject itself is in Git and self-healed by the root application, a window added via the CLI will quickly be reverted; freeze windows must also go through Git. ③ “break-glass means turning off Argo CD” — it turns off automatic sync for a single application, and must be accompanied by the wrap-up steps “write back to Git, restore reconciliation”, otherwise long-term drift is left behind.Timeline: windows over a week
Flowchart: break-glass
Interactive judge: can it sync right now?
The project has two windows (see below). Click any hour in the weekly grid, choose an application and sync method, and view the judgment process. The decision logic is a simplified implementation of the official documentation's rules.
Core commands
| Command | Purpose |
|---|---|
argocd proj windows list PROJ | List windows and current status (Active / Inactive) |
argocd proj windows add PROJ --kind deny --schedule "0 18 * * 5" --duration 62h --applications "*" --time-zone "Asia/Shanghai" | Add a window (if the project is managed by Git, change Git instead) |
argocd proj windows enable-manual-sync PROJ ID | Allow manual sync when this window blocks |
argocd proj windows update PROJ ID --applications … | Modify a window (list fields must be written in full) |
argocd app get APP | Display SyncWindow: Sync Denied and matching windows |
argocd app set APP --sync-policy none / automated --self-heal | Turn off / restore automatic sync during break-glass |
syncWindows:
- kind: allow # production release window: Mon–Thu 09:00–17:00
schedule: "0 9 * * 1-4"
duration: 8h
timeZone: "Asia/Shanghai"
applications: ["*-prod"]
manualSync: true
- kind: deny # weekend freeze: 62 hours starting Fri 18:00
schedule: "0 18 * * 5"
duration: 62h
timeZone: "Asia/Shanghai"
applications: ["*"]
manualSync: true # emergency fixes can still be synced manually
trigger.on-out-of-sync: |
- when: app.status.sync.status == 'OutOfSync'
oncePer: app.status.sync.revision
send: [app-event]
Lab 6: freeze prod, manual override, rehearse break-glass (about 8 minutes)
Below, use the variable PROJ to denote the project in which the podinfo application lives (from Hour 4 it is platform, consistent with the Hour 4 window semantics; the minimal starting point is default).
* * * * * opens a 1-hour window every minute, effectively always in effect; the official documentation's list example also uses this form):
PROJ=platform
cd ~/gitops-lab
yq -i '.spec.syncWindows = [{"kind":"deny","schedule":"* * * * *","duration":"1h","applications":["podinfo-prod"],"manualSync":false}]' argocd/projects/$PROJ.yaml
git commit -am "freeze podinfo-prod (lab)" && git push
kubectl apply -f argocd/projects/$PROJ.yaml # same content as Git; if a root application exists, you can also wait for it to sync
argocd proj windows list $PROJ
ID STATUS KIND SCHEDULE DURATION APPLICATIONS NAMESPACES CLUSTERS MANUALSYNC SYNCOVERRUN TIMEZONE USEANDOPERATOR 0 Active deny * * * * * 1h podinfo-prod - - Disabled Disabled UTC Disabled
If the AppProject is not managed by Git, you can directly argocd proj windows add.
cd ~/gitops-lab/apps/podinfo/overlays/prod kustomize edit set image ghcr.io/stefanprodan/podinfo:6.17.0 git commit -am "prod: podinfo 6.17.0 (during freeze)" && git push argocd app get podinfo-prod --refresh | grep -E 'SyncWindow|Sync Status' argocd app sync podinfo-prod
SyncWindow: Sync Denied Sync Status: OutOfSync from main (e9f0…) FATA[0001] rpc error: code = PermissionDenied desc = cannot sync: blocked by sync window
manualSync: true (also via Git), then manually sync:
cd ~/gitops-lab yq -i '.spec.syncWindows[0].manualSync = true' argocd/projects/$PROJ.yaml git commit -am "freeze: allow manual sync" && git push; sleep 30 argocd app sync podinfo-prod && kubectl argo rollouts promote podinfo -n podinfo-prod --full
The window still blocks automatic sync and self-heal; only people with sync permission can manually sync — this is the “emergency channel” during a change freeze.
ignoreApplicationDifferences: # allow manual changes to the generated Application's syncPolicy (prerequisite for break-glass)
- jsonPointers:
- /spec/syncPolicy
# 0) Prerequisite: the ignoreApplicationDifferences above is already in Git and synced
# (otherwise the ApplicationSet controller will immediately revert syncPolicy to the template value; for a hand-written Application in the minimal starting point, you must first turn off automatic sync on the root application)
# 1) Turn off automatic sync
argocd app set podinfo-staging --sync-policy none
# 2) Fix directly
kubectl -n podinfo-staging patch rollout podinfo --type merge -p '{"spec":{"replicas":6}}'
argocd app get podinfo-staging | grep 'Sync Status' # OutOfSync: expected drift
# 3) Write back to Git
cd ~/gitops-lab/apps/podinfo/overlays/staging
cat >> kustomization.yaml <<'EOF'
patches:
- target: { kind: Rollout, name: podinfo }
patch: |-
- op: replace
path: /spec/replicas
value: 6
EOF
kubectl kustomize . | grep 'replicas:'
git commit -am "staging: replicas 6 (backport of break-glass INC-123)" && git push
argocd app diff podinfo-staging --refresh && echo "zero diff"
# 4) Restore reconciliation: ApplicationSet ignores syncPolicy differences, so restore it manually (to match the template)
argocd app set podinfo-staging --sync-policy automated --self-heal --auto-prune
argocd app get podinfo-staging | grep -E 'Sync Policy|Sync Status'
Sync Status: OutOfSync from main (e9f0…) zero diff Sync Policy: Automated (Prune) Sync Status: Synced to main (1a2b…)
argocd app diff Exit code is 0 when there is no difference, and 1 when there is one. Note: kustomize's replicas: field only recognizes Deployment / StatefulSet / ReplicaSet / ReplicationController (verified locally with kustomize v5; it errors on Rollout), so a JSON patch is used here.
yq -i 'del(.spec.syncWindows)' … and push). prod stays at 6.17.0 or is reverted to 6.16.0; decide according to your Module 7 starting point (Module 7 assumes prod is 6.16.0).Case 1: year-end freeze
Problem: A retail company freezes all production changes from late November to early December, but security patches must still be able to go out. Fix: Add deny windows to all projects (schedule: "0 0 20 11 *",duration: 360h),manualSync: true; manual sync permission is granted only to the SRE on-call group via Argo CD RBAC; all freeze-period change PRs need an extra change-approval label. The window definitions are placed in Git and automatically become invalid after the freeze ends.
Case 2: self-heal conflicts with emergency scale-out
Problem: Traffic surged; the on-call engineer kubectl scale scaled out, but after 30 seconds selfHeal reverted it, and the incident grew. Fix: Hand replicas over to HPA and, in the Application, ignoreDifferences; write a break-glass runbook that clearly says “turn off automatic sync on the root application first, then on child applications”; rehearsed once in the Argo CD UI.
Case 3: an alert-only migration period
Problem: An old system has just been onboarded to GitOps; everyone worries that self-heal will overwrite unknown manual configuration. Fix: For the first two weeks, automated: {} keep selfHeal off and subscribe to the on-out-of-sync notifications, gradually fold manual configuration into Git, and enable selfHeal only after drift alerts are cleared.
Common errors and fixes
cannot sync: blocked by sync window
Cause: A matching deny window is active, or an allow window exists but is not currently in its active period.
argocd app get podinfo-prod | grep -E 'SyncWindow|Assigned Windows' argocd proj windows list platform
Fix: Wait for the window, or use the manualSync: true emergency channel, or fix the window selector (e.g. *-prod wrongly matched dev).
The window time is “off by 8 hours”
Cause: Not set timeZone, so cron is interpreted in UTC.
Fix: Add timeZone: "Asia/Shanghai"; use argocd proj windows list to check the TIMEZONE column.
A window added via the CLI disappears after a few minutes
Cause: The AppProject is managed by Git, and the root application's self-heal changes it back to the Git version.
Fix: Modify the AppProject in Git.
After break-glass, the automatic sync that was turned off “restored itself” and the manual fix was overwritten
Cause: The Application is generated by an ApplicationSet (or managed by the root application), and the controller restores syncPolicy to the template / value in Git.
Fix: Pre-declare ignoreApplicationDifferences: [{jsonPointers: [/spec/syncPolicy]}] in the ApplicationSet; for App of Apps, turn off automatic sync on the root application first. Write this into the runbook and rehearse it.
1. Add an allow window to project platform that starts every day at 02:00 (Shanghai time) for 2 hours, applying only to *-prod applications.
argocd proj windows add platform --kind allow --schedule "0 2 * * *" --duration 2h \ --applications "*-prod" --time-zone "Asia/Shanghai"
2. Check whether podinfo-prod is currently blocked by a window.
argocd app get podinfo-prod | grep -E 'SyncWindow|Assigned Windows'
Friday 20:00, prod is frozen (deny, manualSync: true). A serious vulnerability requires an immediate image upgrade. Write out your steps.
① Open a PR in the normal way to change the image tag in the prod overlay, going through emergency approval (branch protection allows the emergency group); ② after merging, the Application shows OutOfSync and automatic sync is blocked by the window; ③ the on-call SRE (RBAC allows sync) manually argocd app sync podinfo-prod; ④ the Rollout runs the canary and analysis as usual (do not skip the safety net); ⑤ notifications are sent automatically, and afterwards an explanation is added to the change record. Throughout, Git remains the source of truth, and kubectl is not needed.
Verified teaching video
Official documentation
Video storyboard (about 80 seconds)
Visual: a weekly calendar, weekday daytime in green and weekends in red; a PR is merged on Saturday, and the Application card stays at OutOfSync.
Narration: a sync window does not block merging, only syncing. When the window opens, the cluster automatically catches up with Git.
Visual: three drift policies side by side: self-heal (snaps back immediately), alert only (bell rings), manual (waiting for a button).
Narration: the drift policy is the character of an environment. Development self-heals, the migration period only alerts, and regulated production syncs manually.
Visual: the five-step break-glass process; finally the diff count returns to zero.
Narration: in an emergency you may change the cluster first, but you must return to Git: write back, confirm zero diff, restore reconciliation.
Module 7 · Environment Promotion: PR Flow and Promotion Tools
- Express environments with directories (
apps/podinfo/overlays/dev|staging|prod), implement promotion as a PR that copies the verified version number / digest into the next overlay, and explain why not to use “one branch per environment”. - Design promotion gates: previous environment healthy, soak time, automated tests, manual approval, sync windows; write a script that generates the promotion PR.
- Understand the Kargo model (Warehouse → Freight → Stage → Promotion) and its applicable scenarios, and know its relationship with Argo CD.
What: promotion
The same application runs in dev, staging and prod; the differences should only be environment configuration (replica count, resources, domain names, canary cadence) and versions. Promotion means pushing the version along the environment chain: a version verified in dev podinfo:6.17.0 can only enter staging, and staging must pass before it can enter prod. In GitOps this action is a PR that modifies the next environment's directory:
--- a/apps/podinfo/overlays/staging/kustomization.yaml +++ b/apps/podinfo/overlays/staging/kustomization.yaml images: - name: ghcr.io/stefanprodan/podinfo - newTag: 6.16.0 + newTag: 6.17.0
Why: directories instead of branches
| Environment = directory (recommended) | Environment = branch | |
|---|---|---|
| See each environment's differences | diff overlays/staging overlays/prod Visible at a glance | Requires comparing branches, mixing in many unrelated commits |
| Promotion action | A small PR changing one field | Merge / cherry-pick between branches; easily carries changes that should not be promoted along |
| Shared changes (base) | Changing base once affects all environments (watch the blast radius) | Need to merge repeatedly into each branch |
| Argo CD configuration | All Applications track main, with different paths | targetRevision differs for each |
Note that changes to base affect all environments at the same time — this is the cost of the directory model. For higher-risk base changes, you can first validate them in a patch in the dev overlay and then move them up to base; or version the base as well (remote base with ?ref=).
How: promotion gates
| Gate | How it's checked | Where implemented |
|---|---|---|
| Previous environment synced and healthy | argocd app get podinfo-dev -o json in its status: sync=Synced, health=Healthy, and the revision includes this version | Promotion script / CI check |
| Rollout completed and analysis successful | kubectl argo rollouts status; AnalysisRun Successful | Same as above |
| Soak time | Running in dev for ≥ N hours with no alerts | CI scheduled job |
| Automated tests | Run E2E against dev/staging | CI, triggered by a notification Webhook (Module 5) |
| Manual approval | CODEOWNERS: apps/podinfo/overlays/prod/ @org/sre + required review | Git platform branch protection |
| Time | Sync window | Argo CD (Module 6) |
“What is promoted is the artifact, not a rebuild”
What prod runs must be the same image verified in staging. Do not rebuild during promotion; it is best to promote the digest (6.17.0@sha256:…), and enable immutable tags in the image registry. Configuration differences stay in each environment's overlay and do not move with promotion.
When: when a dedicated promotion tool (Kargo) is needed
Kargo (Akuity open source, Apache-2.0, latest v1.12.6 as of 2026-11; not part of the Argo project itself, but developed by Argo's founding team and uses Argo CD to deploy) models promotion as a set of CRDs:
- Warehouse: subscribes to artifact sources (image registry, Git repository, Helm chart) and discovers new versions.
- Freight: a group of artifact versions promoted together (e.g. “podinfo:6.17.0 + config commit a1b2”), the unit of promotion.
- Stage: an environment (dev / staging / prod) that declares from which Warehouse or upstream Stage it receives Freight, and how it is verified (can use Argo Rollouts' AnalysisTemplate).
- Promotion: a request to “put a certain Freight into a certain Stage”, executed per promotion steps steps, such as
git-clone→kustomize-set-image→git-commit→git-push(orgit-open-pr/git-wait-for-pr) →argocd-update.
| PR promotion (this lesson's lab) | Kargo | |
|---|---|---|
| Extra components | None (script / CI) | Kargo controller, API, UI (official install depends on cert-manager) |
| Visualization | Git history + PR list | Pipeline view of Freight flowing between Stages |
| Promoting multiple artifacts together | Must ensure consistency yourself | Freight naturally binds multiple artifacts together |
| Suited for | Few services, short environment chain | Many services, multiple environments / multiple regions, and a need for a unified promotion strategy |
Other related options: Argo CD ApplicationSet's RollingSync (Progressive Syncs, Beta since v3.3, off by default, must be enabled applicationsetcontroller.enable.progressive.syncs; once enabled, generated applications no longer sync automatically) to sync in batches by environment label (Hour 3); in the Flux ecosystem, PRs or Flagger plus a custom pipeline are commonly used. Promotion is a pattern; the tools are replaceable.
Architecture diagram: PR-driven environment chain
Kargo's object model
Interactive board: versions moving through the environment chain
Click “New version arrives” to put a new Freight in, then try to promote. Each environment's gate can be toggled manually; when blocked, the reason is shown; on success, the generated PR diff is shown.
Core commands
| Command | Purpose |
|---|---|
yq '.images[0].newTag' apps/podinfo/overlays/dev/kustomization.yaml | Read the previous environment's version |
diff -u overlays/staging overlays/prod / git diff --no-index | Compare environment differences |
argocd app get podinfo-dev -o json | jq '.status.health.status, .status.sync.status' | Gate: previous environment status |
argocd app wait podinfo-staging --health --timeout 600 | Wait for completion after promotion |
gh pr create --label promotion --reviewer org/sre | Open a promotion PR |
kargo promote --project P --freight F --stage S | Start promotion with the Kargo CLI (parameters per the Kargo docs) |
#!/usr/bin/env bash
# Usage: scripts/promote.sh dev staging
set -euo pipefail
FROM=$1; TO=$2; APP=podinfo
SRC=apps/$APP/overlays/$FROM/kustomization.yaml
DST=apps/$APP/overlays/$TO/kustomization.yaml
TAG=$(yq '.images[] | select(.name == "ghcr.io/stefanprodan/podinfo") | .newTag' "$SRC")
CUR=$(yq '.images[] | select(.name == "ghcr.io/stefanprodan/podinfo") | .newTag' "$DST")
[ "$TAG" = "$CUR" ] && { echo "$TO is already $TAG"; exit 0; }
# Gate: previous environment synced and healthy, Rollout completed
read -r SYNC HEALTH <<<"$(argocd app get $APP-$FROM -o json | jq -r '"\(.status.sync.status) \(.status.health.status)"')"
[ "$SYNC/$HEALTH" = "Synced/Healthy" ] || { echo "Gate failed: $APP-$FROM is $SYNC/$HEALTH"; exit 1; }
kubectl argo rollouts status $APP -n $APP-$FROM --timeout 10s >/dev/null
git switch -c promote/$APP-$TO-$TAG
yq -i '(.images[] | select(.name == "ghcr.io/stefanprodan/podinfo") | .newTag) = "'"$TAG"'"' "$DST"
git commit -am "promote: $APP $TAG $FROM -> $TO"
git push -u origin HEAD
gh pr create --base main --label promotion \
--title "promote $APP $TAG to $TO" \
--body "From $FROM ($SYNC/$HEALTH). Diff: newTag $CUR -> $TAG"
How to verify:bash -n scripts/promote.sh Check the syntax; run it on dev → staging first. In production this script is usually placed in CI and triggered by dev's on-deployed notification (Webhook → repository_dispatch).
Lab 7: use PRs to promote 6.17.0 from dev to staging, then to prod (about 8 minutes)
cd ~/gitops-lab && git switch main && git pull grep -H newTag apps/podinfo/overlays/*/kustomization.yaml
apps/podinfo/overlays/dev/kustomization.yaml: newTag: 6.17.0 apps/podinfo/overlays/prod/kustomization.yaml: newTag: 6.16.0 apps/podinfo/overlays/staging/kustomization.yaml: newTag: 6.16.0
If dev is still 6.16.0, first manually change dev to 6.17.0 and wait for the Rollout to complete.
mkdir -p scripts && chmod +x scripts/promote.sh && bash -n scripts/promote.sh git add scripts && git commit -m "add promote script" && git push ./scripts/promote.sh dev staging
Switched to a new branch 'promote/podinfo-staging-6.17.0' [promote/podinfo-staging-6.17.0 77ab1c2] promote: podinfo 6.17.0 dev -> staging https://github.com/<you>/gitops-lab/pull/57
gh pr diff 57 gh pr merge 57 --squash --delete-branch && git switch main && git pull argocd app get podinfo-staging --refresh >/dev/null kubectl argo rollouts get rollout podinfo -n podinfo-staging --watch
./scripts/promote.sh staging prod
Gate failed: podinfo-staging is Synced/Suspended
When the Rollout is paused, Argo CD health is Suspended and the script refuses to promote. Wait until staging is Healthy, then run it to generate the prod PR.
.github/CODEOWNERS Write in apps/podinfo/overlays/prod/ @<you>, and require Code Owner review in main's branch protection. After merging, prod sync is constrained by the Module 6 window.Case 1: the “merge hell” of branch-per-environment
Problem: The team used three branches dev/staging/prod; each merge from staging to prod carried along untested configuration changes, and after several incidents no one dared to merge. Fix: Migrated to a single branch with multiple directories; version promotion only changes newTag, and environment configuration changes go through a separate PR validated first in the dev overlay. During migration, each Application's targetRevision is uniformly changed to main.
Case 2: promotion rebuilds cause inconsistent behavior
Problem: The prod pipeline rebuilds docker build, and the base image it depends on was updated between the two builds, so prod and staging were not the same binary. Fix: Build only once; promote the digest; enable immutable tags in the image registry.
Case 3: unified promotion for 40 microservices
Problem: Each service has its own promotion script; approvals are scattered and there is no global view. Fix: Evaluate Kargo: one Warehouse per service, Stage chains templated uniformly, prod Stage set to manual promotion; the pipeline view lets the release manager see at a glance which version is stuck in which environment. The execution layer is still Git commits + Argo CD sync, and the existing Rollouts analysis continues as verification for each Stage.
Common errors and fixes
After the promotion PR is merged, staging has configuration that only dev had
Cause: The promotion copied the whole directory or used a branch merge.
Fix: Promotion should only modify images; use git diff --stat to confirm the PR only changed one line in one file.
yq: Error: … bad file / newTag becomes null after promotion
Cause: Used the Python version of yq (different syntax), or images[].name does not match the selection condition.
yq --version # requires mikefarah/yq v4
prod PR is merged, but prod stays OutOfSync
Cause: Blocked by a sync window (Module 6), or the prod Application is set to manual sync.
argocd app get podinfo-prod | grep -E 'SyncWindow|Sync Policy'
The gate check says Healthy, but the Rollout is actually Degraded after an abort
Cause: The check was done on the wrong application, or done after the revert; after an abort the Application health is Degraded, never Healthy.
Fix: The gate should also check status.sync.revision is the commit containing that version, and that the Rollout's stable image is the version to be promoted.
1. One command to list the current podinfo version in the three environments.
for e in dev staging prod; do printf "%-8s " $e; yq '.images[0].newTag' apps/podinfo/overlays/$e/kustomization.yaml; done
2. Compare the full rendered diff between staging and prod.
diff -u <(kubectl kustomize apps/podinfo/overlays/staging) <(kubectl kustomize apps/podinfo/overlays/prod)
A version passed in staging, but the prod canary analysis failed and was aborted. What should you do next? Should staging roll back?
prod: revert the promotion PR in Git (prod goes back to the old version, and the Rollout restores stable directly). staging: no need to roll back automatically, but mark the version as “not promotable” (a PR comment / in Kargo, that Freight no longer promotes to prod), and investigate why staging did not catch the problem (different traffic patterns? different analysis thresholds? data differences?), and strengthen staging's verification. After the fix, release a new version and go through dev → staging → prod again.
Verified teaching video
Official documentation
Video storyboard (about 80 seconds)
Visual: three folders dev, staging, prod; a card reading 6.17.0 is stuck in dev.
Narration: environments are directories, versions are cards. Promotion means moving the card to the next directory.
Visual: the card wants to enter staging; gates light up: dev healthy, tests passed, review passed; entering prod also requires the sync window to turn green.
Narration: each gate is a check; a PR is generated only when all of them pass.
Visual: Kargo's pipeline view, with a Warehouse producing Freight that flows along the Stages.
Narration: as the number of services grows, promotion itself becomes an object to manage. Execution is still Git commits and Argo CD sync.
Module 8 · Hours 1–6 Recap and End-to-End Drill
- Use one diagram to explain the position and responsibility of every component from hours 1–6 in a release (Repo Server, Application Controller, ApplicationSet, AppProject, secrets, Rollouts, Image Updater, Notifications).
- Complete an end-to-end drill: Image Updater automatically updates dev → canary analysis passes → notification → PR promotes to staging → prod is constrained by the window.
- Use the troubleshooting tree to locate where a release gets stuck when it does not proceed as expected.
What: knowledge map of the first six hours
| Hour | Topic | Role in a release |
|---|---|---|
| 1 | GitOps core, architecture, installation | Repo Server renders overlays, Controller compares and syncs, Sync / Health status |
| 2 | Application in depth, sync control | sync options (ServerSideApply, CreateNamespace), waves / hooks, Webhook for faster discovery |
| 3 | App of Apps, ApplicationSet | Platform components (Rollouts, Prometheus, Image Updater) and batch management of multi-environment Applications |
| 4 | Multi-cluster, multi-tenant | AppProject limits sources and destinations; RBAC controls who can sync / execute Rollout actions; where sync windows live |
| 5 | Security and secrets | Image Updater's Git write credentials, encrypted storage of the Slack token |
| 6 | Progressive delivery and automation | Who changes Git, how to ramp traffic, when to abort, who is notified, when syncing is allowed, how to promote |
Why: each step can fail independently
The longer the chain, the more reasons for “not shipped”: image not pushed, PR not merged, Argo CD did not notice, window blocked, render failed, Rollout paused, analysis errored, notification not subscribed… The key to troubleshooting is in data-flow order confirm each stage in turn, rather than guessing backwards from the final symptom.
How: troubleshooting checkpoints following the data flow
- Artifact: does the image tag exist? (
crane digest) - Git: is the version in the overlay correct? Was the PR merged? (
git log -1 -- apps/podinfo/overlays/dev) - Discovery: the Application's
status.sync.revisionis the latest commit? (--refresh, Webhook) - Allow: is a sync window blocking? (
SyncWindowfield) - Render / apply: ComparisonError, SyncError? (
argocd app getConditions) - Release: at which step is the Rollout? Paused / aborted? (
kubectl argo rollouts get) - Analysis: AnalysisRun result and measurement value?
- Feedback: are notifications subscribed and is the trigger true? (
argocd admin notifications trigger run)
When: production readiness review checklist (Hour 6 portion)
- CI holds no cluster credentials; all version changes are written to Git via PR / controller; image tags are immutable.
- User-facing services use Rollout + analysis only for the canary; Prometheus is highly available; there is a revert process after an abort.
- Image Updater is used only for dev or third-party components; git write-back; each application is matched by only one CR.
- At minimum subscribe
on-health-degradedandon-sync-failed; secrets are kept in a Secret. - prod has release windows and a freeze policy (in Git); there is a rehearsed break-glass runbook.
- Promotion only moves verified versions; prod promotion requires Code Owner approval.
suspend: true) or external change management. The pattern is the same: Git is the single source of truth, controllers handle convergence, and people make decisions via PRs.Panorama: components a release passes through
End-to-end replay: choose a fault injection point
Choose “no fault” or a fault point, then play, observe at which stage the chain stops, and which command's output you would see it in.
End-to-end check commands (in data-flow order)
# 1 Artifact crane digest ghcr.io/stefanprodan/podinfo:6.17.0 # 2 Git git -C ~/gitops-lab log -3 --oneline -- apps/podinfo/overlays # 3 Discovery argocd app get podinfo-dev --refresh -o json | jq -r '.status.sync.revision, .status.sync.status, .status.health.status' # 4 Allow argocd app get podinfo-prod | grep -E 'SyncWindow|Assigned Windows' # 5 Render / apply argocd app get podinfo-dev -o json | jq '.status.conditions' # 6 Release kubectl argo rollouts get rollout podinfo -n podinfo-dev # 7 Analysis kubectl -n podinfo-dev get analysisrun --sort-by=.metadata.creationTimestamp | tail -3 # 8 Feedback argocd admin notifications trigger run on-deployed podinfo-dev -n argocd
| Stage | Symptom | Where to look |
|---|---|---|
| Artifact | ImagePullBackOff / Image Updater cannot find the new tag | Pod events, updater logs |
| Discovery | revision stuck on an old commit | status.sync.revision, Webhook delivery records |
| Allow | OutOfSync not moving | SyncWindow: Sync Denied |
| Release | Suspended for a long time | Rollout current step,pause: {} |
| Analysis | Degraded | AnalysisRun measurements |
| Feedback | Nobody knows | Subscription annotations, controller logs |
Lab 8: end-to-end drill (about 10 minutes)
cd ~/gitops-lab && git switch main && git pull for e in dev staging prod; do (cd apps/podinfo/overlays/$e && kustomize edit set image ghcr.io/stefanprodan/podinfo:6.16.0); done git commit -am "e2e: reset all envs to 6.16.0" && git push kubectl -n argocd get imageupdaters; kubectl get pod -A -l run=loadgen kubectl -n webhook-sink logs deploy/webhook-sink -f | grep --line-buffered '"body"' &
Note: Image Updater may bump dev back up to 6.17.0 soon after your reset — this is exactly the first step of the drill. The staging / prod canaries can use promote --full to speed up.
watch -n 10 "git -C ~/gitops-lab pull -q; grep newTag ~/gitops-lab/apps/podinfo/overlays/dev/kustomization.yaml" kubectl argo rollouts get rollout podinfo -n podinfo-dev --watch
on-deployed request body (the revision is Image Updater's commit)../scripts/promote.sh dev staging → review and merge → watch the canary and analysis../scripts/promote.sh staging prod and merge, and confirm prod OutOfSync and Sync Denied; the release is completed by a manual sync by the “on-call SRE”.for e in dev staging prod; do printf "%-8s" $e; kubectl -n podinfo-$e get rollout podinfo -o jsonpath='{.status.stableRS} {.spec.template.spec.containers[0].image}{"\n"}'; done
argocd app list -o wide | grep podinfo
dev 7b54f1c9d8 ghcr.io/stefanprodan/podinfo:6.17.0 staging 7b54f1c9d8 ghcr.io/stefanprodan/podinfo:6.17.0 prod 7b54f1c9d8 ghcr.io/stefanprodan/podinfo:6.17.0
The pod-template-hash of the three environments is the same, showing that the templates are consistent (same artifact + same template); if your overlay has environment-specific template patches, the hashes will differ, which is normal.
kubectl delete pod -A -l run=loadgen; keep Rollouts, Prometheus and notifications for use in Hour 7. When no longer needed: kubectl delete ns webhook-sink.Case 1: the 40 minutes of “merged but not live”
Problem: On Friday afternoon a prod promotion PR was merged; 40 minutes later customers still saw the old version. The team checked the image first, then the Rollout, and only then found the freeze window that had started before Friday 18:00 (the time zone was written wrong, so it took effect 8 hours early). Lesson: Troubleshoot in data-flow order (the “Allow” step at step 4 reveals it); the window must be written timeZone; in notifications include SyncWindow status.
Case 2: analysis passes but users get errors
Problem: AnalysisRun stays Successful, but a certain API path returns 500 all the time. Cause: That path accounts for less than 1% of traffic, so the overall success rate is still above 99%. Fix: Add independent metrics for critical paths (podinfo's http_request_duration_seconds_count with path labels can be computed per path), and pair them with a synthetic probe Job as a second metric.
Case 3: the “last mile” after automating everything
Problem: dev and staging are fully automated, but prod promotion PRs often go unhandled and pile up. Fix: dev's on-deployed notification triggers CI to automatically generate the staging PR; after staging passes, it automatically generates the prod PR and @-mentions the on-call SRE; the PR template attaches links to the dev/staging analysis results. People only need to make a well-informed decision.
Interactive troubleshooting tree: a release did not proceed as expected
Select level by level starting from the symptom to get diagnostic commands and fix suggestions.
1. In one go, view the commit podinfo-dev currently tracks, its sync status and its health status.
argocd app get podinfo-dev --refresh -o json | jq -r '.status.sync.revision, .status.sync.status, .status.health.status'
2. View the stable ReplicaSet hash of the Rollout in the three environments.
for e in dev staging prod; do kubectl -n podinfo-$e get rollout podinfo -o jsonpath='{.metadata.namespace} {.status.stableRS}{"\n"}'; doneA new colleague asks: “Since AnalysisRun rolls back automatically, why do we still need staging? Can't we just go dev → prod?” How do you answer?
Canary analysis can only catch “problems visible in a small part of real traffic, using defined metrics”, and it has a blast radius (that subset of users is already affected). Staging provides: a complete environment close to production without real users; destructive / long-running tests (migration, load test, E2E); and verification of configuration differences. The two are complementary layers of defense: staging tries to catch problems before users do, and the canary limits the problems that slip through to a small scope and automatically stops the damage.
Verified teaching video
Official documentation
Video storyboard (about 90 seconds)
Visual: components in the panorama light up in turn: image registry, Image Updater, Git, Argo CD, Rollout, Prometheus, notifications, promotion PR.
Narration: a release passes through eight stages, and each stage has its own status.
Visual: a red light comes on at the “Allow” stage, with SyncWindow: Sync Denied beside it.
Narration: when troubleshooting, move forward along the data flow; the first abnormal stage is the answer.
Visual: the hashes of the three environments are identical, with green checkmarks.
Narration: the same artifact, verified layer by layer, reaches production. This is progressive delivery.
Command cheat sheet
kustomize edit set image ghcr.io/stefanprodan/podinfo:6.17.0 yq -i '.images[0].newTag = "6.17.0"' kustomization.yaml argocd app diff podinfo-dev --revision BRANCH gh pr create --base main --label promotion gh pr merge --squash --auto ./scripts/promote.sh dev staging
kubectl argo rollouts get rollout podinfo -n NS --watch kubectl argo rollouts status podinfo -n NS --timeout 3m kubectl argo rollouts promote podinfo -n NS [--full] kubectl argo rollouts abort podinfo -n NS kubectl argo rollouts retry rollout podinfo -n NS kubectl argo rollouts dashboard # :3100 kubectl -n NS get analysisrun argocd app actions run APP resume --kind Rollout --resource-name podinfo
kubectl -n argocd get imageupdaters
kubectl -n argocd logs deploy/argocd-image-updater-controller
argocd-image-updater test IMAGE --semver-constraint 6.x
# method: argocd | git | git:secret:NAME | git:repocreds
# writeBackTarget: kustomization[:path] | helmvalues[:path]
# branch: "main:image-updater-{{.SHA256}}"argocd admin notifications trigger get -n argocd argocd admin notifications template get -n argocd argocd admin notifications trigger run on-deployed APP -n argocd argocd admin notifications template notify TPL APP --recipient SVC:RCPT -n argocd # subscription annotation: notifications.argoproj.io/subscribe.TRIGGER.SERVICE: RECIPIENT
argocd proj windows list PROJ argocd proj windows add PROJ --kind deny --schedule "0 18 * * 5" \ --duration 62h --applications "*" --time-zone "Asia/Shanghai" argocd proj windows enable-manual-sync PROJ ID argocd app get APP | grep SyncWindow # break-glass prerequisite: ignoreApplicationDifferences: /spec/syncPolicy in the ApplicationSet argocd app set APP --sync-policy none argocd app diff APP --refresh # after write-back, confirm zero diff
| Field | Default |
|---|---|
failureLimit | 0 (no failures tolerated) |
consecutiveErrorLimit | 4 |
consecutiveSuccessLimit | 0 (disabled, v1.8+) |
Blue-green scaleDownDelaySeconds | 30 |
abortScaleDownDelaySeconds | 30 |
| Image Updater strategy / write-back | semver / argocd |
Webhook notifications retryMax | 3 |
| Sync window time zone | UTC |
Quick reference for verdict rules
| Object | Rule |
|---|---|
| AnalysisRun | Successful → continue; Failed / Error → abort; Inconclusive → pause and wait for a human |
| Rollout health (Argo CD) | Paused → Suspended; aborted → Degraded; complete → Healthy |
| Sync window | No match → allow; has allow → allow only during the active allow period; active deny → forbid; deny takes precedence; manualSync allows manual bypass |
| Canary without traffic routing | weight ≈ canary replicas / total replicas |
| Promotion | Only move verified versions (preferably by digest); do not move environment configuration |
Capstone lab + final quiz
lab and gitops-lab repositories; all configuration must be in Git.argocd/apps/ contains three Applications — argo-rollouts (2.43.12), prometheus (29.47.2), argocd-image-updater (1.5.0) — all Synced / Healthy.
argocd app list -o wide | grep -E 'argo-rollouts|prometheus|image-updater'
success-rate, the query targets only the canary hash and the current namespace; all three environments have a traffic source (load generator or real traffic). Verify in dev with a “bad version” that it gets aborted, then revert.op: replace,path: /spec/strategy/canary/steps/1/pause/duration), keep dev at 2m. Use diff -u <(kubectl kustomize …/staging) <(kubectl kustomize …/prod) to confirm there are only the expected differences.podinfo-dev placed in Git (for example argocd/image-updaters/, managed by one Application), git write-back to dev's kustomization; confirm that staging / prod are not matched by any CR.on-deployed (oncePer revision),on-health-degraded,on-sync-failed three triggers written in bootstrap/argocd-values.yaml; the three podinfo Applications all subscribe to the local Webhook via annotations. Verify with argocd admin notifications trigger run .platform a window of “62-hour deny starting Friday 18:00, manualSync: true, timeZone Asia/Shanghai”; (optional, requires Hour 4 RBAC) only role:sre holding applications, sync, platform/podinfo-prod permission.scripts/promote.sh in Git; on GitHub configure CODEOWNERS for apps/podinfo/overlays/prod/ . Run a full dev → staging → prod pass.Open self-test (answer first yourself, then expand the reference answers)
1. Why is the interface between CI and CD in GitOps “one PR that changes Git”?
CI produces immutable artifacts and proposes changes to the desired state; review, audit and rollback all rely on Git; CD (the in-cluster controller) only reads Git and converges the cluster. This way cluster credentials never leave the cluster, the deployment history is the commit history, and rollback is a revert.
2. Without traffic routing, what does a canary setWeight: 20 look like with 4 replicas? How do you get an exact ratio?
The controller approximates by replica ratio, choosing the integer with the smallest difference: 20% × 4 = 0.8, about 1 canary Pod, an actual share of about 25%. For an exact ratio, configure trafficRouting (NGINX, Istio, Gateway API plugins, etc.) and set canaryService / stableService; then stable keeps full replicas.
3. What effect does AnalysisRun's Failed, Error and Inconclusive each have on the Rollout?
Failed (failure count exceeds failureLimit) and Error (consecutive errors exceed consecutiveErrorLimit, default 4) both cause an abort: traffic returns to stable and the Rollout is Degraded; Inconclusive pauses the Rollout, waiting for a manual promote or abort.
4. How do you choose between Image Updater's argocd write-back and git write-back?
argocd write-back directly modifies the Application in the cluster; it is pseudo-persistent and gets overwritten when the Application is managed by Git, which does not conform to GitOps; git write-back commits to the repository (kustomization / Helm values / .argocd-source files), is auditable and revertable, and is the recommended approach; it needs Git write credentials.
5. Which scenarios suit self-heal versus alert-only drift policies? What are the wrap-up steps of break-glass?
Self-heal suits most environments and enforces Git as the single source of truth; alert-only suits migration periods or systems with concerns about automatic reversion, discovering drift via OutOfSync notifications / metrics. Break-glass wrap-up: write the cluster fix as a PR and merge it,argocd app diff zero diff, restore (the root application's) automatic sync, and do a retrospective.
6. What should promotion move and what should it not move? What problem does Kargo solve?
Only move verified artifact versions (preferably the digest), do not move environment configuration, and do not rebuild. Kargo models promotion as Warehouse / Freight / Stage / Promotion, providing multi-artifact binding, unified promotion steps and a pipeline view, suited to many services and long environment chains; execution is still Git commits and Argo CD sync.
Final quiz (12 questions, covering all modules)
Sources and Version Notes
| Topic | Verified conclusion | Source (accessed 2026-11-17) |
|---|---|---|
| Argo CD | Latest stable v3.6.1 (2026-11-04); Helm chart argo/argo-cd 10.18.0 (appVersion v3.6.1); notifications enabled by default; the chart's templates / triggers are empty by default | argo-cd releases · argo-helm index · argo-cd values.yaml |
| Argo Rollouts | v1.10.2 (2026-11-04) is the latest stable; v1.11.0-rc1 is a pre-release; chart argo/argo-rollouts 2.43.12; failureLimit default 0, consecutiveErrorLimit default 4, scaleDownDelaySeconds / abortScaleDownDelaySeconds default 30; consecutiveSuccessLimit since v1.8; without traffic routing the weight is approximated by replica ratio; the core no longer accepts new traffic providers (pluginized) | releases · Analysis · Canary · Traffic Management · v1.10.2 source code utils/defaults/defaults.go |
| Argo CD support for Rollouts | Health check: Paused → Suspended; resource actions restart / resume / abort / retry / pause / promote-full / skip-current-step | argo-cd v3.6.1 resource_customizations/argoproj.io/Rollout/ (health.lua, actions/discovery.lua) |
| Argo CD Image Updater | v1.5.0 (2026-11-12); 0.x maintenance release v0.19.0; since 1.0.0 (2025-11) changed to ImageUpdater CRD (argocd-image-updater.argoproj.io/v1alpha1); strategies semver / newest-build / digest / alphabetical / calver; write-back argocd (default) / git; writeBackTarget; write-back branch template; supports only Helm / Kustomize / Plugin; chart argo/argocd-image-updater 1.5.0; recommended to install in the Argo CD namespace | releases · Documentation(applications, update-methods, update-strategies, installation) |
| Notifications | trigger / template / service / subscription structure; list of catalog triggers; Webhook service parameters and retry defaults (retryMax 3); oncePer; self-service notifications | Notifications · Webhook · Catalog |
| Sync Windows | allow / deny decision rules, deny precedence, manualSync, timeZone, syncOverrun, AND option; CLI argocd proj windows | Sync Windows(v3.6.1 documentation source) |
| Prometheus | chart prometheus-community/prometheus 29.47.2 (Prometheus v3.16.0); default scrape_interval 1m; kubernetes-pods job scrapes by annotation and labelmaps Pod labels; kube-prometheus-stack 93.3.1 | prometheus-community/helm-charts(values.yaml, index.yaml) |
| podinfo | 6.17.0 (2026-10-26), 6.16.0; metrics http_requests_total{status} and http_request_duration_seconds{method,path,status}; --port-metrics independent metrics server (including /healthz); --random-error (about 1/3 of requests return 500/400/409, applied to all routes on the main port); environment variable prefix PODINFO_ | podinfo 6.17.0 source code (pkg/api/http/metrics.go, http.go, server.go; cmd/podinfo/main.go) |
| Kargo | v1.12.6 (2026-11-16), Akuity open source; Warehouse / Freight / Stage / Promotion; promotion steps include git-clone, kustomize-set-image, git-commit, git-push, git-open-pr, git-wait-for-pr, argocd-update, etc. | kargo releases · Promotion Steps |
| Flux / Flagger | Flux v2.10.0; image-reflector-controller and image-automation-controller v1.3.0 (API image.toolkit.fluxcd.io/v1); Flagger v1.45.0 (2026-09-01) | flux2 · image-automation-controller · flagger |
| Kustomize behavior | images: transformations apply to Rollout; replicas: field only supports Deployment / StatefulSet / ReplicaSet / ReplicationController (verified with local kustomize v5.0.1) | Local kubectl kustomize Verified · Rollouts Kustomize Integration |
| helper image | curlimages/curl:8.23.0,mendhak/http-https-echo:43 tag exists | Docker Hub tag list |
Video verification note
The following videos had their titles and channels verified via the YouTube oEmbed API on 2026-11-17: TechWorld with Nana, “What is GitOps, How GitOps works and Why it's so useful” (f5EpcWp0THw); DevOps Journey, “Argo Rollouts in 15 minutes!” (w3xdopP4aEk); CNCF, “Tutorial: Progressive Delivery with Argo Rollouts” (tnB0TwEqNFA); Geert Baeke, “A blue-green deployment with Argo Rollouts and Kustomize” (ArCu7Wi0AJY); CNCF, “Stop Deploying Blind! Using Observability and Argo Rollouts to Light the Way - Kostis Kapelonis” (oeHdkvVKAZE); DevOps & AI Toolkit, “GitOps Without Pipelines With ArgoCD Image Updater” (avPUQin9kzU) and “How To Do Canary Deployments In Kubernetes Using Flagger And Linkerd?” (NrytqS43dgw); Anton Putra, “ArgoCD Notifications (Successful/Failed Deployments)” (OP6IRsNiB4w); mkdev, “Argo CD Self-Heal, Sync Windows and Diffing” (I77xIKNaNRg); Platform Engineering, “Kargo - Multi-Stage Deployment Pipelines using GitOps - Jesse Suen / Kent Rancourt” (0B_JODxyK0w); Akuity, “Introducing Kargo with Jesse Suen and Kelsey Hightower” (yaZc0DdeLKk) and “Multi Environment Promotions Made Simple | Akuity Webinar” (bFXxvvM-jcQ). oEmbed does not return duration or publish date, so no duration is shown on the cards. All videos are in English, and most were recorded before this lesson's version baseline (especially the Image Updater video, which uses the pre-1.0 annotation configuration); configuration details follow this lesson and the official docs.
Voice narration note
The “Voice” tab uses the browser's Web Speech API (speechSynthesis, en-US) to read the narration aloud in real time, with English terms pronounced in en-US; the result depends on the voices installed on the operating system. This courseware does not embed an MP3; when offline audio is needed, the narration script can be given to a TTS service to generate it.
Known limitations
- The commands in this lesson have not been run one by one on a real kind cluster; all “expected outputs” are compiled from the official docs and source code as examples, and name suffixes, hashes, commit IDs, times and values depend on your environment. The only items that can be verified by running locally are the kustomize renders (the Rollout images transformation and the replicas restriction were verified).
- The Image Updater controller's Deployment name, log text and the Helm chart's default watch scope change across versions (the official docs now state that the default is to watch only its own namespace); refer to
kubectl -n argocd get deployand the chart README. The check interval is controlled by--interval, and this lesson does not assert a specific default value. argocd admin notifications template notifyof--recipientuses the format “service:recipient”; where the Webhook has no recipient, this lesson writeslocal:, and if the CLI reports a format error, refer to--help.- Rollouts'
fieldRef: metadata.namespaceparameter syntax follows the general use of fieldRef in the documentation (the documentation examples use the labels and status fields); if it is unavailable, pass the namespace value directly with a patch in each overlay. - Without traffic routing, the canary ratio is affected by replica count and connection reuse; the podinfo random errors use a random number seeded by the second, so results may appear in clusters over a short time, and the success rate can fluctuate significantly.
- Kargo is not installed in the lab cluster for demonstration; only the model and step names are introduced. The action versions in the GitHub Actions snippets follow the official GitHub documentation.
- The times, ratios and measurement values in the animations are illustrative, used to explain the mechanism, and are not the controller's exact behavior.