How to Manage Multiple Clusters With Argo CD
An ApplicationSet with a cluster generator templates one Application per registered cluster, so a single definition deploys everywhere.
Register each cluster with argocd cluster add, then create an ApplicationSet whose clusters generator iterates registered clusters and stamps out an Application for each from a template.
Steps
- Register clusters with
argocd cluster add <context>. - Create an
ApplicationSetwith aclustersgenerator. - Template the Application using generator variables.
- Each registered cluster gets its own synced Application.
ApplicationSet
apps/api/appset.yaml
apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
name: api
namespace: argocd
spec:
generators:
- clusters: {}
template:
metadata:
name: 'api-{{name}}'
spec:
project: default
source:
repoURL: https://github.com/my-org/deploy-config
path: apps/api
targetRevision: main
destination:
server: '{{server}}'
namespace: apiGotchas
- The empty
clusters: {}generator targets every registered cluster; addselectorto scope by label. - Use per-cluster overlays so each destination can differ without separate ApplicationSets.