Skip to Content
Mengty Learns
GitOps

Drift and Reconciliation

What configuration drift is, how GitOps agents detect OutOfSync resources, and how automated reconciliation heals the cluster.

explanationintermediateTested with argocd 3.6 (docs), flux 2.10 (docs)Updated Nov 26, 2026

TL;DR

Drift happens when live cluster state diverges from Git—usually from a manual kubectl edit. A GitOps agent continuously compares live objects against Git, flags OutOfSync, and with self-heal enabled automatically reconciles the cluster back to Git.

Intent

TL;DR

Understand how GitOps agents detect configuration drift and reconcile live clusters back to Git—and why manual hotfixes get overwritten unless they go through Git.

Problem

During an outage, someone runs kubectl edit deployment web to bump replicas or change an environment variable, fixes the fire, and forgets to update Git. Weeks later, the next deployment silently wipes out that hotfix—or worse, nobody knows why production behaves differently from staging.

Reconciliation compares two snapshots: Git (desired) vs. live Kubernetes API objects (actual).

Solution

GitOps treats reconciliation as a continuous control loop rather than a one-time deploy script:

  1. Observe: The GitOps agent (Argo CD or Flux) watches live Kubernetes resources via the API Server and compares them against the rendered manifests from Git.
  2. Detect Drift: Any difference in tracked fields (replicas, image tag, env vars) marks the application OutOfSync.
  3. Reconcile (Self-Heal): With automated reconciliation enabled (selfHeal: true in Argo CD, or default periodic interval in Flux), the agent reapplies the Git manifests to kube-apiserver, overwriting the manual edit.
  4. Prune (optional): If prune: true is set, resources deleted from Git are also deleted from the cluster.

Real-world analogy

▶ Flow: watch it work

Drift & Reconciliation: Manual Edit → OutOfSync → Self-Heal

Overview of Drift & Reconciliation: Manual Edit → OutOfSync → Self-Heal. 6 steps.
Overview6 steps in this flow

Press Start or tap any step dot to trace the path.

▸All steps (6)

Code

Comparing Flux (Kustomization) and Argo CD (syncPolicy) reconciliation settings:

# Flux Kustomization reconciles drift automatically on its interval (not run)
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
metadata:
  name: web-app
  namespace: flux-system
spec:
  interval: 5m
  path: ./apps/web
  prune: true
  sourceRef:
    kind: GitRepository
    name: k8s-config

When to use / when to avoid

When to use
  • You want production clusters to stay strictly aligned with Git and reject undocumented manual edits.
  • You need alerts when a cluster goes OutOfSync even if auto-heal is turned off.
When to avoid
  • Do not enable automated prune: true on stateful databases or namespaces until you test deletion protection.
  • Do not fight the agent during an incident—pause auto-sync explicitly if you must hotfix live, then commit the fix to Git.

How to implement

Start with drift detection only

Enable GitOps sync notifications so you see OutOfSync diffs before turning on selfHeal.

Enable self-heal for stateless workloads

Turn on selfHeal: true (Argo CD) or rely on Flux's reconciliation interval so drift heals automatically.

Handle HPA and mutated fields cleanly

Configure ignoreDifferences for fields mutated at runtime (such as spec.replicas when using a HorizontalPodAutoscaler).

Pros / Cons

Pros
  • Eliminates "snowflake" clusters where production silently diverges from staging.
  • Makes cluster rebuilds repeatable because everything live is already in Git.
Cons
  • Runtime-mutated fields (like HPA replica counts) can cause false OutOfSync noise if not ignored.
  • Enabling prune: true without care can delete resources removed from Git.

Relations

Check yourself

Check Yourself

1. An operator runs kubectl scale deployment/web --replicas=5 on a cluster where Git specifies replicas: 3 and Argo CD has selfHeal: true. What happens?

2. Why might an application show OutOfSync even when no human ran kubectl edit?

Sources