In simple words
- GitOps: a way of running systems where Git holds the desired state, and a tool keeps the real system matching it automatically.
- Desired state: what you want running, written as files in Git.
- Pull-based deployment: a tool inside the cluster pulls changes from Git, instead of a pipeline pushing into the cluster. No cluster passwords live in CI.
- Config repository: a separate Git repo holding deployment files, apart from the app's source code.
Big picture
GitOps means Git is the one place that says what should run. A tool watches Git and makes the cluster match it. You change the app by changing Git, not by typing commands on a server.
Think of a restaurant. The recipe book (Git) says what each dish must be. The cook (Argo CD) checks the kitchen again and again and fixes anything that does not match the book.
The four ideas
| Idea | In plain words |
|---|---|
| Declarative | You write what you want, not the steps to get it (Kubernetes YAML) |
| Versioned | Every change is a Git commit, so you have history, reviews and undo |
| Pulled | A tool inside the cluster pulls the config. Nobody pushes into the cluster |
| Reconciled | The tool keeps comparing Git with the cluster and fixes differences |
Push versus pull
| Push (old CI deploy) | Pull (GitOps) | |
|---|---|---|
| Who changes the cluster | The CI job, with cluster credentials | A tool inside the cluster |
| Cluster password stored in CI | Yes, risky | No |
| Someone changes the cluster by hand | Nobody notices | The tool notices and fixes it |
| Rollback | Run the pipeline again | git revert |
Two repositories
Most teams use two repos:
- App repo: source code, tests, Dockerfile. CI builds an image from it.
- Config repo: the Kubernetes YAML. Argo CD watches this one.
CI ends by changing the image tag in the config repo. Argo CD does the rest.
Developer -> pull request -> merge -> CI builds image -> CI updates image tag in config repo -> Argo CD sees the commit -> cluster matches GitWhat you get
- A full audit trail:
git logshows who changed what and when. - Easy rollback: revert the commit.
- Safer access: developers need Git access, not cluster admin.
- Rebuilding a cluster is easy, because Git has everything.
A change from start to finish
Say you want 5 copies of the shop app instead of 3.
1. You edit envs/prod/kustomization.yaml: replicas: 3 -> replicas: 52. You open a pull request. A teammate reviews it and approves.3. You merge. Git now says "5".4. Argo CD sees the new commit and compares it with the cluster (3 copies).5. Argo CD scales the app to 5 copies.git log --oneline -3a41c9e2 shop: scale prod to 5 replicas (#142)7be03d1 shop: bump image to 1.4.0 (#139)c09aa5f shop: add readiness probe (#137)The history of your production system is just git log. To undo step 5, run git revert a41c9e2.
Where Argo CD fits
Argo CD is one popular GitOps tool. Another is Flux. Both pull from Git and reconcile. Argo CD is known for its web UI and its clear picture of every app. Flux is smaller and has no UI of its own. The ideas in this course (Git as truth, pull, reconcile) apply to both.
What GitOps does not do
- It does not build your images. CI does that (lesson 17).
- It does not store your data. Backups do that (lesson 19).
- It does not hide secrets for you. You need a plan for them (lesson 12).
Words you will meet
| Word | Meaning |
|---|---|
| Desired state | what Git says should run |
| Live state | what is really running in the cluster |
| Drift | live state that no longer matches desired state |
| Reconcile | compare the two and fix the drift |
| Config repo | the Git repo with the Kubernetes YAML |
These five words are all you need to read the rest of the course.
Common mistakes
- Putting secrets in the config repo as plain text. Lesson 12 shows how to avoid this.
- Keeping app code and config in one repo, so every code commit starts a deploy.
- Changing the cluster with
kubectl edit"just once". Argo CD will undo it, and your team will be confused.
Summary
- Git says what should run. A tool in the cluster makes it so.
- The four ideas: declarative, versioned, pulled, reconciled.
- Use a separate config repo, and change it through pull requests.
CHECK YOUR UNDERSTANDING
3 quick questions
1. In GitOps, who applies the changes to the cluster?
2. Someone edits a Deployment by hand with kubectl. What does a GitOps tool do?
3. How do you roll back in GitOps?