Skip to content
$ lynuxpro
← GitOps with Argo CD

LESSON 1 OF 19 · BEGINNER · 9 MIN

GitOps principles

Free previewLesson 1 of the 2 free lessons in this Pro course.Unlock all 19

HOW IT WORKSPush versus pull

pushCI jobholds cluster passwordGitsingle source of truthTool in clusterpulls and appliesCluster
1/5

In the old way, a CI job pushes into the cluster, so it needs the cluster password.

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

IdeaIn plain words
DeclarativeYou write what you want, not the steps to get it (Kubernetes YAML)
VersionedEvery change is a Git commit, so you have history, reviews and undo
PulledA tool inside the cluster pulls the config. Nobody pushes into the cluster
ReconciledThe tool keeps comparing Git with the cluster and fixes differences

Push versus pull

Push (old CI deploy)Pull (GitOps)
Who changes the clusterThe CI job, with cluster credentialsA tool inside the cluster
Cluster password stored in CIYes, riskyNo
Someone changes the cluster by handNobody noticesThe tool notices and fixes it
RollbackRun the pipeline againgit 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 Git
OUTPUTterminalutf-8 · 3L

What you get

  • A full audit trail: git log shows 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.
OUTPUTterminalutf-8 · 5L
git log --oneline -3
SHELLbashutf-8 · 1L
a41c9e2 shop: scale prod to 5 replicas (#142)7be03d1 shop: bump image to 1.4.0 (#139)c09aa5f shop: add readiness probe (#137)
OUTPUTterminalutf-8 · 3L

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

WordMeaning
Desired statewhat Git says should run
Live statewhat is really running in the cluster
Driftlive state that no longer matches desired state
Reconcilecompare the two and fix the drift
Config repothe 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. 1. In GitOps, who applies the changes to the cluster?

  2. 2. Someone edits a Deployment by hand with kubectl. What does a GitOps tool do?

  3. 3. How do you roll back in GitOps?