design·lab

DevOps & platform

GitOps — Argo CD & Flux

Git holds the desired state of your cluster; an in-cluster agent keeps reality matching it — automatically.

✗ Problem

Deploying by hand invites drift

Someone runs kubectl apply from their laptop, or clicks around a console. It works — until it doesn't.

# works on my machine, deployed from my machine…
$ kubectl apply -f deployment.yaml
$ kubectl set image deploy/api api=v2

# who ran this? when? why? nobody knows.
Config drifts from what's in source control, there's no audit trail of who changed what, rollbacks are scary manual guesswork, and every environment slowly becomes a unique snowflake.
✓ How it works

Git is the single source of truth

An in-cluster agent (Argo CD / Flux) continuously reconciles the live cluster to match Git — pull-based, not pushed from a pipeline.

// the reconcile loop, forever:
loop {
  desired = readGit(repo)
  actual  = readCluster()
  if (desired !== actual) {
    apply(desired)   // heal drift
  }
  sleep(pollInterval)
}
📓 Git
desired state
🚀 Agent
watches & reconciles
☸️ Cluster
actual state

Merge a PR → it deploys. Revert the commit → it rolls back. Manual drift is detected and auto-corrected — the cluster can't stay out of sync for long.

✓ See it live

Merge a PR, drift by hand, watch it heal

Follow the messages: a merged PR gets deployed, then someone edits the cluster directly — the agent notices and reverts it back to Git.

Git is the source of truth; the agent keeps the cluster matching it.

✓ Takeaway

Declarative, versioned, self-healing deploys

  • Deploys are declarative and versioned — the whole history lives in Git, which means it's fully auditable.
  • PR = deploy. Merging changes the desired state; the agent does the rest.
  • Revert = rollback. No scary manual undo — just git revert.
  • Drift is auto-healed: manual cluster edits get reconciled back to Git.
  • Pull-based: the agent lives inside the cluster and pulls changes — no external system needs cluster credentials pushed to it.
  • Argo CD is app-centric with a great UI; Flux is a composable toolkit of controllers. Same reconcile idea as Kubernetes and IaC; pairs with CI/CD (CI builds the image, GitOps deploys it).