Guides
What Is GitOps? Beginner Guide with a Real Flow
By Ravindra Bagale, DevOps trainer · LinkedIn · Published: · Last updated:
Store desired Kubernetes state in Git, change it only via PR, let a sync agent apply, detect drift, and roll back with git revert.
Friends, GitOps means the cluster must match Git — not the other way around. Chala mitrano — if you kubectl edit, expect OutOfSync.
मित्रांनो, GitOps = cluster Git सारखे. Chala mitrano — kubectl edit केले तर OutOfSync.
मित्रों, GitOps = cluster Git जैसा। Chala mitrano — kubectl edit किया तो OutOfSync।
Quick answer
Hold this vertical picture:
- Put manifests in Git.
- Require PR reviews.
- Install a sync agent (next guide).
- Watch Synced/Healthy.
- Revert to roll back; keep secrets out of Git.
Language: English · मराठी · हिंदी
GitOps flow
Why GitOps
Auditable, reversible cluster changes.
Why: Snowflake kubectl sessions cannot be replayed.
What: Git truth + sync agent.
How: PR is the ticket.
Example 1: Desired state in Git
Type this:
mkdir -p /tmp/gitops/apps/web && printf '%s\n' 'apiVersion: apps/v1' 'kind: Deployment' 'metadata: {name: web}' 'spec: {replicas: 2}' > /tmp/gitops/apps/web/deploy.yaml && cat /tmp/gitops/apps/web/deploy.yaml
You will see:
What it means: Git holds what should run — not a wiki guess.
Example 2: PR is the change ticket
Type this:
printf '%s\n' 'ok: every image tag bump goes through a pull request review'
You will see:
ok: every image tag bump goes through a pull request review
What it means: No kubectl edit prod in GitOps land.
Example 12: Definition one-liner
Type this:
printf '%s\n' 'GitOps: Git is source of truth; automated sync makes the cluster match'
You will see:
GitOps: Git is source of truth; automated sync makes the cluster match
What it means: Interview opener.
Concept 1: Sync and drift
Controller applies and detects.
Why: Manual edits fight the agent.
What: OutOfSync; heal or educate.
How: Least privilege kubecreds.
Example 3: Sync agent idea
Type this:
printf '%s\n' 'Controller compares Git desired state to live cluster and applies the diff'
You will see:
Controller compares Git desired state to live cluster and applies the diff
What it means: Argo CD / Flux are common controllers.
Example 4: Drift detection
Type this:
printf '%s\n' 'If someone kubectl-ed a change, GitOps shows OutOfSync and can heal'
You will see:
If someone kubectl-ed a change, GitOps shows OutOfSync and can heal
What it means: Drift is visible — Infosys audit win.
Example 7: Who can apply
Type this:
printf '%s\n' 'Humans merge PRs; the controller applies — least privilege on cluster creds'
You will see:
Humans merge PRs; the controller applies — least privilege on cluster creds
What it means: Fewer humans with prod kubeconfig.
Merges promote; reverts undo.
Why: SSH hotfixes leave no history.
What: Overlays/folders; git revert.
How: CI updates image tags in Git.
Example 5: Promote via Git
Type this:
printf '%s\n' 'dev overlay → stage → prod folders or branches; merge promotes'
You will see:
dev overlay → stage → prod folders or branches; merge promotes
What it means: Promotion is a merge, not an SSH.
Example 6: Image tag update
Type this:
printf '%s\n' 'sed example: image: registry.example.internal/web:1.4.2'
You will see:
sed example: image: registry.example.internal/web:1.4.2
What it means: CI writes the tag into Git; sync deploys.
Example 8: Rollback = revert commit
Type this:
printf '%s\n' 'git revert the bad tag commit; sync brings old version back'
You will see:
git revert the bad tag commit; sync brings old version back
What it means: History explains every prod change.
Concept 3: Scale and secrets
App-of-apps; sealed secrets.
Why: Cleartext passwords fail audits.
What: Root app pattern; external secrets.
How: Terraform can be PR-gated too.
Example 9: Not only Kubernetes
Type this:
printf '%s\n' 'GitOps idea also appears for Terraform plans gated by PR — cluster sync is the classic demo'
You will see:
GitOps idea also appears for Terraform plans gated by PR — cluster sync is the classic demo
What it means: Stay focused on K8s sync for this guide.
Example 10: App of apps pattern hint
Type this:
printf '%s\n' 'One root app points at a folder of child apps — team scale pattern'
You will see:
One root app points at a folder of child apps — team scale pattern
What it means: Capgemini multi-team clusters use this.
Example 11: Secrets still special
Type this:
printf '%s\n' 'Do not put raw passwords in Git — sealed secrets / external stores'
You will see:
Do not put raw passwords in Git — sealed secrets / external stores
What it means: GitOps does not mean secrets in cleartext.
GitOps card
1 Desired state in Git 2 PR review 3 Sync agent applies 4 Drift = OutOfSync 5 Rollback = git revert 6 No raw secrets in Git
Suppose: Constant OutOfSync
Someone mutating live; enable auto-heal or stop manual edits.
Suppose: Bad release
Revert the commit; let sync roll back.
Ravindra Bagale's Tip
At Cognizant and Infosys interviews, say: PR review is the change ticket; the sync agent is the only prod applier.
Cognizant/Infosys interviews मध्ये: PR = change ticket; sync agent = एकमेव prod applier.
Cognizant/Infosys interviews में: PR = change ticket; sync agent = अकेला prod applier।
Check yourself (quiz)
Q1. Source of truth?
Git
Q2. Who applies to cluster?
Sync agent/controller
Q3. Change ticket?
Pull request
Q4. Rollback?
git revert + sync
Q5. kubectl edit result?
Drift / OutOfSync
Q6. Secrets in Git?
Not in cleartext
Reading tracking
Mark this guide when you finish. Your browser remembers it on this device.
commit → PR → sync → match → revert if needed.
Did you understand? Let us try it once more.
Frequently asked questions
GitOps vs CI deploy?
CI may update Git; the agent deploys continuously from Git.
Must I use Argo CD?
No — Flux and others exist; Argo is common.
What is drift?
Live cluster differs from Git.
Rollback?
Revert commit; sync.
Secrets?
Sealed secrets / external secret stores.
App of apps?
Root application that manages many child apps.