Ravindra BagaleCourses & study guides मराठी

Chapter 86: Argo CD (GitOps)

DevOps

86.1 Why GitOps — kubectl from laptops versus desired state in Git

Story. At a PhonePe-style payments team in Bengaluru, four engineers each kept a kubeconfig for prod. On Friday, Omar applied a hotfix from his laptop. Priya had already changed the same Deployment in a PR that was still open. Monday morning staging matched Git; prod did not. The on-call bill for the weekend spike was about ₹1.2 lakh in lost orders. They moved desired YAML into a deploy repo and let Argo CD sync. Now the only path to prod is a merged commit. That is GitOps: Git is the source of truth; the cluster must match Git.

Laptop kubectl drifts. Git holds desired state. Argo CD syncs the cluster to match Git.
Laptop kubectl drifts. Git holds desired state. Argo CD syncs the cluster to match Git.

Why

Many people with cluster write access create silent drift. Reviews belong on pull requests, not on chat screenshots of kubectl commands.

What

  • GitOps — Desired cluster state lives in Git. A controller applies it.
  • Desired state — The YAML (or Helm/Kustomize) you want in the cluster.
  • Live state — What is actually running now.
  • Drift — Live state differs from desired state.
  • Argo CD — A Kubernetes-native GitOps continuous delivery tool. It compares Git to the cluster and syncs.

How

  1. Put app manifests in a Git repo (often a separate deploy repo).
  2. Install Argo CD in the cluster.
  3. Create an Application that points at that repo path.
  4. Sync so live state matches Git. Prefer pull requests for every change.

Example 1: Drift after a laptop hotfix

kubectl get deploy shop-api -n shop -o jsonpath='{.spec.replicas}{"\n"}'

Output

5

What it shows: Live replicas are 5. Git still says 3. Without GitOps nothing pulls the cluster back.

Example 2: Same check after Argo CD self-heal

argocd app get shop-api

Output

Name:               shop-api
Sync Status:        Synced
Health Status:      Healthy

What it shows: Argo CD reports Synced. Live matches the Git revision it tracks.

Ravindra Bagale's Tip

One deploy repo per product team beats many people sharing one prod kubeconfig.

Quick quiz

Q1. What is the source of truth in GitOps?

Git — the desired state stored in a repository.

Q2. What is drift?

When live cluster state differs from the desired state in Git.

Q3. What does Argo CD do?

It watches Git and syncs the cluster so live matches desired.

Did you understand? Let us try it once more.