Q&A-9Design repository structure for a large GitOps estate.
Answer
The 90-second answer
Assume one platform team, roughly 40 tenant teams, three environments, a few hundred clusters, and Argo CD as the reconciler. Flux changes the mechanics below, not the boundaries.
Split into three repo classes, each with one owner:
platform/: CRDs, controllers, cluster add-ons. Platform owns it, platform reviews it.tenants/<team>/: that team's workloads, one directory per environment. The team owns it.envs/<cluster>/: thin. It names which tenant directories and which platform revision this cluster runs. Whoever owns the cluster owns it.
Reusable bases live in a tagged repo or platform/modules; overlays are per-environment patches.
Why overlays stay small. Kustomize applies strategic-merge patches in order, so every field an overlay restates silently shadows the base. A base change then never reaches that environment, and nobody notices until an incident. Keep overlays to replicas, resource limits, hostnames and image tags: the things that genuinely differ per environment.
Why pinning matters. A remote base written as github.com/org/base//k8s?ref=v1.4.2 is fetched at render time. Drop the ?ref and an upstream force-push changes what your cluster runs with no commit in your repo: the audit trail is gone. Same story for Helm: Chart.lock pins the chart digest, and without it helm dependency update can move you.
Reconciliation scale. Argo CD's default resync is 180 seconds (timeout.reconciliation in argocd-cm). At 200 clusters × 40 tenants that is 8,000 Applications, and hand-writing them does not survive. Generate them with an ApplicationSet cluster generator. The repo-server keeps a local clone per repository and fetches on each refresh, so a repo with heavy binary history makes every refresh slower for every Application that points at it.
Failure modes and how you catch them.
- Duplicate field ownership. Two Applications both set
spec.replicas. Symptom: the Application flaps OutOfSync on every resync and the live object alternates between values. Detect it withargocd app historyshowing alternating revisions, or alert on sync count per Application per hour. - Unpinned base. Symptom is a diff with no corresponding commit. Detect it in CI: render
kustomize buildand fail the build if the output hash differs from the committed manifest. - Prune on the wrong path.
syncPolicy.automated.prune: trueon a namespace-scoped Application deletes anything not in Git. Runargocd app diff --localin CI before merge, and putargocd.argoproj.io/sync-options: Prune=falseon shared CRDs.
What would change the decision. If tenants cannot be trusted with cluster-scoped resources, split by cluster rather than by team, and give each tenant an AppProject whose sourceRepos is restricted to their own directory. On Flux the boundaries hold, but tenancy is enforced differently: --no-cross-namespace-refs and --no-remote-bases on kustomize-controller, plus spec.serviceAccountName on each Kustomization so it reconciles as the tenant, not as the controller.
Curated: · Written: · Reviewed:
Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.