ApplicationSet and environment promotion
Generate Applications, not clusters
An ApplicationSet is a custom resource managed by the Argo CD ApplicationSet controller. It creates or updates Application objects using a generator and a template. A list generator supplies explicit rows; a cluster generator uses registered cluster information; a Git generator reads repository paths or files. Matrix generators can combine inputs, multiplying the number of resulting Applications. The generated Applications perform ordinary Argo CD delivery. The generator does not create Kubernetes clusters or automatically grant access. Preview names, targets and counts before approval.
2 environments x 1 catalog app = 2 ApplicationsA matrix with 2 environments x 3 services = 6 ApplicationsCreate a bounded two-environment definition
This complete illustrative ApplicationSet assumes two registered destinations and an existing restricted AppProject. It uses Go templates in string fields and fails when a required key is missing. Go templates are evaluated per string field, not arbitrary YAML objects. The revision names and URLs are fictional; resolve each revision to a reviewed commit in a real delivery record. The ApplicationSet policy controls changes to Applications, not their sync behavior. No automated sync is configured here.
apiVersion: argoproj.io/v1alpha1kind: ApplicationSetmetadata: name: catalog-environments namespace: argocdspec: goTemplate: true goTemplateOptions: ["missingkey=error"] generators: - list: elements: - env: dev server: https://dev.example.invalid revision: reviewed-dev - env: staging server: https://staging.example.invalid revision: reviewed-staging template: metadata: name: 'catalog-{{.env}}' spec: project: catalog-lab source: repoURL: https://git.example.invalid/catalog/config.git targetRevision: '{{.revision}}' path: 'overlays/{{.env}}' destination: server: '{{.server}}' namespace: 'catalog-{{.env}}' syncPolicy: applicationsSync: create-update preserveResourcesOnDeletion: trueReview the deletion and trust boundaries
A generator entry disappearing can remove an Application under default controller policy. The fixture requests create-update to avoid controller-driven deletion on generator changes, and requests workload preservation on Application deletion; actual controller settings may override policy, and deleting the parent can still trigger Kubernetes garbage collection. Review finalizers and ownership before any deletion. App-of-apps uses a parent Application to manage child Applications; it is convenient but parent write access is powerful. Restrict repositories, destination namespaces and resource kinds in AppProjects, restrict cluster credentials, and do not accept untrusted pull request content as trusted deployment input.
Review generated names -> check source/destination allowlists -> inspect deletion diff -> approvePromote a reviewed artifact, not a mutable tag
Build the image once, record its immutable digest and attestations, then update each environment overlay through review. A dev success does not authorize staging automatically: require test evidence, a compatible migration plan and approval. Use sync windows to constrain permitted sync times; evaluate matching allow/deny rules and manual overrides with the installed version. Keep secret values outside ordinary Git; use approved external secret references or an encrypted workflow with restricted decryption rights. Do not ignore all differences: document narrowly scoped exceptions for fields owned by another controller, such as HPA-managed replica counts. Flux offers separate source, Kustomization and HelmRelease reconciliation APIs; do not let two systems manage the same fields without explicit ownership.
Dev verified digest D -> reviewed staging overlay points to D -> sync window and policy checks -> staging smoke testPractice and next step
Open lab-fixtures/advanced-gitops/applicationset.yaml and promotion-cases.json. Predict generated names and which promotion requests pass the local policy. Run validate_offline.py. Explain why the tests cannot establish actual AppProject permissions, controller deletion behavior or sync-window enforcement. Next: progressive delivery and rollback.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
ApplicationSet and environment promotion — knowledge check
Design a controlled ApplicationSet and promote a reviewed artifact across two environments.
What does a list generator create through ApplicationSet?
Two environments and three services are combined in a full matrix. How many applications are expected if all combinations are unique?
What does missingkey=error help detect?
What should be promoted from dev to staging?
What does create-update on an ApplicationSet govern?