Why you need it

Ben adds a copy of the shop by hand, to fix a slow night. A month later nobody knows why it is there, who added it, or whether it is safe to remove. When people change the servers by hand, the only record of what runs is the servers themselves.

Think of it like this

A shared document that keeps its version history. You can see who changed each line and when, and you can go back to yesterday's version. Nobody edits a printed copy and hopes the others notice.

Where you’ll find it

  • Argo CD: Argo CD watches a Git repository and keeps a Kubernetes cluster matching it. With self-heal on, a change made by hand is undone.
  • Flux: Flux runs inside the cluster, reads the files in Git on a timer, and applies any difference.
  • GitLab: The GitLab agent lets a cluster follow a project's files the same way.

What to know first

The code. The servers' settings written as files in main. See Infrastructure as code.

Controller. A program that keeps comparing the code with what runs, and closes the gap. See Desired state and reconciliation.

History. Every change to main is kept as a line: who made it, when, and what changed.

How it works

  1. A change by hand leaves no trace. Ben starts a second copy himself. The code still says copies: 1, and nothing written anywhere says why the second one exists. This is the red ? in the animation.
  2. Only the code counts. A controller makes the servers match the code, and nothing else. Ben's copy is not in the code, so it is taken away. Changing the servers by hand stops working, so people stop doing it.
  3. Every change is a line with a name. To get two copies, Ben changes the code to copies: 2. The history now says Ben did it. A teammate can read it, ask about it, or check it before it goes in.
  4. Going back is one more line. In the animation Ben undoes his line and the servers follow. In real Git an undo does not erase the old line: it adds a new line that puts the old value back, so the history keeps both the mistake and the fix.
  5. Pull, not push. Before GitOps, a person or a build pushed changes to the servers, so what ran depended on who pushed last. With GitOps the controller lives with the servers and pulls from main. Nobody outside needs a key to the servers, and main always says what is running.

An example

The code says copies: 1. At 22:00 Ben starts a second copy by hand. With GitOps the controller sees it within a minute and removes it.

So Ben changes the code to copies: 2 instead. The history line reads "Ben, 22:04, copies 1 to 2", and the controller adds the copy.

Next morning the extra copy is not needed. Ana adds a line that sets copies: 1 again. Both lines stay in the history, and the servers drop to one copy.

Further reading

  • OpenGitOps principles, OpenGitOps, CNCF. The four rules of GitOps, each in one sentence. Start with this one.
  • Automated sync policy, Argo CD docs. How a real controller undoes changes made by hand, and how to switch that on.
  • git revert, Git docs. The real undo: a new line that reverses an old one, without rewriting history.