GitOps with ArgoCD & Flux
Reconciliation loops, app-of-apps, sync waves, drift detection, secret handling in GitOps. Why "kubectl apply from CI" is not GitOps and what changes when you fix that.
The mental model
Imagine a thermostat. You set it to 21°C — that's the desired state. The thermostat reads the room every few seconds — that's the actual state. If they differ, it turns the heating on until they match. Nobody "pushes heat" into the room; the loop pulls the room toward the number on the dial.
GitOps is that thermostat for infrastructure. A git repository holds the desired state (Kubernetes manifests, Helm values, Kustomize overlays). A controller running inside the cluster continuously compares the live cluster to that repo and reconciles the difference. Git is the dial.
This is why **kubectl apply from a CI job is not GitOps**. That's a push: CI has cluster credentials, fires a one-shot command, and then stops caring. If someone runs kubectl edit deploy/api at 2am, CI never notices — the cluster silently drifts from the repo, and the next deploy quietly reverts the hotfix. Three things change when you flip to pull-based reconciliation:
- Drift is detected and (optionally) corrected automatically. The controller is always comparing.
- **CI loses cluster credentials.** The pipeline builds an image and writes a tag into a git repo. Nothing else. A compromised CI runner can no longer
kubectl delete ns prod. - **Rollback becomes
git revert.** The audit trail is the commit log, with reviewers attached.
The two mainstream implementations: **ArgoCD** (a controller plus a strong UI, models everything as an Application CRD) and Flux (composable controllers — source, kustomize, helm, image-automation — CRD-first, no built-in UI). The mental model is identical; the ergonomics differ.
- Deep dive
- Internal architecture
- Real-world use cases
- Best practices
- Common mistakes
- Performance
- Security
- Production troubleshooting
- Advantages & disadvantages
- Alternatives
- Interview expectations
- Interview questions
- Facts to remember
- Cheat sheet
- Quick revision