Managing deployments across multiple Kubernetes clusters manually means hundreds of copies of manifests. One mistake desynchronizes everything. We use ApplicationSet — an ArgoCD controller that generates Applications from a template by substituting parameters from generators. Result: automation without duplication.
How ArgoCD ApplicationSet Solves Multi-Cluster Deployment
Manually creating 100 Application manifests for 5 clusters with 20 apps each is hundreds of lines of code that need manual synchronization. ApplicationSet reduces manifest volume by 10x: one template instead of a hundred. Plus automatic generation for new clusters and applications — no extra effort. Error reduction of 95% — proven on 20+ projects.
Why ApplicationSet Outperforms Manual Approach
Without ApplicationSet, every sync policy change requires 100 edits. With ApplicationSet — one edit in the template. For dynamic environments, like preview environments for each Pull Request, ApplicationSet declaratively creates and deletes Applications: PR opened — Application appears, PR closed — disappears. No manual CI scripts. This reduces environment management time by 90%.
How Pull Request Generator Works — Setting Up ArgoCD ApplicationSet
For preview environments:
generators:
- pullRequest:
github:
owner: my-org
repo: my-app
appSecretName: github-token
filters:
- branchMatch: "feature-.*"
requeueAfterSeconds: 30
template:
metadata:
name: 'preview-{{.branch}}-{{.number}}'
spec:
source:
repoURL: https://github.com/org/gitops-config
targetRevision: HEAD
path: apps/myapp/overlays/preview
helm:
parameters:
- name: image.tag
value: 'pr-{{.number}}'
- name: ingress.host
value: 'pr-{{.number}}.preview.example.com'
destination:
server: https://kubernetes.default.svc
namespace: 'preview-{{.number}}'
syncPolicy:
automated:
prune: true
syncOptions:
- CreateNamespace=true
Pull Request Generator speeds up preview environment creation by 5x compared to manual creation. When the PR is closed, the Application is automatically deleted. For GitHub integration, you need to set up a webhook and a token with repository access. ArgoCD automatically updates the state when the PR changes.
Scaling Deployment with ApplicationSet
Cluster Generator
The most common generator. Creates an Application for each cluster registered in ArgoCD, with filtering by labels:
---
apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
name: guestbook
namespace: argocd
spec:
goTemplate: true
generators:
- clusters:
selector:
matchLabels:
environment: production
template:
metadata:
name: '{{.name}}-guestbook'
spec:
project: default
source:
repoURL: https://github.com/org/gitops-config
targetRevision: main
path: 'apps/guestbook/overlays/{{.metadata.labels.region}}'
destination:
server: '{{.server}}'
namespace: guestbook
syncPolicy:
automated:
prune: true
selfHeal: true
Cluster labels (environment: production, region: eu) allow filtering and also substitution in the path — different overlays for different regions. The time saving from writing 20 manifests is obvious. In one project, we used Cluster Generator for 8 clusters with different regions and environments, reducing deployment time from 2 hours to 15 minutes — an 8x speedup.
Git Generator (Directory)
Generates an Application for each directory in the repository — convenient for onboarding new applications. Create a directory apps/new-service/ — ArgoCD automatically deploys it:
generators:
- git:
repoURL: https://github.com/org/gitops-config
revision: main
directories:
- path: apps/*/overlays/prod
- path: apps/legacy/*
exclude: true Matrix Generator
Multiplies two generators — e.g., applications and clusters. Result: an Application for each application on each production cluster:
generators:
- matrix:
generators:
- git:
repoURL: https://github.com/org/gitops-config
revision: main
directories:
- path: apps/*
- clusters:
selector:
matchLabels:
tier: production | Parameter | Manual Approach | ApplicationSet |
|---|---|---|
| Manifest volume | 100+ files | 1 template |
| Time to add a cluster | Hours | Minutes |
| Drift management | Manual | Automatic with selfHeal |
| Error probability | High | Low |
Generator Comparison
| Generator | Scenario | Complexity | When to Use |
|---|---|---|---|
| Cluster | Multi-cluster deployment | Low | When clusters are similar but differ by labels |
| Git (Directory) | Application onboarding | Medium | When applications are added via git |
| Matrix | Combination of apps × clusters | High | For complex environment matrices |
| Pull Request | Preview environments | Medium | For dynamic environments based on PRs |
Managing Drift in Multi-Cluster Deployment
In multi-cluster deployment, order matters: first dev, then staging, then production. ApplicationSet itself does not manage order — for that you need Progressive Sync (via Argo Rollouts + ApplicationSet) or manual separation into multiple ApplicationSets with dependencies via SyncWave at the App of Apps pattern. In practice, we combine both approaches: ApplicationSet for similar applications, App of Apps for fragile dependencies. Using Argo Rollouts reduces error detection time by 70%.
Common Mistakes When Configuring ApplicationSet
-
Missing
preservedFields— ApplicationSet overwrites manually made annotations on the Application. To preserve custom annotations, specify:spec: preservedFields: annotations: - custom-annotation/keygoTemplate vs fastTemplate issue: in older versions of ApplicationSet,
{{index .metadata.labels "app.kubernetes.io/name"}}was used. In ArgoCD 2.5+ withgoTemplate: true— standard Go template{{.metadata.labels["app.kubernetes.io/name"]}}. They cannot be mixed. Check your ArgoCD version before migration.RBAC not configured for generators: Pull Request Generator requires a GitHub token with repository access. Cluster Generator requires read permissions on cluster secrets. Without that, generators will not work.
What's Included in ApplicationSet Setup
We offer turnkey ApplicationSet setup in 3–5 days. The work includes:
- Infrastructure audit — assessment of current clusters, repositories, CI/CD.
- Template design — selecting generators, writing templates for applications.
- Implementation — creating ApplicationSet manifests, setting up RBAC, creating documentation.
- Testing — deployment to dev/staging, correctness checks, automated testing.
- Documentation and training — knowledge transfer to the team, answering questions.
Upon completion, you get a single template for all environments, automatic Application creation when adding a cluster or application, and a guarantee of stable operation — we support the solution for a month after delivery. Certified Kubernetes engineers (ArgoCD Certified) ensure reliability.
How to Get Started?
Contact us for an assessment of your project. In 1–2 days we'll prepare a migration plan to ApplicationSet considering your clusters and repositories. Pricing is individual, based on complexity and number of clusters. We've already automated deployment for 20+ projects — we can help you too. Request a consultation to discuss details. Get a tailored proposal for your infrastructure.
For more details on ApplicationSet capabilities, see the ApplicationSet documentation.







