An ApplicationSet is a template plus a generator. The generator produces a list of parameter sets; the ApplicationSet controller renders one Application per set and keeps them in step — adding, updating and (by default) deleting them.
apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
name: shop-api
namespace: argocd
spec:
goTemplate: true
goTemplateOptions: ["missingkey=error"]
generators:
- list:
elements:
- { env: dev, cluster: https://kubernetes.default.svc }
- { env: staging, cluster: https://kubernetes.default.svc }
- { env: prod, cluster: https://prod-sg.example.com:6443 }
template:
metadata:
name: 'shop-api-{{.env}}'
spec:
project: shop
source:
repoURL: https://github.com/example-org/shop-config.git
targetRevision: main
path: 'apps/shop-api/overlays/{{.env}}'
destination:
server: '{{.cluster}}'
namespace: 'shop-{{.env}}'
Generators
| Generator | Produces one set per… | Typical use |
|---|---|---|
| List | element you write in the YAML | A few fixed environments |
| Cluster | cluster registered in Argo CD (filter by labels) | Install the same add-on on every cluster |
| Git directories | folder matching a path, e.g. apps/* |
One app per folder in a monorepo |
| Git files | JSON/YAML file, e.g. envs/*/config.json |
Per-environment parameters kept in Git |
| Matrix | combination of two generators | Every app × every cluster |
| Merge | merged result of generators | Defaults plus overrides |
| Pull request / SCM provider | open PR or repository | Preview environments per PR |
generators:
- matrix:
generators:
- git:
repoURL: https://github.com/example-org/platform-config.git
revision: main
directories: [{ path: addons/* }]
- clusters:
selector: { matchLabels: { env: prod } }
# template name: '{{.path.basename}}-{{.name}}'
Safety switches
goTemplate: truewithmissingkey=errorfails loudly on a typo instead of creating an app calledshop-api-.syncPolicy.preserveResourcesOnDeletion: truekeeps workloads if the ApplicationSet is deleted.syncPolicy.applicationsSync: create-only(orcreate-update) stops the controller from deleting Applications when an element disappears.- Generated Applications are owned by the ApplicationSet: edit the template, not the children — manual edits are overwritten.
- An ApplicationSet can create Applications in any project its template names, so only platform admins should write ApplicationSets (or restrict them with the
applicationsetRBAC and allowed projects).
argocd appset create shop-api-appset.yaml
argocd appset list
argocd appset get shop-api