Argo CD in practice

Advanced · 26 min

Running Argo CD for many apps: AppProjects as guardrails, ApplicationSets instead of hand-made Applications, sync waves and hooks, sync options, and drift.

Before thisKustomize in depthHelm charts in depthRBAC

CNCF [Cloud Native Computing Foundation] · 26 min

Argo CD in practice

The player loads from youtube-nocookie.com when you press play. Nothing reaches YouTube before that.

Taught by CNCF [Cloud Native Computing Foundation]Report a problem with this video
Not started
Set this lesson's status

What you'll learn

  • Argo CD is a set of CRDs plus controllers. Application says sync this path to that destination, AppProject limits what Applications may do, and ApplicationSet stamps out Applications from generators.
  • AppProjects are the security boundary: allowed source repos, destination clusters and namespaces, and which kinds may be created. Never leave teams on the default project.
  • ApplicationSet generators (git directories or files, list, cluster, pull request, matrix and merge) replace hand-made Applications and app-of-apps for fleets of environments or clusters.
  • Within a sync, resources apply in waves (argocd.argoproj.io/sync-wave), and PreSync, Sync and PostSync hooks run Jobs around them. Helm hooks are mapped onto these, since Argo CD renders charts with helm template.
  • Automated sync with prune and selfHeal makes Git authoritative. ignoreDifferences and server-side apply stop fights with controllers that legitimately own fields, such as an HPA's replicas.
  • Since Argo CD 3.0, resources are tracked by an annotation rather than a label, which avoids mix-ups when labels are copied.

One Application is easy. Two hundred aren’t

The devops lesson on GitOps covered the core idea: an agent in the cluster pulls desired state from Git and keeps reconciling. A single Argo CD Application with selfHeal and prune was enough to show it. Real platforms run dozens of services across dev, staging and production, often across several clusters, for teams who shouldn’t be able to touch each other’s namespaces. Hand-written Applications multiply, nobody knows which repo can deploy what, and a migration Job races the Deployment it’s meant to precede.

This lesson is about the parts of Argo CD (v3.6.3 when checked) that handle that scale: projects, ApplicationSets, sync ordering and sync options.

Argo CD is CRDs plus controllers

Argo CD’s model lives in three custom resources. Installing its v3.6.3 CRDs into a lab API server gave:

NAME              SHORTNAMES         APIVERSION             NAMESPACED   KIND
applications      app,apps           argoproj.io/v1alpha1   true         Application
applicationsets   appset,appsets     argoproj.io/v1alpha1   true         ApplicationSet
appprojects       appproj,appprojs   argoproj.io/v1alpha1   true         AppProject

Behind them run the application controller (compares and syncs), the repo server (clones Git and renders Kustomize, Helm or plain YAML), the ApplicationSet controller, and the API server and UI. The CRDs’ schemas catch typos at apply time. An Application with prune: yes-please was rejected: spec.syncPolicy.automated.prune in body must be of type boolean.

AppProjects are the guardrails

Every Application belongs to a project, and the project limits it:

apiVersion: argoproj.io/v1alpha1
kind: AppProject
metadata:
  name: shop
  namespace: argocd
spec:
  sourceRepos: ["https://github.com/acme/shop-config.git"]
  destinations:
  - server: https://kubernetes.default.svc
    namespace: "shop-*"
  clusterResourceWhitelist: []
  namespaceResourceBlacklist:
  - {group: "", kind: ResourceQuota}

Applications in shop may deploy only from that repo, only to shop-* namespaces, may create no cluster-scoped resources at all, and can’t change their own quotas. Argo CD applies changes with its own powerful ServiceAccount, so this is the boundary that matters. A team that can create Applications in the default project can deploy anything anywhere. Projects also carry roles for Argo CD’s own RBAC (who may sync or delete) and sync windows that block automated syncs during, say, a release freeze.

ApplicationSets instead of hand-made Applications

An ApplicationSet generates Applications from a template and one or more generators:

apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
  name: shop-envs
  namespace: argocd
spec:
  goTemplate: true
  goTemplateOptions: ["missingkey=error"]
  generators:
  - git:
      repoURL: https://github.com/acme/shop-config.git
      revision: main
      directories:
      - path: overlays/*
  template:
    metadata:
      name: "shop-{{.path.basename}}"
    spec:
      project: shop
      source:
        repoURL: https://github.com/acme/shop-config.git
        targetRevision: main
        path: "{{.path.path}}"
      destination:
        server: https://kubernetes.default.svc
        namespace: "shop-{{.path.basename}}"
      syncPolicy:
        automated: {prune: true, selfHeal: true}
        syncOptions: [CreateNamespace=true, ServerSideApply=true]

Each Kustomize overlay directory becomes an Application named shop-<dir>. Add overlays/perf in a commit and an Application appears. The lab API server accepted both objects, but with no ApplicationSet controller running, nothing was generated and the status stayed empty.

The generators worth knowing:

  • git (directories or JSON/YAML files) for one Application per folder or per config file.
  • list for a fixed set of values.
  • cluster for one Application per registered cluster, filtered by labels. This is how one add-on gets onto every cluster.
  • pullRequest for a preview environment per open PR.
  • matrix and merge to combine them, such as every service × every cluster.

The older app of apps pattern, an Application whose manifests are other Applications, still works for bootstrapping, but ApplicationSets are more controlled: the template is fixed, so a commit to a values folder can’t create an Application in another project. missingkey=error makes a typo fail instead of rendering an empty string into a namespace name.

Ordering a sync: waves and hooks

Within one sync, Argo CD orders resources by phase and wave:

metadata:
  annotations:
    argocd.argoproj.io/hook: PreSync
    argocd.argoproj.io/hook-delete-policy: HookSucceeded
---
metadata:
  annotations:
    argocd.argoproj.io/sync-wave: "-1"

Phases run PreSync → Sync → PostSync, with SyncFail on failure. Within a phase, waves run lowest first, and Argo CD waits for each wave to be healthy before starting the next. Use them for a migration Job before the app, CRDs before the custom resources that use them, or a Namespace and its quota before the workloads.

Because Argo CD renders charts with helm template, Helm hooks don’t run as Helm would run them. Argo CD maps pre-install and pre-upgrade to PreSync, post-install and post-upgrade to PostSync, and ignores some others. There is no Helm release Secret, and helm list shows nothing. That surprises people who expect the Helm lifecycle.

Living with other controllers

Git can’t own everything. An HPA owns replicas. A mutating webhook injects sidecars. A controller fills in defaults. With selfHeal, Argo CD would fight them. The tools:

  • Don’t declare fields another controller owns. Leave replicas out when an HPA is attached.
  • ignoreDifferences on specific JSON paths or managed-fields managers.
  • ServerSideApply=true, so field ownership is respected and large CRDs don’t hit the client-side annotation size limit.
  • PruneLast=true and prune confirmation for dangerous deletions.

Since Argo CD 3.0, the default resource tracking method is an annotation (argocd.argoproj.io/tracking-id) instead of the app.kubernetes.io/instance label. Copied labels no longer make Argo CD think it owns, and prunes, resources it didn’t create.

Day-2 habits

  • Run the Argo CD control plane like production: HA mode, its own namespace, SSO for the UI, and the admin account disabled.
  • One AppProject per team, clusterResourceWhitelist empty by default.
  • Promote by commit: CI updates an image tag in the dev overlay, and a PR copies it to prod.
  • Watch the OutOfSync and Degraded health states in alerts, not just the UI.

About the video

The embed is Alexander Matyushentsev’s KubeCon North America 2024 talk “Mastering ApplicationSet: Advanced Argo CD Automation”, up to the Q&A, 26 minutes. He co-created Argo CD and co-founded Akuity. Going by its chapters, it starts from the problem of managing many Applications, compares the CLI/API approach, app of apps and ApplicationSet, then covers real-world challenges, troubleshooting and the roadmap. It predates Argo CD 3.0, so the tracking-annotation default is newer than the talk. I judged it from chapters and description only, since transcripts couldn’t be fetched. English was judged from the title, speaker and English caption track. The page shows no audio-language flag. Viktor Farcic’s sync-waves video in deeper covers ordering in depth.

What was run: Argo CD v3.6.3’s CRDs were installed into a local Kubernetes v1.37.3 API server, and the API resource list, the AppProject and ApplicationSet creation, and the schema rejection are real output. No Argo CD controller, repo server or Git repository was running, so generation, syncing, waves and hook behaviour are written from the Argo CD docs and the 2.14-to-3.0 upgrade notes, checked 2026-11-29.

Where this fits

Argo CD applies a change everywhere at once. Next, rolling it out gradually: progressive delivery: canaries and blue-green.

Check yourself

  1. 01A team's Application points at a repo you don't control and deploys a ClusterRoleBinding. What Argo CD object should have stopped that?

    Its AppProject. sourceRepos should allow only approved repositories, and clusterResourceWhitelist should be empty (or list only what the team may create) so cluster-scoped kinds like ClusterRoleBinding are refused.

  2. 02You have 40 overlays/<env> directories and add a new one each sprint. How do you avoid writing 40 Applications?

    An ApplicationSet with a git directory generator over overlays/*, templating the Application name, path and namespace from each directory. A new directory in Git produces a new Application automatically, and deleting it removes the Application.

  3. 03A database migration Job must finish before the new Deployment rolls out. How do you express that in Argo CD?

    Make the Job a PreSync hook (argocd.argoproj.io/hook: PreSync), or put it in an earlier sync wave than the Deployment. Argo CD waits for each wave to be healthy before applying the next.

  4. 04With selfHeal on, Argo CD keeps resetting replicas that the HPA set. What are the fixes?

    Remove replicas from the manifests in Git so nobody declares it, or add an ignoreDifferences entry for /spec/replicas on that Deployment, and use server-side apply so field ownership is respected.

Go deeper

Notes

Private to you

Esc
↑↓ navigate↵ open? shortcuts

Keyboard shortcuts

Press Esc to close

Anywhere

⌘K
Search and commands
/
Search
?
This sheet
Esc
Close

Reading a lesson

J
Next lesson
K
Previous lesson
B
Bookmark