What is GitOps? Principles, benefits, and pitfalls
Learn what GitOps is, the four OpenGitOps principles, the difference between the push and pull models, the benefits, the real costs, and how to take your first steps.
Kubernetes$ git revert HEAD && git push▍“Who changed this in production?” If that question usually goes unanswered on your team, GitOps was made for you. GitOps is a way of operating systems in which the desired state of your infrastructure and applications lives in a Git repository, and automated agents continuously make sure the real environment matches it. The term was popularized by Weaveworks around 2017 and today is almost synonymous with continuous delivery on Kubernetes.
This is an introductory article. For the hands-on side, see the Argo CD guide and the article on separating CI from CD.
The four OpenGitOps principles
To keep “GitOps” from becoming just a marketing label, the OpenGitOps project, created within the CNCF GitOps Working Group, published four principles:
| Principle | What it means in practice |
|---|---|
| Declarative | The system is described by its desired state (manifests, charts), not by a sequence of commands |
| Versioned and immutable | Desired state is stored immutably with complete history — usually in Git |
| Pulled automatically | Software agents pull the desired state declarations from the source |
| Continuously reconciled | Agents observe the actual state at all times and work to apply the desired state |
Notice that the principles mention neither Git nor Kubernetes. Git is the most common implementation, and Kubernetes, with its declarative API and controllers, is the natural fit — but the idea is broader.
Push vs. pull
The most concrete difference between a traditional pipeline and GitOps is who applies the changes:
| Aspect | Push (CI deploys) | Pull (GitOps) |
|---|---|---|
| Who applies | The CI pipeline, from outside the cluster | An agent running inside the cluster |
| Credentials | CI stores write credentials for the cluster | The agent only needs to read Git |
| When it applies | Only when the pipeline runs | Continuously, on an interval or event |
| Manual change (drift) | Goes unnoticed until the next deploy | Detected and, if configured, reverted |
| Rollback | Re-run an old pipeline | git revert |
Benefits
- Auditability: every change is a commit, with an author, a Pull Request review, and a reason.
- Simple rollback: reverting the commit makes the agent reconcile back to the previous state.
- Drift detection: hand-made changes in the cluster become visible and can be undone automatically.
- No cluster credentials in CI: a pipeline leak doesn’t grant write access to production.
- Consistent environments: staging and production derive from the same base manifests, and the differences are explicit in the repository.
- Disaster recovery: rebuilding a cluster becomes installing the agent and pointing it at the repository.
Costs and pitfalls
- Secrets: they can’t go into Git in plaintext. You’ll need SOPS, Sealed Secrets, or the External Secrets Operator — one more piece to operate.
- Promotion between environments: how do you move the version validated in staging to production? GitOps doesn’t answer that by itself; you need to define a flow (per-environment directories and PRs, or promotion tools).
- Bot commit noise: automations that bump image tags generate lots of commits and PRs.
- Developer feedback: the pipeline turns green before the deploy actually happens. Without notifications from the agent, developers are left in the dark.
- Not everything is declarative: database migrations and imperative operations (restoring a backup, draining a node, rotating a key) don’t fit well and require hooks, jobs, or separate processes.
- One more critical system: the GitOps agent has to be installed, upgraded, monitored, and secured.
Tools
For applications on Kubernetes
- Argo CD: rich web UI, centralized model able to manage many clusters.
- Flux: a set of Kubernetes-native controllers, no built-in UI, with image automation and native Helm releases.
Both are CNCF graduated projects.
Beyond application deploys
- Crossplane: extends Kubernetes with CRDs that represent cloud resources (databases, buckets, networks). Because infrastructure becomes Kubernetes objects, Argo CD or Flux can sync it the same way they sync applications, and Crossplane’s controllers continuously reconcile the state in the cloud.
- Terraform with Atlantis: Atlantis runs
terraform planandterraform applyfrom Pull Requests and comments. That brings the “change via PR, review, and audit” workflow, but it is not continuous reconciliation: apply only happens when someone triggers it, and drift isn’t corrected on its own. It’s a “GitOps-style” workflow, not GitOps in the strict sense of the four principles.
A minimal example
A lean manifests repository can look like this (the full structure, with per-environment overlays, is in this article):
k8s-manifests/
├── apps/
│ └── api/
│ ├── deployment.yaml
│ ├── service.yaml
│ └── kustomization.yaml
└── clusters/
└── prod/
└── api.yaml # Application (Argo CD) or Kustomization (Flux) pointing to apps/api
And deploying a new version becomes a Pull Request:
git checkout -b api-1.4.0
# in apps/api/deployment.yaml: ghcr.io/your-org/api:1.3.2 -> ghcr.io/your-org/api:1.4.0
git commit -am "api: bump to 1.4.0"
git push origin api-1.4.0
gh pr create --fill
# after review and merge, the agent detects the new commit and reconciles the cluster
If version 1.4.0 misbehaves, the way back is the same: revert the commit (or the merge) and let the agent apply the previous state. Nobody needs kubectl with write access to production.
How to start in 5 steps
- Pick a pilot: a low-criticality service and a staging cluster.
- Move the manifests into Git and agree with the team that nobody applies changes to that service by hand anymore.
- Install an agent (Argo CD or Flux) pointing at that directory, with manual sync at first to build confidence.
- Solve secrets and notifications before expanding: they are the two things that most often stall adoption.
- Turn on automated sync with self-heal and prune, remove cluster credentials from CI, and repeat for the next services.
Summary
- GitOps = desired state in Git + agents that pull and continuously reconcile
- The four principles: declarative, versioned and immutable, pulled automatically, continuously reconciled
- In the pull model, CI doesn’t need write credentials for the cluster
- Rollback is
git revert, and drift is detected automatically - Secrets, promotion between environments, and developer feedback need planning
- Argo CD and Flux for applications; Crossplane brings the model to infrastructure
- Start small, with one pilot service in staging
If it’s not in Git, it doesn’t exist — and if it is in Git, the cluster will end up reflecting it.