Skip to content
Latchkey

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 ApplicationSet with a clusters generator.
  • 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: api

Gotchas

  • The empty clusters: {} generator targets every registered cluster; add selector to scope by label.
  • Use per-cluster overlays so each destination can differ without separate ApplicationSets.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →