What GitOps Is
In the CI/CD course the pipeline's last job deployed: it held cluster credentials and ran helm upgrade or kubectl apply. That works, but it has three weak spots. The pipeline needs write access to production, so every compromised runner or leaked token is a production breach. Nothing watches the cluster after the job ends, so a kubectl edit at 2 a.m. stays there until someone notices. And the answer to "what is running in production right now?" lives in the cluster, not in anything you can review.
GitOps turns that around. A Git repository describes the desired state of the cluster, and an agent running inside the cluster keeps pulling that repository and making the cluster match it, forever. The Kubernetes GitOps lesson gave you a one-page overview; this course goes deep with the two agents the industry settled on, Argo CD and Flux.
The four principles
The OpenGitOps project (a CNCF working group) wrote the principles down. A system is GitOps-managed when its desired state is:
| Principle | Meaning | What breaks without it |
|---|---|---|
| Declarative | the state is described ("3 replicas of linkly 1.4.0"), not scripted ("scale up, then patch") | you can't diff a script against a cluster |
| Versioned and immutable | it is stored so that every version is kept and can't be changed after the fact: in practice, Git commits | no audit trail, no revert |
| Pulled automatically | software agents fetch the desired state from the source | someone has to remember to push it |
| Continuously reconciled | agents keep observing the actual state and correcting it toward the desired state | drift goes unnoticed |
Git is not part of the definition (an OCI registry also qualifies as an immutable, versioned store, and Flux can reconcile from one), but Git is where almost everyone keeps it, because pull requests give you review, approval and history for free.
Push versus pull
Push (CI deploys):
developer -> git push -> CI runner --(kubeconfig with write access)--> cluster
Pull (GitOps):
developer -> pull request -> merge -> Git repository
^
| fetch every few minutes (read-only)
agent in the cluster --(applies, in-cluster RBAC)--> cluster| Push-based CD | Pull-based GitOps | |
|---|---|---|
| Who holds cluster credentials | the CI system | only the agent inside the cluster |
| What CI needs | kubeconfig / cloud role with write access | write access to a Git repo (or nothing) |
| Drift after deploy | invisible | detected and reported or reverted |
| "What's deployed?" | ask the cluster | read the repo at main |
| Rollback | re-run an old pipeline | git revert |
| Clusters behind a firewall | CI must reach the API server | the agent only needs outbound access to Git |
CI doesn't disappear: it still builds, tests and scans images and pushes them to a registry. It just stops at the registry and, at most, opens a pull request that changes an image tag in the GitOps repository.
A first taste: the deployed state is a commit
Everything a GitOps agent will apply sits in a repository, so "what changed in production?" is a git log question. This session builds a tiny deployment repo with two commits; the image version for each commit is just a line in a file:
git init -q linkly-deploy && cd linkly-deploy
mkdir -p production
cat > production/values.yaml <<'EOF'
image:
tag: 1.3.2
replicaCount: 3
EOF
git add . && git commit -qm "production: linkly 1.3.2"
sed -i 's/1.3.2/1.4.0/' production/values.yaml
git commit -qam "production: promote linkly 1.4.0"
git log --oneline
echo "--- deployed now:"
git show HEAD:production/values.yaml | grep tag
echo "--- deployed before the last change:"
git show HEAD~1:production/values.yaml | grep tagb1bff9d production: promote linkly 1.4.0
17e6e92 production: linkly 1.3.2
--- deployed now:
tag: 1.4.0
--- deployed before the last change:
tag: 1.3.2
An agent watching main sees the new commit, renders what's in production/ and applies the difference. To undo, nobody touches the cluster: git revert HEAD creates a third commit, and the agent rolls the cluster back the same way it rolled it forward.
What this course covers
- Principles: the reconcile loop (modelled in Python), declarative state, drift and self-heal, repo layouts, promotion between environments, and secrets.
- Argo CD 3: Applications, Projects, sync policies, health checks, sync waves and hooks, rollback, Helm sources, app-of-apps and ApplicationSets.
- Flux 2: the source, kustomize, helm and image-automation controllers.
- Argo CD vs Flux, then progressive delivery with Argo Rollouts and Gateway API traffic splitting.
- A Mini Project: a GitOps repo that promotes the
linklychart from staging to production.
How the examples run
There is no cluster in the browser or in the verification sandbox, so the course uses three kinds of example:
- Real tool sessions (
bashblocks with output):git,helm template,kustomize build,kubeconform(with the Argo CD, Flux and Gateway API schemas),flux create … --exportandflux build kustomization. They ran offline in a container with Helm 4.3, Kustomize 5.8, kubeconform 0.8 and Flux CLI 2.10, and their output is real. - Python models of the controllers' logic: reconcile loops, sync waves, health aggregation, generators, canary steps. They are deterministic, so you can edit and rerun them.
- Sample sessions for anything that needs a live cluster (
argocd app sync,flux get kustomizations), labelled as samples and kept in the real tools' output format.
The course assumes you can write Helm charts and Kustomize overlays (Kubernetes Packaging: Helm & Kustomize) and build images in CI (CI/CD Pipelines); it links back instead of re-teaching them.
Test yourself
Which OpenGitOps principle is missing from a setup where CI runs kubectl apply once per merge and nothing else watches the cluster?
- Declarative
- Versioned and immutable
- Continuously reconciled
- None: that setup is GitOps
In pull-based GitOps, which component needs credentials that can change the production cluster?
- The CI runner
- Every developer
- The agent running inside the cluster
- The container registry
How do you roll back a bad release in a GitOps setup?
- kubectl rollout undo on each Deployment
- Revert the commit in the GitOps repository and let the agent apply it
- Delete the namespace
- Re-run the build job of the previous version