Running ArgoCD for a single cluster with a handful of Applications is straightforward. Running it as the control plane for 30 clusters, 400 microservices, and five environments is a different problem entirely. The UI still looks the same, but the failure modes, scaling bottlenecks, and operational decisions become far less forgiving. In my experience, the jump from a demo installation to a production-grade GitOps platform comes down to three areas: how you template Applications at scale with ApplicationSets, how you configure sync and health to reflect real application needs, and how you model multi-cluster topology without creating a single point of failure. This article covers the patterns I have seen work reliably in production, the ones that cause incidents, and the configuration details that documentation tends to gloss over.
Beyond a Single Application CRD: Structuring ApplicationSets for Fleet Scale
An Application resource is a 1:1 mapping between a Git path and a cluster destination. That is fine for ten services. At fleet scale, maintaining those resources by hand becomes a source of drift itself. I have worked on teams that tried to template Applications with Helm or Kustomize wrappers, and it always ended with a custom script nobody wanted to own. ApplicationSets were built to solve this exact templating problem inside the ArgoCD controller.
The core idea is that an ApplicationSet controller watches a generator and renders an Application for each element it discovers. You declare the template once, and the controller reconciles the set. This keeps Git as the single source of truth while removing the manual toil of creating and deleting Application manifests. In my experience, the most maintainable repositories use one ApplicationSet per logical grouping — for example, one for platform add-ons deployed to every cluster, and one per business unit for workloads — rather than a single monolithic ApplicationSet that tries to generate everything.
Repository Layout That Prevents Generator Sprawl
The generator you choose dictates your directory structure. If you use the Git directory generator, your repo layout becomes your API. I recommend a structure like apps/{app-name}/overlays/{env} combined with clusters/{cluster-name}/values.yaml rather than deeply nested environment folders. This keeps the path used by the generator predictable and makes it trivial to add a new cluster by adding a file, not by editing a central matrix. It also aligns well with how you manage promotion. If you are still deciding how to move changes between environments, the patterns in Environment Promotion in GitOps: From Dev to Production with Confidence provide a solid foundation for branching versus overlay approaches.
Template Hardening and Go Templating Gotchas
ApplicationSet templates support Go templating, but failures are silent in frustrating ways. A typo in {{ .path.basename }} will not fail the ApplicationSet; it will simply generate an Application with an empty name that never syncs. Always set goTemplate: true explicitly and use goTemplateOptions: ["missingkey=error"] so templating errors surface as ApplicationSet conditions. I also add a policy to preserve Applications on deletion during initial rollouts, then switch to automated pruning once I trust the generator output. Validate the generated Applications with argocd appset generate --local in CI before merging.
Choosing Your Generator: Cluster, Git and Matrix Strategies in Practice
Most teams start with the Git generator and hit a wall when they need to target multiple clusters with per-cluster configuration. That is where understanding the generators as composable primitives pays off. You rarely use one in isolation in production.
The Cluster generator discovers destinations from secrets labeled argocd.argoproj.io/secret-type: cluster. It is ideal for platform concerns where every cluster should get the same set of add-ons — ingress-nginx, external-secrets, monitoring — but with per-cluster values. The Git generator is better for application concerns where the source of truth is a directory or file. In practice, I combine them with the Matrix generator, which takes the cartesian product of two generators, and the Merge generator, which overlays values from multiple sources.
For example, a Matrix of Cluster + Git lets you deploy every application found in apps/* to every production cluster, while injecting cluster-specific Helm values. A Merge of Git files + Cluster metadata lets you define defaults in Git and override them per cluster without duplicating configuration. I have found that Matrix is powerful but dangerous: a 50-app x 20-cluster matrix generates 1,000 Applications. If you do not set resource limits on the application-controller and repo-server, you will exhaust memory during the initial generation.
apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
name: platform-addons
namespace: argocd
spec:
goTemplate: true
goTemplateOptions: ["missingkey=error"]
generators:
- matrix:
generators:
- clusters:
selector:
matchLabels:
tier: production
values:
version: "v2.4.1"
- git:
repoURL: https://github.com/org/gitops-repo
revision: HEAD
directories:
- path: platform/addons/*
template:
metadata:
name: '{{.path.basename}}-{{.name}}'
spec:
project: platform
source:
repoURL: https://github.com/org/gitops-repo
targetRevision: HEAD
path: '{{.path.path}}'
helm:
values: |
replicaCount: {{ .values.replicaCount | default 2 }}
clusterName: {{.name}}
clusterEndpoint: {{.server}}
destination:
server: '{{.server}}'
namespace: '{{.path.basename}}'
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=true
- ServerSideApply=true
Notice the explicit destination.server templating and the use of Helm values derived from both generators. I prefer ServerSideApply=true for platform add-ons that include CRDs, as it avoids the last-applied annotation size limits that break large CRDs like Prometheus Operator. According to the Kubernetes Documentation, server-side apply is the recommended mechanism for controllers managing fields declaratively, and ArgoCD surfaces it cleanly as a sync option.
When Not to Use ApplicationSets
If your Application needs per-instance lifecycle control — manual sync windows, completely different sync policies, or human approval — generating it removes that control. I keep critical data-plane Applications like databases and queue systems as standalone Application resources managed outside the set. This also simplifies Progressive Syncs, where you want to roll out to one cluster at a time rather than all at once.
Sync Policies That Survive Production: Prune, Replace and Selective Sync Realities
The default sync behavior in ArgoCD is safe but conservative: it will not prune resources and it will not self-heal. For production GitOps, you almost always want automated sync with pruning and self-heal enabled, but you need to understand what each flag actually does.
Automated prune deletes resources in the cluster that are no longer present in Git. This is desirable for most workloads, but catastrophic if someone accidentally deletes a folder. I mitigate this with two controls: ArgoCD Projects that restrict which namespaces an Application can affect, and a git webhook that requires two reviewers for deletes on promoted branches. Self-heal reverts manual kubectl edits back to the desired state in Git. Leave it on for stateless workloads, but consider disabling it for resources that operators legitimately patch during incidents, such as scaling a Deployment during a traffic spike. You can also disable self-heal selectively with the annotation argocd.argoproj.io/sync-options: Prune=false on a per-resource basis.
The Replace=true sync option forces kubectl replace instead of apply. I only use it for resources that are immutable or where strategic merge patch consistently fails, such as certain Jobs, ServiceMonitors with webhook validation, or mutated ConfigMaps. Overusing Replace causes unnecessary pod restarts and can break rolling updates. Selective sync via argocd app sync --resource is useful for recovery, but do not build your deployment pipeline around it; if you need to sync resources out of order, your health checks or sync waves are likely misconfigured.
| Sync Configuration | Behavior | When to Use It | Risk If Misused |
|---|---|---|---|
| Automated + Prune + SelfHeal | Git is absolute source of truth; out-of-sync resources are corrected and orphans removed | Stateless services, platform add-ons, preview environments | Accidental Git deletion causes mass deletion; manual hotfixes are reverted |
| Automated + Prune=false | Creates and updates but never deletes | StatefulSets with PVCs, resources managed partially outside GitOps | Orphaned resources accumulate; drift goes undetected |
| Manual Sync with Sync Waves | Waits for human approval; respects wave ordering (-5 to 5) and hooks | Production databases, infra migrations, high-risk releases | Deployments stall; reliance on UI breaks automation |
| SyncOption Replace=true | Deletes and recreates resource instead of patching | Immutable fields, CRDs, broken strategic merge patches | Downtime from recreation; pods rescheduled unexpectedly |
| SyncOption ServerSideApply=true | Uses server-side apply for field management | Large CRDs, controllers that manage their own fields | Conflicts with client-side apply tools if not coordinated |
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: payments-api-prod
namespace: argocd
annotations:
argocd.argoproj.io/sync-wave: "2"
spec:
project: payments
source:
repoURL: https://github.com/org/gitops-repo
targetRevision: main
path: apps/payments-api/overlays/prod
destination:
server: https://prod-k8s.example.com
namespace: payments
syncPolicy:
automated:
prune: true
selfHeal: true
allowEmpty: false
syncOptions:
- RespectIgnoreDifferences=true
retry:
limit: 5
backoff:
duration: 5s
factor: 2
maxDuration: 3m
ignoreDifferences:
- group: apps
kind: Deployment
jsonPointers:
- /spec/replicas
- group: autoscaling
kind: HorizontalPodAutoscaler
managedFieldsManagers:
- hpa-controller
This example shows two production-hardening details. First, ignoreDifferences for spec.replicas prevents ArgoCD from fighting the HPA. Without this, every HPA scale-up shows the Application as OutOfSync and, with self-heal on, gets reverted. Second, retry with exponential backoff handles transient failures like webhook timeouts without marking the sync as failed permanently. I have seen prod syncs fail because a single admission webhook was slow; retries eliminate most of that noise.
Orchestrating Deployments Across Multiple Clusters Without Losing Control
Multi-cluster with ArgoCD usually follows one of two architectures: a central hub cluster that manages all remotes, or a distributed model where each cluster runs its own ArgoCD. In my experience, a single hub works up to about 15-20 managed clusters if you tune it correctly. Beyond that, the hub's application-controller becomes a bottleneck, Git rate limiting becomes a problem, and a hub outage blocks deployments everywhere.
For hub architectures, register remote clusters with argocd cluster add and store cluster credentials as secrets. Do not use the in-cluster https://kubernetes.default.svc for everything; be explicit about destinations so ApplicationSets can target correctly. Set --application-controller-workers and shard the controller if you exceed 500 Applications. I also recommend enabling Redis HA and increasing repo-server replicas to at least 3, as repo clones are the primary latency source for multi-cluster syncs.
Sharding and Progressive Rollouts
When you need to roll out to clusters progressively — dev, then staging, then prod-us, then prod-eu — do not rely on manual sync ordering. Use the ApplicationSet Progressive Sync feature (available since ArgoCD 2.8) or the Pull Request generator with a promotion pipeline. Progressive Sync lets you define stages and max update concurrency so only one cluster updates at a time, with health checks gating progression. ThisPairs well with a dedicated promotion controller that updates targetRevision after checks pass. For teams tracking what actually changed between promotions, integrating Drift Detection and Reconciliation: Keeping Clusters in Sync with Git gives visibility into whether clusters diverged outside Git.
Network and Secret Considerations
Hub-to-remote communication requires the hub to reach the remote API server. In private clusters this means either a VPN/peering or running ArgoCD agents like ApplicationSet in pull mode on each cluster. I have had success with the pull model using ArgoCD's agent pattern where each cluster runs its own instance that pulls from Git, avoiding inbound firewall rules entirely. For secrets, never store plain values in Git even for non-production. Combine ArgoCD with GitOps Secret Management: Sealed Secrets, SOPS and External Secret Operator so that decrypted values never live in the repo and can be scoped per cluster via External Secrets.
Hardening ArgoCD for Production Operations: RBAC, Resource Customizations and Failure Modes
A vanilla ArgoCD install is not production-ready. Three areas need hardening immediately: RBAC, resource customizations, and observability. For RBAC, lock down Projects. Each team should have its own Project that whitelists source repos and destination clusters/namespaces. Without this, any Application can deploy to any cluster, which defeats multi-tenancy. Use OIDC via Dex for SSO and map groups to Roles — I map platform-admins to admin, developers to a custom role that can sync but not delete Applications, and read-only for auditors.
Resource customizations are where most newcomers lose time. ArgoCD determines health via Lua scripts per Group/Kind. The built-in health checks for Deployments, StatefulSets, and DaemonSets are accurate, but checks for CRDs like CertManager, Istio, or Argo Rollouts default to Unknown. You must supply custom health checks in the argocd-cm ConfigMap. For example, an Istio VirtualService should be considered Healthy only if its observed generation matches, otherwise an invalid config appears Healthy while traffic is broken.
Dealing with Large Repositories and Rate Limits
At scale, Git becomes the bottleneck. Every Application does a Git clone or fetch on its reconciliation interval. With 500+ Applications pointing at the same monorepo, you will hit GitHub rate limits and slow syncs. Solutions that have worked for me: enable the commit-server cache, increase timeout.reconciliation to 5m, use Helm OCI or Kustomize remote bases sparingly, and most importantly, split your repo by blast radius. Keep platform and workload repos separate so a noisy workload repo does not delay platform syncs. Also set retryLimit and use argocd repo add --insecure-ignore-host-key only for testing; in production, pin known hosts.
Monitor ArgoCD itself. Key metrics to alert on: argocd_app_reconcile duration, argocd_app_sync_total failures, repo-server queue depth, and controller workqueue depth. If reconciliation duration climbs above 30 seconds, you likely need to shard or reduce generator cardinality.
Automating Health and Deployment Ordering with Sync Waves and Hooks
ArgoCD syncs resources in a defined order, and that order matters. By default it applies all manifests in parallel, which will break if your Application includes a CRD and a Custom Resource that depends on it. Sync waves solve this. Assign argocd.argoproj.io/sync-wave: "-5" to CRDs and Namespaces, "0" to Deployments, and "5" to post-sync jobs. Waves run sequentially within a sync, and health is checked before proceeding to the next wave.
Sync hooks are Jobs or Pods that run at a specific phase: PreSync, Sync, PostSync, or SyncFail. I use PreSync hooks for database migrations and PostSync hooks for smoke tests. A common mistake is leaving hooks as Hook without Hook.DeletePolicy; they remain as completed pods and clutter the namespace. Always set argocd.argoproj.io/hook-delete-policy: HookSucceeded or BeforeHookCreation.
apiVersion: batch/v1
kind: Job
metadata:
name: db-migrate
annotations:
argocd.argoproj.io/hook: PreSync
argocd.argoproj.io/hook-delete-policy: BeforeHookCreation,HookSucceeded
argocd.argoproj.io/sync-wave: "-1"
spec:
template:
spec:
restartPolicy: Never
containers:
- name: migrate
image: ghcr.io/org/migrator:v1.8.2
env:
- name: DATABASE_URL
valueFrom:
secretKeyRef:
name: db-credentials
key: url
command: ["./migrate", "up"]
activeDeadlineSeconds: 300
---
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: api-with-migration
namespace: argocd
spec:
source:
path: manifests/api
helm:
parameters:
- name: image.tag
value: v2.4.1
destination:
server: https://prod-k8s.example.com
namespace: api
syncPolicy:
syncOptions:
- PrunePropagationPolicy=foreground
For progressive delivery, pair ArgoCD health with Argo Rollouts or Flagger. ArgoCD can treat a Rollout as Healthy only when the Rollout reports it, which means your sync will remain Running during a canary and only mark Healthy when the canary succeeds. This turns ArgoCD from a simple sync tool into a deployment orchestrator. If you want deeper visibility into deployment frequency and rollback patterns, GitOps Observability: Tracking Deployments, Rollbacks and Change Velocity covers how to export ArgoCD metrics into your observability stack. As noted in the Docker Documentation, pinning image digests rather than tags is critical here to ensure the health check evaluates the exact artifact you tested.
Frequently Asked Questions
Should I use one ApplicationSet per environment or one ApplicationSet with Matrix for all environments?
Use one ApplicationSet per environment when environments have different approval policies or cluster sets. A single Matrix ApplicationSet for all environments is tempting but couples dev and prod lifecycles — a bad Git template change will generate broken Applications everywhere simultaneously. Separating them lets you canary changes to dev first, and it keeps the generated Application count per controller shard manageable.
How do I prevent ArgoCD from fighting the Horizontal Pod Autoscaler?
Add an ignoreDifferences entry for /spec/replicas on Deployments and StatefulSets managed by an HPA, as shown in the example above. Also set spec.replicas to omitted or a placeholder in Git. If you use KEDA ScaledObjects, ignore differences on spec.minReplicaCount as well. Without this, the Application will constantly appear OutOfSync and self-heal will revert scaler decisions.
What is the practical limit for a single ArgoCD instance managing remote clusters?
From operational experience, a single HA ArgoCD instance comfortably manages 10-20 clusters and 500-800 Applications with default resources (2 controller replicas, 3 repo-servers). Beyond that, increase controller.workers, shard by cluster or project, and separate repo-servers. For 50+ clusters, evaluate a distributed model where each cluster runs its own ArgoCD that pulls from Git, or use ApplicationSet cluster generators with progressive sync to limit concurrency.
How should I handle secrets across multiple clusters with ArgoCD?
Do not store encrypted secrets directly in the same repo as your ApplicationSets if you can avoid it. Use External Secrets Operator with a central vault (AWS Secrets Manager, HashiCorp Vault) and reference them via ExternalSecret resources templated per cluster. The ApplicationSet can inject the correct vault path per cluster via generator values. This keeps secrets out of Git entirely and allows per-cluster rotation without a Git commit for every cluster.