GitOps in depth
Repository design choices
Most GitOps difficulties come from repository layout, not from the controller. The main decisions:
| Decision | Options | Trade-off |
| Where config lives | Same repository as app code, or a separate config repository | Separate repositories keep deployment history clean and permissions distinct; same-repo is simpler for small teams |
| Environments | Directories per environment, or branches per environment | Directories with overlays are easier to compare and promote; long-lived environment branches tend to drift |
| Packaging | Plain YAML, Kustomize, Helm | Kustomize for small variations, Helm for reusable packages and third-party software |
| Fleet structure | One repository for all clusters, or one per team or tenant | Central control versus team autonomy |
Example: a hypothetical team's CI builds and signs an image, then opens a pull request that changes the image tag in the staging overlay. After merge, the GitOps controller deploys it to staging and automated checks run. A promotion step then opens a second pull request that copies the same tag to the production overlay. Production changes require approval from a code owner, and branch protection prevents direct pushes. If production metrics degrade, the on-call engineer reverts the merge commit, and the controller restores the previous version. The audit trail of who changed production, when and with whose approval is the Git history itself.
Handling secrets and drift
- Secrets: never commit plain secrets. Use encrypted files (SOPS, Sealed Secrets) or references resolved at runtime by the External Secrets Operator from a cloud secret manager or Vault.
- Drift: decide per environment whether the controller only reports manual changes or reverts them. Production usually self-heals; a sandbox might only report.
- Break-glass: define how to make an emergency change during an incident, and require that it is committed to Git afterward.
Measuring a GitOps setup
- Time from merge to healthy deployment, per environment.
- Number and duration of out-of-sync or degraded applications.
- Manual changes detected as drift, which shows whether people still bypass Git.
- Rollback time, measured from decision to restored service.
These feed directly into DORA metrics.
Document the repository conventions in the repository itself: where each team's configuration lives, how promotion works, who approves production changes and how to make an emergency fix. New engineers learn the workflow faster, and reviewers can point to the agreed rules instead of debating them in every pull request.
Common mistakes
- CI pipelines that still run kubectl apply against production alongside the GitOps controller.
- Huge pull requests that change many services and environments at once.
- Templating so deep that reviewers cannot see the rendered result; show rendered diffs in pull requests.
- Applying GitOps to Kubernetes but leaving cloud resources as manual changes; extend it with infrastructure as code and controllers such as Crossplane where appropriate.
GitOps is implemented with Argo CD or Flux, extends CI/CD, and is often the deployment layer of an internal developer platform. We design and run it in our GitOps service.