Eli Brody
← Back to blog

GitOps Is Not Just Git

· 11 min read
IaC Automation Operations

I've lost count of how many teams have told me they're "doing GitOps" when what they mean is "we put our Kubernetes manifests in a Git repository." They have YAML files in version control and a CI pipeline that runs kubectl apply when someone merges to main. That is a reasonable setup, and it is not GitOps.

I don't say this to be pedantic. The principles those teams are missing are the ones that make GitOps worth having. They've adopted the easiest 20% of the pattern and skipped the 80% that provides the operational guarantees.

The Four Principles

GitOps, as originally defined by Weaveworks and later formalized by the OpenGitOps project, rests on four principles. Read them closely and it becomes clear why most "GitOps" implementations don't qualify.

Declarative. The entire desired state of the system is described declaratively: a statement of what the state should be, as opposed to scripts that produce it or imperative commands that move toward it. Kubernetes manifests, Terraform configurations, and Helm charts all qualify. Shell scripts that run kubectl commands do not.

Versioned and immutable. The desired state is stored in a way that enforces immutability and versioning, with a complete audit trail. Git gives you this for free: every commit is immutable, every change is tracked, every state is recoverable. This is the easy part, and most teams get it right.

Pulled automatically. Software agents automatically pull the desired state declarations from the source. Most implementations part ways with the definition here. In GitOps the cluster pulls its desired state from Git. In most implementations a CI pipeline pushes changes to the cluster, and the direction of that arrow matters a great deal.

Continuously reconciled. Software agents continuously observe actual system state and attempt to apply the desired state. If the actual state diverges from the desired state, for any reason, the agent corrects it. This principle is what makes GitOps an operational model and more than version-controlled deployment.

Push vs. Pull

Most CI/CD pipelines work on a push model. A developer merges code, the pipeline triggers, builds artifacts, and runs kubectl apply or helm upgrade or terraform apply against the target environment. This works and there is nothing wrong with it.

Its limit is that it only acts on events. When the pipeline runs, it applies the current state from Git. Between runs, nothing is watching. If someone runs a manual kubectl edit in production, and eventually someone always does, the system drifts from the Git state. Nobody knows until the next pipeline run, if then. The pipeline applies what's in Git without checking that what's running matches it. It assumes the only difference is the latest commit.

In the pull model, an agent running inside the cluster (ArgoCD, Flux, or similar) watches the Git repository. When the repository changes, the agent pulls the new desired state and applies it. The agent also watches the cluster, and that is the part that counts. If actual state diverges from desired state, the agent corrects it whether or not anyone has committed anything to Git.

So manual changes get reverted. If someone runs kubectl scale deployment/api --replicas=5 directly against the cluster and the Git manifest says 3 replicas, the agent scales it back to 3. The repository is the source of truth. The cluster and the last pipeline run are not.

Reconciliation Loops

The reconciliation loop is the center of GitOps and the part most implementations skip. It continuously compares the desired state (what's in Git) with the actual state (what's running in the cluster) and takes corrective action when they diverge.

A thermostat works the same way. You set it to 72 degrees. It doesn't turn the furnace on once and walk away. It keeps measuring the temperature and acts whenever it deviates from the target. Someone may have opened a window, the sun may have gone down, the insulation may be poor. The thermostat has no interest in the cause, only in the delta.

The agent treats the cluster the same way. Maybe someone ran a manual command. Maybe a controller modified a resource. Maybe a node failure caused pods to reschedule with different configurations. The agent sees the delta, consults Git, and corrects it.

A CI pipeline that runs kubectl apply on merge is a different kind of thing. It is event-driven: it runs when you push code and handles the changes you planned. The reconciliation loop runs all the time and handles every change, whether planned, accidental, or malicious.

Drift Detection

Drift detection is the observability layer of GitOps. Even if you choose not to auto-remediate every drift, and there are valid reasons not to, you should know when your running system doesn't match your declared state.

In a push-only model, drift is invisible. You push a deployment on Monday. On Wednesday, someone manually patches a configmap in production to fix an urgent issue. On Friday, monitoring shows everything healthy, and nobody knows the running configuration doesn't match Git. The next deployment might overwrite the manual fix and bring the issue back. Or the fix might persist indefinitely and surprise someone months later during a disaster recovery exercise.

Proper drift detection continuously compares running state against declared state and surfaces the differences. ArgoCD does this visually: its UI flags resources that have drifted from the Git definition. Flux generates events and alerts. Either one gives you something the push model can't, which is confidence that what's running is what you think is running.

It catches more than manual changes. It also shows you controllers or operators modifying resources in unexpected ways, admission webhooks injecting sidecars that don't match your manifests, and vertical pod autoscalers changing resource limits. It amounts to a continuous audit of desired state against actual state.

Why Most Implementations Miss the Point

The typical "GitOps" implementation looks like this. Kubernetes manifests live in a Git repository, and a CI pipeline watches it. When changes are merged, the pipeline runs kubectl apply against the cluster. Maybe a staging environment gets deployed first, maybe there's an approval gate. The team calls this GitOps because the config is in Git and deployments are triggered by Git events.

What it lacks is the part that makes GitOps useful as an operational model:

None of this makes it bad infrastructure. A CI/CD pipeline that deploys from Git is functional, version-controlled, auditable, and better than deploying by hand. But the benefits people attribute to GitOps (drift detection, self-healing infrastructure, guaranteed state consistency) come only from the parts that were skipped.

The Role of Operators

ArgoCD and Flux exist to implement the reconciliation loop. I think of them as state reconciliation engines. Deploying things is a side effect of reconciling desired state with actual state.

ArgoCD watches one or more Git repositories, compares their manifests against what's running in the cluster, and surfaces any differences. It can auto-sync, applying changes when Git is updated. It can auto-prune, removing resources that exist in the cluster but not in Git. It can auto-heal, reverting manual changes that cause drift. Each capability maps to a core GitOps principle.

Flux takes a similar approach with a different architecture: it runs as a set of controllers inside the cluster rather than as a separate application. It watches Git repositories, Helm repositories, and OCI registries, and reconciles on a configurable interval. It generates Kubernetes events when it detects drift and integrates with notification systems to alert on reconciliation failures.

Both tools run continuously. They don't apply once and assume success. They keep comparing, detecting, and correcting, and that is the operational model you are paying for. Without it you have CI/CD with extra steps.

When GitOps Makes Sense

GitOps doesn't suit everything. It works very well for Kubernetes-native workloads where the entire desired state can be expressed declaratively, for infrastructure managed by controllers and operators, and in environments where multiple teams deploy to shared clusters and need clear audit trails.

It works less well when your infrastructure has significant imperative components: database migrations, data backups, one-off administrative tasks. These don't fit neatly into a declarative model. You can work around that with Kubernetes Jobs and CronJobs, but you're fighting the abstraction.

It also works less well when a deployment needs complex orchestration, such as deploying service A, waiting for it to be healthy, then deploying service B with a configuration that references service A. Traditional CI/CD pipelines handle sequential, conditional logic like that naturally. GitOps reconciliation converges on a declared state and was never meant to orchestrate a sequence of steps.

Most organizations need both. GitOps handles the steady-state management of infrastructure and applications. CI/CD handles the build, test, and artifact creation that produces the images and manifests GitOps deploys. The two complement each other.

Getting It Right

If you want GitOps itself, and not version-controlled CI/CD with a fashionable label, it requires five things:

  1. Deploy a reconciliation agent. Install ArgoCD, Flux, or an equivalent in your cluster and configure it to watch your Git repository. Everything else depends on this.
  2. Enable drift detection. Configure the agent to continuously compare desired state against actual state, alert when drift is detected, and make drift visible to the team.
  3. Remove push-based deployment. Your CI pipeline should build images and update manifests in Git. It should not run kubectl apply. The agent deploys and the pipeline creates artifacts.
  4. Lock down cluster access. With a reconciliation agent enforcing desired state, direct kubectl access to production is unnecessary for routine operations, so restrict it. Every manual change that bypasses Git undermines the model.
  5. Treat Git as the single source of truth. If it's not in Git, it shouldn't be in the cluster. If it's in the cluster but not in Git, the agent should flag or revert it, with no exceptions.
GitOps is an operational model in which the Git repository is the single source of truth and software agents continuously reconcile actual state to match desired state. Anything short of that is CI/CD with a Git trigger.

The teams getting real value from GitOps did more than move their YAML into a repository. They deployed reconciliation agents, enabled drift detection, and committed to the repository as the authority on what should be running, ahead of the cluster, the pipeline, and the last person who ran kubectl.

Comments