Topic guide

What is GitOps? The reconciliation loop, explained

GitOps keeps the desired state of a system in Git and leaves the deploy to an agent. The agent pulls that state, compares it with what is running, applies the difference and reports drift back. Everything on this page follows from that loop.

Desired state in Git Actual state running system 1 2 3 4
  1. Pull The agent fetches the latest commit, on a timer or a webhook.
  2. Compare It diffs that desired state against the running system.
  1. Apply It changes what differs, or only flags it when it is not allowed to act.
  2. Report Sync status, health and drift go back to the people who own them.
Illustration: the loop an agent runs continuously, not once per deploy.

The rules behind the loop

What are the four principles of GitOps?

OpenGitOps, overseen by a CNCF working group, defines GitOps as four principles (v1.0.0). All four must hold. A pipeline that applies manifests from Git meets two at most.

  1. 01

    Declarative

    “A system managed by GitOps must have its desired state expressed declaratively.”

    In practiceManifests say what should exist, not how to create it. A deploy script in Git is not a declaration.

  2. 02

    Versioned and immutable

    “Desired state is stored in a way that enforces immutability, versioning and retains a complete version history.”

    In practiceProtected branches, no force pushes, and references pinned to a tag or commit, never to a branch that moves.

  3. 03

    Pulled automatically

    “Software agents automatically pull the desired state declarations from the source.”

    In practiceNobody applies changes from a laptop, and CI holds no production credentials.

  4. 04

    Continuously reconciled

    “Software agents continuously observe actual system state and attempt to apply the desired state.”

    In practiceThe agent keeps comparing after the deploy. Continuous means it keeps happening, not that it is instant.

Step 1 of the loop: pull

What is the difference between GitOps and CI/CD?

Your CI pipeline stays: it still builds, tests and publishes artifacts. GitOps changes who deploys. A push pipeline ends with a deploy job; a GitOps pipeline ends with a commit, and the agent deploys. In the OpenGitOps glossary, traditional CI/CD is “driven by pre-set triggers”, while reconciliation is “triggered whenever there is a divergence”.

Push-based CI/CD compared with pull-based GitOps
Aspect Push-based CI/CD Pull-based GitOps
Who deploysA pipeline jobAn agent inside or next to the target
What starts itA merge, a schedule or a buttonAny difference between Git and the running system
CredentialsCI can write to every targetCI writes only to Git; the agent holds target access
After the deployThe job ends; later changes go unseenThe agent keeps comparing, and reports or reverts drift
RollbackRe-run an older pipelineRevert the commit; the agent applies it
Audit trailPipeline logsGit history: author, review and diff
Fits bestAnything with an API or SSH, and ordered workDeclarative targets an agent can observe, mostly Kubernetes

Where CI hands over

  1. CIBuilds, tests and publishes the image
  2. GitGets a commit with the new tag, or a pull request
  3. AgentPulls, compares and applies
Illustration: the last step of the pipeline becomes a commit.

Argo CD’s docs describe this handoff, and Flux can make the commit itself when a new image appears.

Where the loop runs

Is GitOps only for Kubernetes?

The principles are not: the glossary accepts any state store that meets its criteria, not only Git. The common agents are. Argo CD and Flux are built for Kubernetes, which already works through control loops. Elsewhere, you borrow the principles and accept a weaker loop.

Fits well

Kubernetes, with more than one cluster or environment
Run an agent such as Argo CD or Flux. Start with one service.
Production gets edited by hand
The agent lists every difference before you let it revert anything.

Borrow the principles

Cloud resources in Terraform or OpenTofu
Apply from a pipeline and schedule a plan with -detailed-exitcode (Terraform, OpenTofu). Exit code 2 means changes: drift, or code nobody applied.
Servers managed with Ansible
ansible-pull “inverts the default push architecture of ansible into a pull architecture”.

Use a pipeline

Ordered or one-off work: fleet upgrades, data fixes, app store releases
A reconciler holds a state; a pipeline runs a sequence. Agents can still order steps, with Argo CD sync hooks or Flux dependencies.
One service, one environment, a small team
Another controller to run and secure may cost more than the drift it prevents.

From a real engagementAt Nike, es.nl consolidated multi-team Windows server upgrades for 900+ stores into one self-service pipeline. Per-server runtime fell from 6-8 hours to about 3, with 8 servers safely in parallel instead of 2. A long procedure run in small batches suits pipeline stages. Read the Nike case

Steps 2 and 3: compare and apply

Argo CD or Flux: which GitOps tool fits?

Both are CNCF graduated, Argo since December 2022 and Flux since November 2022, and both run the loop above. Their defaults differ.

Argo CD

What it is
“A declarative, GitOps continuous delivery tool for Kubernetes”, with a web UI.
When it syncs
On request, unless automated sync is on. It checks Git every 3 minutes at most by default, or on a webhook.
Drift
Shown as OutOfSync. Live edits alone trigger a sync only with self-heal on.
Deleted manifests
Left running by automated sync, “as a safety mechanism”, until you enable pruning.
Seeing state
A web UI with drift visualization, plus audit trails.

Flux

What it is
Controllers for “keeping Kubernetes clusters in sync”. UIs are separate projects.
When it syncs
Each Kustomization reconciles on its own interval: fetch, build, apply.
Drift
Corrected every interval for Kustomizations. Opt-in for Helm releases, in warn or correcting mode.
Deleted manifests
Pruning is a required yes or no on every Kustomization.
Seeing state
Notifications to Slack and similar tools when configuration is synced and ready.

The es.nl article GitOps in 2026: Reconciliation, Drift, and the Argo CD vs Flux Decision offers a rule of thumb: Argo CD when people need to see state, Flux when the audience is other automation.

Other GitOps tools

Argo CD and Flux are not the only ways to run the loop. Four others you will meet:

  • Fleet (Rancher) Kubernetes custom resources and controllers that run GitOps for one cluster or a large fleet of them, from raw YAML, Helm charts or Kustomize.
  • Red Hat OpenShift GitOps An Operator based on Argo CD, for OpenShift and Kubernetes clusters.
  • GitLab Its agent for Kubernetes works with Flux, and GitLab’s documentation recommends using both for GitOps deployments.
  • Kargo A promotion layer that complements Argo CD, for moving a change through your environments in order.

Three of the four sit on Argo CD or Flux, so the choice between those two usually comes first.

The desired state

How do you structure a GitOps repository?

Structure decides who can change what, and how a change reaches production. Four decisions come first.

fleet-config

fleet-config/
├── apps/
│   ├── base/          # shared
│   ├── staging/       # overrides
│   └── production/    # overrides
├── infrastructure/  # ingress, policy
└── clusters/
    ├── staging/       # entry point
    └── production/    # entry point
Illustration: one config repository, environments as directories on main.
  1. Keep config apart from source code

    Argo CD’s best practices highly recommend a separate manifest repository: a cleaner audit history, separate access to production, and no CI commit that starts “an infinite loop of build jobs”.

  2. Use directories for environments, not branches

    In Flux’s monorepo example, all environments sit “in the same branch (e.g. main)”. Promotion is a pull request against the production directory, and environments differ by a diff anyone can read.

  3. Split repositories along access lines

    A monorepo is simplest. A separate production repository lets you “grant access to a subset of team members”.

  4. Pin what you reference

    A base or chart that tracks a branch can change meaning overnight. Pin a Git tag or commit SHA instead.

Steps 3 and 4: apply and report

How do rollback and drift work in GitOps?

Rollback is a revert

Revert the change in Git and the agent applies the previous state. The revert is reviewed and recorded like any other change.

terminal

git switch -c rollback-4c2e9f1
git revert --no-edit 4c2e9f1
git push -u origin rollback-4c2e9f1
# merge the pull request, and the
# agent applies the previous state

Two limits. Argo CD’s own rollback “cannot be performed against an application with automated sync enabled”, since the loop would sync back to Git. And a revert restores configuration, not data: desired state “generally does not include persistent application data”. For rollback driven by metrics, see Progressive Delivery in 2026: Canary vs Blue-Green vs Feature Flags.

Drift: report it or revert it

Drift is any difference between Git and the running system. Decide per app whether the agent reports it or reverts it: Argo CD reports by default, while Flux Kustomizations correct it every interval.

That changes incidents. Fix by hand with the agent running and the loop may revert your hotfix. Pause the agent for that app first (Flux has suspend; Argo CD can run without automated sync), then commit the fix and resume.

How it goes wrong in the first months

SymptomLikely causeFix
A hotfix vanishes after an incidentThe agent reverted a hand editPause the agent, fix, commit the same change, resume
An app never shows as in syncAn autoscaler or other controller changes a field Git also setsLeave that field out of Git, as Argo CD’s guide suggests for replicas
A deleted manifest leaves its resource runningPruning is offTurn pruning on, app by app
Drift alerts pile up unreadNobody owns themRoute each one to the owning team as a defect

Secrets in the desired state

How do you manage secrets in GitOps?

Desired state “often does include credentials”, the OpenGitOps glossary notes, and plaintext cannot go in the repository. Three patterns differ in how much secret material Git holds.

  1. Encrypted in Git

    Git holds
    Encrypted values, versioned with the rest.
    At apply time
    A controller decrypts them. Flux decrypts SOPS files with age, OpenPGP or cloud KMS keys.
    Watch for
    The key. Whoever holds it can read the whole history.
  2. Referenced from a store

    Git holds
    A reference, never the value.
    At apply time
    An operator such as External Secrets Operator fetches the value from a vault or cloud secret manager.
    Watch for
    Rotation and audit move to the store, outside Git.
  3. No standing secret

    Git holds
    Nothing secret.
    At apply time
    The workload proves its identity and gets short-lived credentials.
    Watch for
    It needs a provider that supports identity federation.

Two cautions. Do not inject secrets while manifests are generated: Argo CD “stores generated manifests in plaintext in its Redis cache”, its docs warn. And a Kubernetes Secret is “by default, stored unencrypted” in etcd, so the Kubernetes docs ask for encryption at rest and least-privilege access. More in Secrets Management in 2026: Sprawl, Non-Human Identities, and the Vault vs Workload Identity Decision.

Your first loop

How do you get started with GitOps?

Where your team stands

DORA’s research finds that comprehensive use of version control predicts continuous delivery. Five questions show how close you are.

  • Could you rebuild a cluster from the repository alone?
  • Does every deploy start from a commit, or do some start from a terminal?
  • Who can change production by hand today?
  • Are secrets already out of your repositories?
  • If someone edits production by hand, how long until you know?

A first rollout in five steps

  1. One service, one cluster

    A service that matters but is not critical, in a non-production cluster.

  2. Watch before you enforce

    Run Argo CD without automated sync, or preview Flux with flux diff kustomization. List every difference.

  3. Make Git true

    Move each difference into Git or remove it, until the app shows as in sync.

  4. Turn on the loop

    Enable automatic sync and drift correction first. Add pruning last.

  5. Remove hand access

    Take away standing write access to production. Keep a logged break-glass path.

If you would rather have it built for you, see the Self-Service Release Build.

Where to start

Measure your last release first

GitOps changes how the last step of a release runs. The free Release Check shows where your last release spent its time and what that costs a year, in under 5 minutes and without a call.