Video in progress

Staff 🌿 Git

In GitOps, do you keep application code and deploy configuration in one repo or separately?

Usually separately: the application repo builds the image, and the config repo (Helm/Kustomize manifests) says which image digest runs in each environment. That keeps the deploy history clean, permissions separated, and lets one code commit go out to several environments at different times.

📖 Answer

The problems of keeping them in one repo show up quickly in practice:

  • CI writes the image tag into the manifest → a new commit → CI again → circular triggers;
  • the application history gets mixed with deploy commits;
  • every application developer ends up needing write access to the prod configuration.

The flow with a separate config repo:

order-service repo:  PR → merge → CI → image ghcr.io/shop/order@sha256:ab12...
                                       └─► PR to the config repo: envs/staging/order.yaml
config repo:         staging automatic, prod is a PR with approval
Argo CD / Flux:      applies the config repo state to the cluster

What you gain:

  • what runs in prod is the config repo's main, and the deploy history is its git log;
  • rollback is git revert;
  • prod access is in a small group, while application repos are open widely.

The cost is that a change lives in two places: if you add a new env variable, the code and manifest PRs must go together. Linking the two PRs and their order (config first, then code, or the reverse) takes discipline.

I prefer separating environments by folders, not by branches (staging and prod branches): promoting between branches leads to merge conflicts and confusion about "what is on which branch". With folders, the difference is visible with a plain diff.

Secrets must not sit in the open in the config repo: use Sealed Secrets, SOPS or External Secrets.