Module 8 · Project 08 · Deploy with GitOps and Argo CD · Lesson 28 of 48
Git as the source of truth
What GitOps is, why pulling changes into the cluster is safer than pushing them, and how Argo CD keeps the cluster matching a Git repository.
In this lesson · about 30 minutes
- Explain GitOps and pull-based deployment
- Separate the app repo from the config repo
- Describe sync, drift, self-heal and rollback in Argo CD
The problem with kubectl apply
In Project 07 you changed the cluster with kubectl apply. That works for one person. With a team, nobody knows exactly what's running, someone "quickly" edits a Deployment by hand and forgets, and the CI system needs admin credentials to the production cluster, which makes CI a juicy target.
GitOps fixes this with one rule: the cluster runs whatever is in Git, and Git is the only way to change it.
- The desired state of every environment is declared in a Git repository.
- An agent inside the cluster (Argo CD or Flux) watches that repository and pulls changes in. CI never touches the cluster.
- The agent keeps comparing Git with the cluster, just like Kubernetes' own control loop, and reports or undoes any difference.
- Every change is a commit: reviewed in a pull request, with an author and a time. Rolling back is
git revert.
Two repositories
- App repo: the source code. CI (Project 04) tests it, builds an image and pushes
notes-api:1.5.0to the registry. - Config repo (also called the manifest or GitOps repo): the Kubernetes YAML or Helm values for every environment. CI's last step is to open a pull request here changing
image.tagto1.5.0.
Keeping them apart means a code commit doesn't trigger a deploy loop, access can be different (many developers, few production approvers), and the config repo's history is a clean deployment log.
An Argo CD Application
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: notes-production
namespace: argocd
spec:
project: default
source:
repoURL: https://github.com/you/notes-config
targetRevision: main
path: environments/production
destination:
server: https://kubernetes.default.svc
namespace: notes
syncPolicy:
automated:
prune: true # delete things that were removed from Git
selfHeal: true # undo changes made by hand in the cluster
syncOptions:
- CreateNamespace=true
Argo CD shows each Application as Synced (cluster matches Git) or OutOfSync (it doesn't), and separately as Healthy, Progressing or Degraded. Sync means "apply what's in Git".
Try it · watch it run
GitOps: Git → Argo CD → cluster
Commit to the config repo and watch Argo CD notice and sync. Turn auto-sync off, then make a manual kubectl change and see the app go OutOfSync. Turn self-heal on and try again. Finally, roll back with git revert.
Git: manifests repo (main)
- a1c9e02 notes: deploy 1.4.0
replicas: 3 image: notes:1.4.0
⟳
Argo CD
Synced
auto-sync on
Cluster (live)
notes:1.4.0
argocd: app notes is Synced and Healthy (a1c9e02)
Whiteboard · watch and try
Push vs pull
Press Play. The tutor compares the two ways to deploy.
Tip: press Pause, then use the pen to work along on the board. Space plays and pauses; Ctrl+Z undoes your last mark.
Check your understanding0 of 3 correct
Key terms
Say the meaning to yourself, then tap a card to check.
Quiz score: 0 of 3
Written by Noviq Academy in its own words. The labs are simulations: no real servers are touched. When you build the projects yourself, use a practice virtual machine or a free-tier cloud account you control, watch your cloud spending, and never run cleanup or delete commands on a machine you care about. Tool names belong to their owners; versions and output are shown for learning and may differ slightly from yours. Read-aloud and the whiteboard voice use your device's built-in voices.