ApplicationSets for Multi-Environment
What you'll learn: How to use ArgoCD ApplicationSets to automatically generate multiple Applications across clusters, namespaces, or environments from a single template.
The Challenge: Managing Many Similar Applications
Imagine manually creating 20 ArgoCD Applications—one for dev, staging, and production across multiple regions. You'd copy-paste Application manifests, tweaking cluster URLs and namespaces each time. ApplicationSets solve this by acting like a template engine that generates Applications automatically based on rules.
What is an ApplicationSet?
An ApplicationSet is a higher-level ArgoCD resource that uses generators to create multiple Application resources from one definition. Think of it as a "for loop" for Applications—you define the pattern once, and ArgoCD creates instances for each environment automatically.
How Generators Work
Generators produce parameters that populate your Application template:
- List Generator: Define explicit values (e.g.,
["dev", "staging", "prod"]) - Cluster Generator: Auto-discover registered clusters and deploy to each
- Git Generator: Read environment configs from Git directory structure
For example, a Cluster Generator inspects all clusters registered in ArgoCD and creates an Application for each, automatically passing cluster name and server URL as parameters.
Multi-Environment Pattern
apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
name: myapp-environments
spec:
generators:
- list:
elements:
- env: dev
namespace: myapp-dev
- env: prod
namespace: myapp-prod
template:
metadata:
name: 'myapp-{{env}}'
spec:
destination:
namespace: '{{namespace}}'
source:
path: environments/{{env}}
This single manifest generates myapp-dev and myapp-prod Applications automatically. Update the list, and ArgoCD creates/removes Applications accordingly.
Key Takeaway: ApplicationSets eliminate manual Application duplication by using generators to automatically deploy the same application pattern across multiple clusters, namespaces, or environments from one declarative template.