What Is GitOps?
GitOps is not just installing ArgoCD or FluxCD, it’s more and I tried to break down.
Bob logged into the cluster one evening and changed a worker node’s resource limit. Quick fix, nobody knew. After a few weeks the manager asks, “who changed what in our cluster?” and everybody just looks at each other. Nobody has the answer. That small story is the reason GitOps exists.
GitOps Inception
The textbook line is:
GitOps uses Git as a single source of truth to deliver applications and infrastructure.
Notice the word infrastructure. GitOps is not only for apps, you can deliver infra the same way.
Now the obvious question: we can already deliver things with shell scripts, Python or whatever, so why drag Git into this? Because of Bob. Linux logs may tell you who logged in, but they won’t tell you which change was made by which person. No proper tracking, no proper audit.
Git gives you both for free:
| What You Need | What Git Already Gives |
|---|---|
| Tracking | Pull request, review, commit |
| Auditing | Who changed what, and when |
| Rollback | Revert the commit |
So people said, why not connect delivery directly with Git? That is how GitOps was born.
How It Looks
Nobody touches the cluster by hand. You change the YAML in Git, and a controller (ArgoCD here) running inside the cluster reads Git and applies it.
flowchart LR
actor["Actor"] -->|PR, review, merge| repo["Git Repo (K8s YAML)"]
subgraph cluster["K8s Cluster"]
ctrl["GitOps Controller (ArgoCD)"] -->|Deploys| res["Resources"]
end
ctrl -->|Reads| repo
Works fine for one cluster. But think about 100s of clusters, then 1000s of resources. Without the GitOps way, managing, tracking, auditing and changing all of that becomes a headache.
GitOps Principles
| # | Principle | In Simple Words |
|---|---|---|
| 1 | Declarative | Desired state is written as what you want. What you see in the YAML is what you finally get |
| 2 | Versioned And Immutable | Desired state is versioned. Git is the usual choice, but even a versioned S3 bucket can do it |
| 3 | Pulled Or Pushed Automatically | Either the controller pulls the change, or the change is pushed to it automatically (like a webhook) |
| 4 | Continuously Reconciled | Controller keeps watching the cluster and Git. If they don’t match, Git wins |
About the last one: the controller can’t stop somebody from changing the cluster by hand, but it will notice and put things back as Git says.
flowchart LR
watch["Watch Git and Cluster"] --> same{"Match?"}
same -->|Yes| watch
same -->|No| fix["Reconcile: Make Cluster Match Git"]
fix --> watch
Note
GitOps by principle is not only for Kubernetes. It is just that most of the popular controllers are focused on K8s clusters.
Advantages
| Advantage | Why |
|---|---|
| Security | Continuous reconcile throws away unwanted changes |
| Versioning | Every change lives in Git history |
| Auto upgrades | Merge a change and it rolls out by itself |
| Auto healing | Something drifts or breaks, controller brings it back |
| Audit | Every change has a name and a reviewed PR behind it |
So next time the manager asks who changed what, you just open Git history and show.
