Skip to main content

Structuring a Git Repo for Argo CD Multi-Environment Deployments

How would you structure a Git repo for Argo CD when you have dev, staging, and prod environments?

junior
beginner
GitOps
Question

How would you structure a Git repo for Argo CD when you have dev, staging, and prod environments?

Answer

Two common patterns exist: environment-per-directory and environment-per-branch. Pick directories. Branches per environment create merge pain, cherry-picking, and drift. Use one branch (usually main) with separate directories for each environment. A layout that works for most teams: apps/ myapp/ base/ # shared manifests (Deployment, Service, ConfigMap) kustomization.yaml overlays/ dev/ # dev patches: replicas, image tag, hostname staging/ prod/ Each environment gets its own Argo CD Application pointing at its overlay path. Base holds what is the same everywhere. Overlays patch only what differs (replicas, resource requests, image tags, ingress hosts, ConfigMap values). If you grow past 20 to 30 environments or clusters, switch from hand-written Application CRs to an ApplicationSet with a Git directory generator so you do not write the same boilerplate over and over.

Why This Matters

This is one of the first questions in any Argo CD interview. It separates candidates who have read a tutorial from those who have run this in production. Listen for: a clear preference for directories over branches with a real reason (merge complexity, drift, audit clarity), separation of base from environment-specific patches, and awareness that the layout has to scale past the first three environments. If they immediately reach for branches-per-env, dig in and see if they have actually tried it.

Code Examples

Repo layout for a single app across three environments

bash

Argo CD Application pointing at the prod overlay

yaml
Common Mistakes
  • Using a branch per environment and then drowning in cherry-picks and merge conflicts
  • Putting environment-specific values in a single Helm values file with conditional blocks for prod, then forgetting which branch sets what
  • Pointing all three environments at the same Argo CD Application path so a dev change ships to prod
Follow-up Questions
Interviewers often ask these as follow-up questions
  • Why not use a branch per environment? People still recommend that on blog posts.
  • How do you handle a config value that has to differ in every single environment?
  • What changes when dev and prod live in different clusters?
  • When would you switch from one Application per environment to an ApplicationSet?
Tags
gitops
argocd
deployments
repository-structure
kubernetes
Sponsored
Carbon Ads

More GitOps interview questions

Also worth your time on this topic