Stage 4 · Provision
Continuous Delivery & GitOps
ArgoCD ApplicationSets
Cluster generators, app-of-apps, sync waves, and self-healing reconciliation — templating ArgoCD at scale.
What Are ApplicationSets?
An ApplicationSet is a template for creating ArgoCD Applications. Instead of creating one Application per service, per cluster, or per environment, you define a template and a generator that produces parameters. ArgoCD creates Applications automatically from the template and parameters.
ApplicationSets solve the scaling problem — managing hundreds of Applications manually is error-prone and tedious. The generator pattern ensures consistency and reduces duplication.
Generators
Generators produce the parameter matrix for ApplicationSet templates. Each generator type reads parameters from a different source — clusters, Git files, directories, or lists.
apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
name: my-app
namespace: argocd
spec:
generators:
- list:
elements:
- env: dev
url: https://dev-cluster.example.com
- env: staging
url: https://staging-cluster.example.com
- env: prod
url: https://prod-cluster.example.com
template:
metadata:
name: 'my-app-{{env}}'
spec:
project: default
source:
repoURL: https://github.com/org/k8s-manifests.git
targetRevision: main
path: 'apps/my-app/{{env}}'
destination:
server: '{{url}}'
namespace: my-appThe list generator defines elements with parameters. The template uses {{env}} and {{url}} placeholders. ArgoCD creates one Application per element. This generates three Applications: my-app-dev, my-app-staging, my-app-prod.
Cluster Generator
The cluster generator reads ArgoCD's registered clusters and creates an Application per cluster. This is ideal for deploying the same application to multiple clusters — one ApplicationSet deploys everywhere.
apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
name: monitoring
namespace: argocd
spec:
generators:
- clusters:
selector:
matchLabels:
env: production
template:
metadata:
name: 'monitoring-{{name}}'
spec:
project: default
source:
repoURL: https://github.com/org/monitoring.git
targetRevision: main
path: overlays/production
destination:
server: '{{server}}'
namespace: monitoring
syncPolicy:
automated:
prune: true
selfHeal: trueThe cluster generator creates an Application for each cluster matching the label selector. When a new cluster is registered with the env:production label, ArgoCD automatically creates and syncs a new Application for it.
Git Generator
The git generator reads parameters from Git — either from directory names or from YAML/JSON files. This is the most flexible generator — adding a new environment or service is a Git commit.
apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
name: microservices
namespace: argocd
spec:
generators:
- git:
repoURL: https://github.com/org/k8s-manifests.git
revision: main
directories:
- path: services/*
template:
metadata:
name: '{{path.basename}}'
spec:
project: default
source:
repoURL: https://github.com/org/k8s-manifests.git
targetRevision: main
path: '{{path}}'
destination:
server: https://kubernetes.default.svc
namespace: '{{path.basename}}'The git directory generator scans the services/ directory. Each subdirectory creates an Application. Adding a new directory creates a new Application. Removing a directory prunes the Application.
apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
name: services
namespace: argocd
spec:
generators:
- git:
repoURL: https://github.com/org/k8s-manifests.git
revision: main
files:
- path: 'services/*/config.json'
template:
metadata:
name: '{{appName}}'
spec:
project: default
source:
repoURL: '{{repoURL}}'
targetRevision: '{{revision}}'
path: '{{path}}'
destination:
server: '{{cluster}}'
namespace: '{{namespace}}'The git file generator reads parameters from config.json files in each service directory. Each config.json defines the application name, repo URL, revision, and destination. This is the most flexible generator.
Sync Waves
Sync waves control the order of resource deployment within an Application. Resources with lower sync wave numbers deploy before resources with higher numbers. This ensures dependencies are met.
# Namespace (deploys first)
apiVersion: v1
kind: Namespace
metadata:
name: my-app
annotations:
argocd.argoproj.io/sync-wave: "-10"
---
# ConfigMap (deploys second)
apiVersion: v1
kind: ConfigMap
metadata:
name: my-config
annotations:
argocd.argoproj.io/sync-wave: "-5"
---
# Deployment (deploys third)
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-app
annotations:
argocd.argoproj.io/sync-wave: "0"Negative sync waves deploy before the default (0). Resources with the same wave number deploy in parallel. This ensures namespaces exist before ConfigMaps, and ConfigMaps exist before Deployments.
Self-Healing Reconciliation
Self-healing means ArgoCD reverts manual changes to match the desired state in Git. Combined with sync waves, self-healing ensures the entire stack remains consistent.
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: my-app
spec:
syncPolicy:
automated:
prune: true # Remove resources deleted from Git
selfHeal: true # Revert manual changes
syncOptions:
- CreateNamespace=true
- ServerSideApply=trueselfHeal: true means ArgoCD detects when the cluster state differs from Git and reverts the change. This is essential for maintaining consistency — manual changes are reconciled away.
ApplicationSets eliminate the need to create individual Applications for each service or cluster. One template generates all Applications. Changes to the template propagate to all Applications automatically.
A misconfigured generator can create hundreds of Applications. Test with a small list first. Use the git file generator for fine-grained control over which Applications are created.
Mark this lesson complete to store local progress and unlock a cleaner resume path the next time you visit.