Overview
Generators are responsible for generating parameters, which are then rendered into thetemplate: fields of the ApplicationSet resource. Each generator type uses a different data source to produce these parameters.
If you are new to generators, begin with the List and Cluster generators. For more advanced use cases, explore the remaining generators.
List Generator
The List generator generates parameters based on an arbitrary list of key/value pairs. This is the simplest generator type.Basic Example
Clusters must be predefined in Argo CD. The ApplicationSet controller does not create clusters within Argo CD.
Flexible Key/Value Pairs
As of ApplicationSet v0.2.0, any key/value element pair is supported:Dynamic Elements with elementsYaml
You can dynamically generate list elements from Git by combining with a Matrix generator:Cluster Generator
The Cluster generator automatically identifies clusters defined in Argo CD and extracts cluster data as parameters.How It Works
In Argo CD, managed clusters are stored as Secrets in the Argo CD namespace. The Cluster generator uses these Secrets to produce parameters:name- Cluster namenameNormalized- Name normalized to lowercase alphanumeric, ’-’ or ’.’server- Cluster API server URLproject- The Secret’s ‘project’ field (defaults to empty)metadata.labels.<key>- Each label in the Secretmetadata.annotations.<key>- Each annotation in the Secret
Basic Example
Label Selector
Target only specific clusters using label selectors:Pass Additional Values
Provide additional parameters based on cluster labels:The
values. prefix is always prepended to values provided via generators.clusters.values field.Filter by Kubernetes Version
Filter clusters based on their Kubernetes version:You must set the label
argocd.argoproj.io/auto-label-cluster-info to true on the cluster secret for automatic version labeling.Git Generator
The Git generator has two subtypes: directories and files.Git Directory Generator
Generates parameters based on directory structure in a Git repository:{{.path.path}}- Directory path matching the wildcard{{index .path.segments n}}- Path split into array elements{{.path.basename}}- Right-most directory name{{.path.basenameNormalized}}- Basename with unsupported characters replaced
Exclude Directories
Exclude specific directories from being scanned:Git File Generator
Generates parameters from JSON/YAML files in a Git repository:{{.path.path}}- Path to directory containing the config file{{index .path.segments n}}- Path split into array elements{{.path.basename}}- Directory basename{{.path.filename}}- Matched filename{{.path.filenameNormalized}}- Filename with unsupported characters replaced
Matrix Generator
The Matrix generator combines parameters from two child generators, creating every possible combination.Common Use Cases
- SCM Provider + Cluster: Scan GitHub organization repositories and deploy to all clusters
- Git Files + List: Deploy applications from config files to a fixed list of clusters
- Git Directory + Cluster Decision Resource: Deploy applications from Git folders to clusters from a custom resource
Example: Git Directory + Cluster
- Finds
argo-workflowsandprometheus-operatordirectories - Finds
stagingandproductionclusters - Generates 4 Applications: each app on each cluster
Using Parameters Between Generators
You can use parameters from one child generator in another:When using parameters from one child generator in another, the consuming generator must come after the producing generator.
Two Git Generators with pathParamPrefix
When using two Git generators, usepathParamPrefix to avoid parameter conflicts:
Additional Generators
Merge Generator
Merges parameters from two or more generators. Additional generators can override base generator values.
SCM Provider
Uses GitHub/GitLab/Bitbucket APIs to automatically discover repositories within an organization.
Pull Request
Uses SCM provider APIs to automatically discover open pull requests within a repository.
Cluster Decision Resource
Interfaces with Kubernetes custom resources that use custom logic to decide which clusters to deploy to.
Plugin Generator
Makes RPC HTTP requests to external services to provide parameters.
Post Selector
All generators can be filtered using a Post Selector to further refine generated parameters:Next Steps
Use Cases
Explore real-world patterns for cluster add-ons, monorepos, and self-service deployments