Everything you've built so far is push-based — the pipeline pushes changes to the cluster. GitOps inverts this: an agent inside the cluster pulls desired state from Git. This lesson explains why that matters and how it changes everything.
Push vs Pull: The Fundamental Difference
Git becomes the single source of truth for your cluster's state. What's in Git IS what's running. If someone manually changes the cluster, ArgoCD reverts it. If Git changes, ArgoCD updates the cluster. This is continuous reconciliation.
The Four GitOps Principles (OpenGitOps Standard)
Why GitOps Is Architecturally Superior
| Concern | Push-Based | GitOps |
|---|---|---|
| Security | CI pipeline has cluster admin creds (big attack surface) | Only ArgoCD (in-cluster) has access. CI never touches cluster. |
| Audit trail | Check CI logs (scattered, ephemeral) | git log = complete history of every change |
| Drift | Someone kubectl edits → cluster diverges silently |
ArgoCD detects drift, reverts to Git (self-heal) |
| Rollback | Find old pipeline run, re-trigger… which version? | git revert → ArgoCD auto-syncs → rolled back |
| Multi-cluster | Pipeline per cluster (creds per cluster) | One ArgoCD managing N clusters from one Git repo |
| Disaster recovery | Rebuild cluster… then run all pipelines? In order? | Point ArgoCD at Git → entire cluster restored |
The Two-Repo Pattern
Why two repos?
- App devs don't need cluster access — they just push code
- Different permissions: restrict who can change production config
- Clean history: image tag updates don't pollute code commits
- CI pipeline image updates are the ONLY bridge between the two repos
The GitOps Deployment Flow
Self-Healing: The Killer Feature
🧠 Recall Check
- What's the fundamental difference between push-based and pull-based CD?
- Name the four GitOps principles.
- Why use two separate repos (app + GitOps)?
- What happens in GitOps when someone manually changes the cluster?
- In the GitOps flow, what does the CI pipeline actually DO? (Hint: it doesn't deploy.)
Reveal answers
- Push: CI pipeline pushes to cluster (pipeline has creds). Pull: in-cluster agent pulls from Git (pipeline never touches cluster).
- Declarative (desired state declared), Versioned (stored in Git), Pulled automatically (agents pull from Git), Continuously reconciled (drift auto-corrected).
- Separation of concerns: different permissions, clean git history, app devs don't need cluster access, CI only bridges via Git write.
- ArgoCD detects the drift (actual ≠ desired) and with
selfHeal: true, reverts the change to match Git. - CI builds the image, pushes to registry, then updates the image tag in the GitOps repo. That's it. ArgoCD handles the actual deployment.
You already understand Kubernetes reconciliation loops (controller watches desired state, makes actual match). GitOps is the same pattern one level up: ArgoCD watches Git (desired state) and makes the cluster (actual state) match. Next: installing ArgoCD and seeing it in action.