GitOps

GitOps is an operating model where the desired state of systems is stored as declarative files in Git, and software agents continuously pull that state and reconcile the live environment to match it.

Also known as: Git-based operations

Related terms in this glossary

How it works

The OpenGitOps project, a CNCF working group, defines four principles for GitOps:

  • Declarative: the desired state of the system is expressed declaratively, for example as Kubernetes manifests.
  • Versioned and immutable: that state is stored in a way that keeps full history, which in practice means Git.
  • Pulled automatically: software agents pull the desired state from the source, rather than a CI job pushing it in.
  • Continuously reconciled: agents keep comparing actual state with desired state and correct any drift.

To change production, an engineer opens a pull request. Review and merge become the approval step. A controller running inside the cluster, such as Argo CD or Flux, notices the new commit and applies it. If someone edits the cluster by hand, the controller reports the drift or reverts it.

Why it matters

GitOps gives you an audit trail for free: every change has an author, a reviewer and a timestamp. Rollback is a Git revert. Production credentials stay inside the cluster rather than in CI systems, which reduces the blast radius if a pipeline is compromised. It also scales well to many clusters, because each one pulls its own configuration. The main trade-offs are repository design, secret handling and deciding how environments are promoted. Gepton's GitOps service covers these design choices.

GitOps in depth

Repository design choices

Most GitOps difficulties come from repository layout, not from the controller. The main decisions:

DecisionOptionsTrade-off
Where config livesSame repository as app code, or a separate config repositorySeparate repositories keep deployment history clean and permissions distinct; same-repo is simpler for small teams
EnvironmentsDirectories per environment, or branches per environmentDirectories with overlays are easier to compare and promote; long-lived environment branches tend to drift
PackagingPlain YAML, Kustomize, HelmKustomize for small variations, Helm for reusable packages and third-party software
Fleet structureOne repository for all clusters, or one per team or tenantCentral control versus team autonomy

Example: promotion from staging to production

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.

Questions about GitOps

Something else? Send us your question and an engineer replies with next steps.

Is GitOps only for Kubernetes?

The principles are general: declarative desired state, versioned in Git, pulled and reconciled by an agent. Kubernetes is where the tooling is most mature because its API is declarative and controllers are built in. GitOps ideas also apply to cloud infrastructure through tools such as Crossplane, or through Terraform and OpenTofu run by controllers or automation that applies merged changes, to edge devices, and to configuration of SaaS tools with declarative providers. Outside Kubernetes, check carefully whether drift is really detected and corrected continuously.

How do we handle database schema changes in a GitOps workflow?

Treat migrations as versioned, backward-compatible steps deployed like any other change. A common pattern runs a migration Job before the application update, using sync waves or hooks in Argo CD or dependencies in Flux. Design migrations in expand-and-contract steps: add new columns or tables first, deploy code that works with both shapes, then remove old structures in a later release. Because a Git revert cannot undo data changes, rollback for schema changes means a forward fix or a tested down-migration.

Articles that mention GitOps

All articles

Jump to

↑↓ to move↵ to open