GitOps Agents Pull the Desired State from Git and Revert Changes Made Outside It
In GitOps, a Git repository holds the complete desired state of a cluster, and an agent running inside the cluster (Argo CD or Flux) keeps comparing that repository with what is actually running. When they differ, the agent applies the repository. Deploying becomes a commit, rolling back becomes git revert, and a change typed by hand with kubectl is either flagged or undone.
Pull Instead of Push
A classic pipeline pushes: CI runs kubectl apply and therefore holds credentials for the cluster. A GitOps agent pulls from inside the cluster, so CI only needs to write to the repository, and the cluster's credentials never leave it. The agent runs a reconcile loop: read the desired state, observe the live state, act on the difference, repeat. It is the declarative model (see Declarative Tools Converge on a Desired State, Imperative Scripts Replay Steps) applied continuously to the whole cluster, where a tool like Terraform compares code and real state only when someone runs a plan.
What It Buys
- Rebuilds: on a fresh cluster, install the agent, point it at the repository, and every application declared there comes back.
- Rollbacks: reverting the commit that broke an application makes the agent deploy the previous version.
- Audit trail:
git logshows who changed which setting, when, and the message explains why. - No silent drift: a manual change shows up as a difference between Git and the cluster.
When It Is Worth It
GitOps pays off once there are several applications, several people, or a cluster you expect to rebuild. It adds an agent to install and upgrade, and a bootstrap order to think about (the agent itself and its custom resources come first). For a handful of manifests applied by one person, a repository plus kubectl apply keeps most of the benefits.
In My Homelab
Argo CD runs the cluster from the homelab repo since 2026-11-24. A single root Application creates the others, and only it syncs on its own (see In an App of Apps, Only the Root Is Applied by Hand, So Its Sync Policy Decides What a Commit Can Delete). The CNI and Argo CD itself had been installed with Helm; they were adopted, not reinstalled, by rendering the same chart and values, so nothing restarted (see Argo CD Can Adopt a Running Helm Release When It Renders the Same Chart, Values and Release Name). The media stack is registered but stays unsynced until its storage exists: Git can describe it before the cluster can run it.
References
- Kubernetes MOC - hub for Kubernetes notes.
- DevOps and Infrastructure as Code MOC - hub for infrastructure-as-code notes.
- Declarative Tools Converge on a Desired State, Imperative Scripts Replay Steps - the desired-state model GitOps runs in a loop.
- Argo CD Can Adopt a Running Helm Release When It Renders the Same Chart, Values and Release Name - moving an existing Helm release under Argo CD.
- In an App of Apps, Only the Root Is Applied by Hand, So Its Sync Policy Decides What a Commit Can Delete - the root Application and its safety settings.
- OpenGitOps: GitOps principles - declarative, versioned, pulled automatically, continuously reconciled.
- Argo CD documentation - sync, self-heal and out-of-sync status.
- Flux documentation - Git sources and reconciliation intervals.