TL;DR
A curated reference guide to GitOps for infrastructure: core principles, Flux and ArgoCD, Terraform patterns, and security practices for declarative delivery.
GitOps Infrastructure: Principles, Tools and Essential Resources
Executive Summary
GitOps is one idea with strict consequences: the desired state of your system lives in git, and an automated agent continuously pulls the live system toward it. Done properly, you get an audit trail for every change, rollbacks that are just reverts, and drift that fixes itself. Done halfway — pipelines that still push, secrets pasted into repos, no drift detection — you get the ceremony without the safety. This guide covers the four principles, the Flux versus ArgoCD decision, how Terraform fits, and the practices that keep a GitOps setup trustworthy.
Why This Matters
Every production incident eventually asks the same question: what changed? In a push-based world the answer is archaeology across CI logs, console clicks, and memory. In a GitOps world the answer is git log. That single property — the environment is a function of a repository — is why GitOps improves both reliability and security: reviewers approve changes before they exist, credentials stay inside the cluster instead of in CI, and a compromised pipeline cannot invent state that git does not describe.
Core Concepts
The Four Principles (OpenGitOps)
If any one is missing, you have CI/CD with extra steps. The pull model is the one teams most often skip — and it is the one that removes deploy credentials from your pipeline.
Flux vs ArgoCD
Both are CNCF-graduated and production-proven. The difference is philosophy:
Pick based on who operates it: infrastructure engineers tend to prefer Flux's composability; platform teams serving developers tend to prefer ArgoCD's UI and app model. Running both is a smell — standardise.
Terraform in a GitOps World
Terraform describes infrastructure outside Kubernetes (VPCs, databases, DNS). GitOps discipline still applies: state in a remote backend with locking, plans reviewed on pull requests, applies executed by a controller or a locked pipeline — never from a laptop. Controllers like Flux's terraform-controller (or Crossplane for a fully Kubernetes-native model) close the loop so cloud resources reconcile continuously instead of only when someone runs apply.
Secrets: The Part Everyone Gets Wrong
Git is not a secret store, and "the repo is private" is not a control. The working patterns:
Repository Structure
Two shapes dominate. A monorepo (one repo: apps + infra + clusters) gives atomic changes and one audit trail, at the cost of access control granularity. Repo-per-team/layer scales permissions and blast radius, at the cost of cross-repo coordination. Most organisations land on a hybrid: one platform repo for cluster and shared infrastructure, one repo per team for their applications.
Decision Framework
| Situation | Reach for |
|---|---|
| Kubernetes apps, platform team serving many devs | ArgoCD |
| Kubernetes infra + apps, controller-purist team | Flux |
| Cloud resources (networks, databases) | Terraform with reviewed plans, or Crossplane |
| Secrets in git | External Secrets Operator, Sealed Secrets, or SOPS |
| Rollback | git revert + let reconciliation do the rest — rehearse it |
Implementation Checklist
Trade-offs
Reconciliation loops add latency: a change lands when the agent polls or receives a webhook, not the instant CI finishes. Git becomes a critical system — an outage or a bad merge affects every environment that trusts it. And the model fits Kubernetes-shaped workloads best; pets, legacy estates, and one-off snowflake systems need adapters or exemptions, which must be explicit rather than silent.
When Not to Use GitOps
References
Here are essential resources for learning about GitOps:
These resources provide comprehensive information about implementing GitOps practices effectively.
Why This Matters
Understanding the business and technical context helps you make informed decisions rather than blindly following patterns.
Trade-offs to Consider
Every architectural decision involves trade-offs. Consider your specific requirements, team expertise, and scale when evaluating options.
When NOT to Use This
Knowing when a solution doesn't apply is as valuable as knowing when it does. Consider alternatives for your specific situation.
Decision Framework
Use this framework to evaluate whether this approach is right for your use case based on your specific constraints and requirements.