Overview
With generators, the ApplicationSet controller provides powerful tools to automate the templating and modification of Argo CD Applications. Here are the primary use cases that ApplicationSet was designed to support.Cluster Add-ons
An initial design focus of the ApplicationSet controller was to enable infrastructure teams to automatically create and manage a large set of Argo CD Applications across many clusters as a single unit.The Problem
Infrastructure teams are responsible for provisioning cluster add-ons to multiple Kubernetes clusters:-
Cluster add-ons are operators and controllers like:
- Prometheus operator for metrics
- Argo Workflows controller for workflow orchestration
- Cert-manager for certificate management
- Ingress controllers
-
Scale challenges:
- Organizations may manage tens, hundreds, or thousands of clusters
- New clusters are added/modified/removed regularly
- Different add-ons need to target different cluster subsets (staging vs production)
-
Permission requirements:
- Installing add-ons requires cluster-level permissions
- Development teams (cluster tenants) don’t have these permissions
- Infrastructure/ops teams need automation to scale
The Solution
The infrastructure team maintains a Git repository with application manifests for cluster add-ons. ApplicationSet automatically deploys these add-ons to target clusters.
Option 1: List Generator
Manually maintain a list of target clusters:Adding/removing clusters requires manually updating the ApplicationSet’s list elements.
Option 2: Cluster Generator (Recommended)
Automatically detect all clusters defined in Argo CD:Adding/removing a cluster from Argo CD automatically creates/removes the corresponding Application.
Option 3: Git Generator
Most flexible approach using Git as the source of truth: Using files field:Monorepos
In the monorepo use case, cluster administrators manage the entire state of a Kubernetes cluster from a single Git repository.The Problem
- Single Git repository contains manifests for multiple applications
- Changes to the repository should automatically deploy to the cluster
- Need to avoid creating individual Application resources for each service manually
- Want GitOps workflow where merging to main triggers deployment
The Solution
ApplicationSet automatically discovers applications in the monorepo and creates Application resources for each.
Git Directory Approach
Repository structure:This creates Applications for
argo-workflows, prometheus-operator, cert-manager, api, and worker.Git Files Approach
Repository structure:Self-Service Multi-Tenant Deployments
The self-service use case allows developers on multi-tenant Kubernetes clusters to deploy applications without requiring cluster administrator intervention.The Problem
Developers want to:- Deploy multiple applications to a single cluster
- Deploy to multiple clusters
- Do so without involving cluster administrators for each deployment
- Developers define Argo CD Application resources in Git
- Admins review/accept via merge requests
- Security risk: Application spec contains sensitive fields:
project- controls permissionscluster- target clusternamespace- target namespace
- Inadvertent merge could grant excessive permissions
The Solution
ApplicationSet allows admins to restrict sensitive fields while letting developers customize safe fields.Safe Self-Service Pattern
Repository structure (developer-controlled):Security benefits:
- Developers can customize: source repo, revision, path
- Admins control: target cluster, namespace, project
- Developers cannot escalate privileges
- Git commits only contain config.json, not full Application specs
Multi-Cluster Self-Service
Extend to multiple clusters using Matrix generator:This creates Applications for each app config on each cluster:
team-a-frontend-staging, team-a-frontend-production, etc.Multi-Cluster Deployment Patterns
Deploy Different Apps to Different Clusters
Use cluster labels to control which apps deploy where:Progressive Rollout Across Clusters
Deploy to dev, then staging, then production:Best Practices
Start Simple with List/Cluster Generators
Start Simple with List/Cluster Generators
Begin with List or Cluster generators before moving to more complex Git-based generators. This helps you understand the fundamentals.
Use Automated Sync Policies
Use Automated Sync Policies
Enable automated sync with prune and selfHeal for true GitOps:
Leverage Cluster Labels
Leverage Cluster Labels
Use cluster labels extensively for flexible targeting:
environment: production/staging/devregion: us-east/us-west/eutier: frontend/backend/data
Control Sensitive Fields in Self-Service
Control Sensitive Fields in Self-Service
Always hard-code
project, destination.server, and destination.namespace when allowing developer customization.Use Matrix for Combinations
Use Matrix for Combinations
When you need to deploy multiple apps to multiple clusters, Matrix generator eliminates duplication.
Next Steps
Generators
Dive deep into each generator type and their configuration options
Security
Understand security implications and access control for ApplicationSets