Lesson 05 of 9 · Argo CD in practice
Multi-cluster management: four clusters, teams and access
Run four clusters from one Argo CD the way real platform teams do: clusters registered as code with least-privilege access, labels that drive ApplicationSets, projects as guard-rails per team and environment, sync windows for production, and a precise, tested answer to 'who may do what, where'.
The setup we'll build
A small but realistic platform:
mgmt (Argo CD: the hub)
┌────────────┼──────────────┐
▼ ▼ ▼
dev staging prod
env=dev env=staging env=prod
tier=nonprod tier=nonprod tier=prod
| Who | Wants |
|---|---|
| Platform team | Add-ons and team namespaces everywhere; full control in emergencies |
| Shop team | Deploy storefront freely to dev and staging; see (not touch) prod |
| Payments team | The same for api, and no access to shop's apps |
| Release managers | Push approved versions to prod, during working hours only |
| Everyone else | Read-only visibility |
Everything below is in the free lab argocd-gitops-lab, step 09: a kind-up.sh that builds all four clusters on one machine, and every manifest shown here.
A school with one head office and three buildings. The head office keeps a key for every building, but the key for the main building only opens the classrooms, not the boiler room. Each teacher may rearrange their own classroom in the practice building, only look into it in the main building, and the caretaker may change things in the main building only during the agreed hours.
Hub or Argo CD per cluster?
| Hub (one Argo CD, many clusters) | Per cluster | |
|---|---|---|
| Visibility | One UI and one set of permissions for everything | One UI per cluster |
| Credentials | The hub holds access to every cluster: protect it | Stay local |
| Failure | Hub down = no new syncs anywhere (running apps keep running) | Independent |
| Network | Hub must reach every cluster's API | Works disconnected; each pulls from Git |
For four clusters in one network, a hub is simplest. Edge or air-gapped sites usually run their own Argo CD bootstrapped from the same repos (see Edge Kubernetes & Zero-Touch Provisioning).
Register clusters as code, with least privilege
argocd cluster add <context> is fine for a quick start, but it creates a cluster-admin ServiceAccount on the target, and the registration lives only in Argo CD. For a real platform, describe each cluster as a Secret in the argocd namespace:
apiVersion: v1
kind: Secret
metadata:
name: cluster-prod
namespace: argocd
labels:
argocd.argoproj.io/secret-type: cluster # tells Argo CD this is a cluster
env: prod # labels used by ApplicationSets
tier: prod
region: eu
stringData:
name: prod
server: https://prod-api.example.com:6443
namespaces: shop-storefront,payments-api # Argo CD may only manage these namespaces
clusterResources: "false" # and no cluster-scoped resources
config: |
{"bearerToken": "<token>", "tlsClientConfig": {"caData": "<base64 CA>"}}
On the target, the identity behind that token is deliberately different per tier:
| Cluster | Argo CD's ServiceAccount on it | Why |
|---|---|---|
| dev, staging | cluster-admin |
Platform add-ons and fast iteration; low risk |
| prod | admin only inside shop-storefront and payments-api (RoleBindings) |
The hub holds every credential; on prod a mistake or compromise is contained to team namespaces |
With a namespaced prod credential, the platform bootstrap (Terraform, cluster provisioning) creates the namespaces and ResourceQuotas on prod; Argo CD can't, by design.
Keep cluster Secrets out of plain Git: deliver them with External Secrets, Sealed Secrets or SOPS. On EKS, replace the long-lived token with IAM: "awsAuthConfig": {"clusterName": "prod", "roleARN": "arn:aws:iam::111122223333:role/argocd-deployer"} in config, with Argo CD's own pods given that role (Pod Identity or IRSA).
Labels: each cluster's identity card
ApplicationSets select clusters by labels, so labels are the interface between "a cluster exists" and "it gets the right software":
| Label | Values | Used for |
|---|---|---|
env |
dev, staging, prod | Which overlay (values) to deploy |
tier |
nonprod, prod | Which sync behaviour and project apply |
region |
eu, us… | Region-specific add-ons, data residency |
Adding a fifth cluster becomes: create its Secret with the right labels. Every matching ApplicationSet deploys to it automatically, which is powerful, so label changes deserve the same review as code.
Projects: the guard-rails
An AppProject decides what an Application in it may do, regardless of who clicks Sync: which repos it may come from, which cluster/namespace it may go to, and which kinds of resources it may contain. One project per team × tier:
| Project | Source repos | Destinations | Extra rules |
|---|---|---|---|
platform |
platform/* |
any cluster, any namespace | cluster-scoped resources allowed |
shop-nonprod |
shop/* |
dev, staging · shop-* |
no cluster resources; no quotas, limits or network policies |
shop-prod |
shop/* |
prod · shop-* |
the same, plus a sync window |
payments-nonprod/prod |
payments/* |
the same shape · payments-* |
the same |
apiVersion: argoproj.io/v1alpha1
kind: AppProject
metadata:
name: shop-prod
namespace: argocd
spec:
sourceRepos: [ "https://git.example.com/shop/*" ]
destinations:
- { name: prod, namespace: "shop-*" }
clusterResourceWhitelist: [] # nothing cluster-scoped
namespaceResourceBlacklist: # platform-owned kinds
- { group: "", kind: ResourceQuota }
- { group: "", kind: LimitRange }
- { group: networking.k8s.io, kind: NetworkPolicy }
syncWindows:
- kind: allow # changes go out Mon-Thu 09:00-17:00 UTC only
schedule: "0 9 * * 1-4"
duration: 8h
timeZone: UTC
applications: [ "*" ]
manualSync: false
What this blocks, whoever is logged in: an app from a payments/* repo, a destination of payments-api or default, a ClusterRole, a ResourceQuota, and any sync to prod on a Friday. When an allow window exists, syncs happen only while it's open; for emergencies, a platform admin adds a temporary window through a reviewed pull request.
ApplicationSets: one definition per team and tier
A matrix generator combines the clusters (by label) with the app folders in the team's deploy repo, so every new app or cluster gets Applications without anyone writing YAML for it:
apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
name: shop-nonprod
namespace: argocd
spec:
goTemplate: true
goTemplateOptions: [ "missingkey=error" ] # a missing label fails loudly
generators:
- matrix:
generators:
- clusters:
selector: { matchLabels: { tier: nonprod } }
- git:
repoURL: https://git.example.com/shop/shop-deploy.git
revision: main
directories: [ { path: apps/* } ]
template:
metadata:
name: 'shop-{{.path.basename}}-{{.name}}' # shop-storefront-dev, shop-storefront-staging
spec:
project: shop-nonprod
source:
repoURL: https://git.example.com/shop/shop-deploy.git
targetRevision: main
path: '{{.path.path}}/overlays/{{index .metadata.labels "env"}}'
destination:
name: '{{.name}}'
namespace: 'shop-{{.path.basename}}'
syncPolicy:
automated: { prune: true, selfHeal: true }
The prod ApplicationSet is the same shape with three differences: it selects env: prod, uses the shop-prod project, and has no automated sync, so a release manager presses Sync inside the window. It also sets spec.syncPolicy.preserveResourcesOnDeletion: true, so deleting or breaking the ApplicationSet never removes running production workloads.
| ApplicationSet | Generates | Sync |
|---|---|---|
platform-tenants |
tenants-dev, tenants-staging (namespaces, quotas) |
Automatic, no prune |
shop-nonprod |
shop-storefront-dev, shop-storefront-staging |
Automatic, prune, self-heal |
shop-prod |
shop-storefront-prod |
Manual, inside the window |
payments-nonprod / payments-prod |
payments-api-… |
The same pattern |
Who may do what, where
Projects decide what an app may contain and where it may go. RBAC decides what a person may do with apps. Argo CD's policy model is short:
p, <role>, <resource>, <action>, <project>/<app>, allow|deny a permission
g, <user or SSO group>, <role> a membership
| Resource | Common actions |
|---|---|
applications |
get, create, update, delete, sync, override, action/<group>/<kind>/<action> |
logs |
get |
exec |
create (the web terminal; also needs exec.enabled: "true" in argocd-cm) |
clusters, projects, repositories |
get, create, update, delete |
The permission matrix
| Role (SSO group) | dev / staging | prod |
|---|---|---|
platform-admin (platform-admins) |
everything | everything |
release-manager (release-managers) |
view, logs | view, logs, sync (inside the window) |
shop-developer (shop-developers) |
view, logs, sync, restart, terminal: shop apps only | view, logs: shop only |
payments-developer (payments-developers) |
the same for payments | view, logs: payments only |
| everyone else | read-only | read-only |
The policy
apiVersion: v1
kind: ConfigMap
metadata:
name: argocd-rbac-cm
namespace: argocd
data:
policy.default: role:readonly # anyone who logs in can look
scopes: "[groups]" # match on the SSO token's groups claim
policy.csv: |
g, platform-admins, role:admin
p, role:release-manager, applications, get, */*, allow
p, role:release-manager, applications, sync, shop-prod/*, allow
p, role:release-manager, applications, sync, payments-prod/*, allow
p, role:release-manager, logs, get, */*, allow
g, release-managers, role:release-manager
p, role:shop-developer, applications, get, shop-nonprod/*, allow
p, role:shop-developer, applications, get, shop-prod/*, allow
p, role:shop-developer, applications, sync, shop-nonprod/*, allow
p, role:shop-developer, applications, action/apps/Deployment/restart, shop-nonprod/*, allow
p, role:shop-developer, logs, get, shop-nonprod/*, allow
p, role:shop-developer, logs, get, shop-prod/*, allow
p, role:shop-developer, exec, create, shop-nonprod/*, allow
g, shop-developers, role:shop-developer
# payments-developer: the same lines with payments-nonprod / payments-prod
Notes that matter in practice:
- Groups, not people. Map SSO groups (
g, shop-developers, …); joining or leaving a team is then an identity-provider change, not an Argo CD change. - Default deny. Anything not granted is refused;
policy.default: role:readonlyonly adds viewing. Set it to''if even viewing should be restricted. - No
deletefor developers, even in dev: removing an app is done by removing its folder in Git. - CI gets a project role, not a person's token. The
shop-nonprodproject defines acirole allowed togetandsynconly its own apps;argocd proj role create-token shop-nonprod ciissues a token scoped to exactly that.
Test the policy before you apply it
Every row of the matrix can be checked offline with the argocd CLI:
$ argocd admin settings rbac can sam sync applications 'shop-nonprod/shop-storefront-dev' --policy-file argocd-rbac-cm.yaml
Yes
$ argocd admin settings rbac can sam sync applications 'shop-prod/shop-storefront-prod' --policy-file argocd-rbac-cm.yaml
No
$ argocd admin settings rbac can rita sync applications 'shop-prod/shop-storefront-prod' --policy-file argocd-rbac-cm.yaml
Yes
The lab's rbac/test-rbac.sh runs 19 such checks (allowed and refused cases) and fails if any answer differs from the matrix. Run it in the pull request that changes the policy. (The command builds a Kubernetes client even with --policy-file, so it needs some kubeconfig present; the script creates a dummy one if none exists.)
Two layers of access, kept separate
| Layer | Controls | Who uses it |
|---|---|---|
| Argo CD RBAC + projects | What people do through Argo CD | Developers, release managers, CI |
| Kubernetes RBAC on each cluster | What kubectl users can do directly |
Platform team; break-glass only on prod |
With GitOps, developers shouldn't need kubectl write access to prod at all: they read logs and status in Argo CD, and change things through Git.
Rolling out safely across environments
- Promotion through Git: the same image digest moves dev → staging → prod by pull requests to the overlays (see GitOps Principles & Practice, lesson 03).
- Sync windows on prod projects, plus
denywindows for change freezes. - Progressive syncs: ApplicationSets support a
RollingSyncstrategy that syncs generated apps in steps by label (for exampleenv: dev, thenstaging, thenprod). It's behind a feature flag in the ApplicationSet controller; check its status for your Argo CD version before relying on it. - A canary cluster: label one prod cluster
canary: "true"and let it receive changes first.
Operating the fleet
| Task | How |
|---|---|
| Add a cluster | Create its access on the cluster + a labelled cluster Secret; matching ApplicationSets create its apps |
| Remove a cluster | Remove the labels or the Secret; generated apps are deleted, so check preserveResourcesOnDeletion first |
| Rotate a cluster credential | New token on the target, update the Secret, revoke the old token |
| Give someone access | Add them to the SSO group |
| Freeze production | Add a deny window to the *-prod projects by pull request |
| Many clusters, slow controller | Run more application-controller replicas with sharding (clusters spread across replicas) |
| Hub outage | Running apps are unaffected; syncs resume when the hub returns. Back up Argo CD's config (it's all in Git and Secrets) |
Try it: the four-cluster platform
Follow the lab's 09-multi-cluster step, Part B (about 8 GB of RAM for four kind clusters):
./kind-up.sh: four clusters, Argo CD on mgmt, three clusters registered with labels and least-privilege access on prod.- Push the three sample deploy repos; apply the projects and ApplicationSets. Expect 8 apps; prod ones waiting for a manual sync.
- Apply the RBAC policy and lab users; run
rbac/test-rbac.sh(expect 19 passed). - Log in as
sam(shop developer): sync a dev app, then try prod and a payments app. Log in asrita(release manager) and sync prod inside, then outside, the window. - Add a
ResourceQuotato the shop repo and point an app atpayments-api: read both project errors.
Three ways to tell Argo CD about an app
The same task, add a new app shop, done three ways:
| A. Application by hand | B. ApplicationSet over folders | C. ApplicationSet over repos | |
|---|---|---|---|
| One-time setup | Nothing | Apply one ApplicationSet watching apps/* in one repo |
Apply one ApplicationSet watching a Git organisation |
| Where shop's manifests go | Its own repo or path | A new folder apps/shop/ |
A new repo with a k8s/ folder |
| Write an Application? | Yes, every time | No | No |
| Touch Argo CD? | Yes (kubectl apply) |
No | No |
| Remove shop | Delete the Application | Delete the folder, push | Delete the repo |
| New app shows up | Immediately | On the next poll (instant with a webhook) | On the next SCM scan (30 min by default) |
| Typical use | Learning, one or two apps | Most teams: onboarding by a reviewed PR | Many teams, a repo per app |
A differs from B/C in who creates the Application: you, or a generator. B and C differ only in where the list of apps lives: folders in one repo, or repos in one organisation. For the SCM-provider generator, the scan interval is set with requeueAfterSeconds (each scan costs API calls per repo, so mind rate limits), or force a rescan once with the argocd.argoproj.io/application-set-refresh=true annotation.
Practise it in the lab
- 09-multi-cluster: Part A puts one app on every cluster; Part B is the full four-cluster platform from this lesson.
- 07-appset-folders and 08-appset-repos: the folder and repo generators on their own.
- 10-rbac-projects: a single-team project and RBAC, if you want the basics first.
Recap
- Register clusters as code (labelled Secrets); least privilege on prod: namespaces only, no cluster resources; IAM instead of tokens on EKS.
- Labels (
env,tier,region) drive which ApplicationSets deploy where. - Projects per team × tier limit sources, destinations and resource kinds; sync windows gate prod.
- ApplicationSets (matrix of clusters × app folders): automatic in non-prod, manual in prod,
preserveResourcesOnDeletionfor safety. - RBAC: roles mapped to SSO groups, a written permission matrix, and
argocd admin settings rbac cantests in CI. - Keep Argo CD access and Kubernetes access separate; developers change prod through Git, not
kubectl.
This site is a public version of my personal engineering knowledge hub. It intentionally excludes confidential company information and internal operational details.