Where is the real state of your cluster?
Imagine you have a Kubernetes cluster running your production application. A developer, trying to fix a bug at 3 AM, runs a manual kubectl edit deployment command to change an environment variable.
Later that day, your CI/CD system deploys a new version based on the YAML files in your Git repository. The 3 AM fix is instantly overwritten and lost, causing the bug to reappear.
Why? Because there were two distinct sources of truth:
1. What was actually running in the cluster (the reality).
2. What was defined in the Git repository (the desired state).
This is the "configuration drift" problem, and it gets worse at scale. With dozens of services and multiple engineers making ad-hoc changes, the gap between what Git says and what the cluster actually runs becomes a reliability and security nightmare.
Enter GitOps
GitOps is a set of practices designed to solve this. The core idea is simple: Git is the single source of truth for your entire system.
Everything—infrastructure definitions, application configurations, policies—must be described declaratively in Git. If you want to change something in the cluster, you don't use kubectl directly; you make a Pull Request to the Git repository. An automated process then ensures the actual state of the cluster matches the desired state defined in Git.
This means Git history becomes your audit log. Every change is attributed to a commit, reviewed via a PR, and reversible with a git revert. You get all the software engineering practices—code review, branching, rollback—applied to your infrastructure.
Interviewers often ask: "What is GitOps, and how is it different from just using a CI/CD pipeline?" The key distinction is who initiates the deployment and where credentials live. In traditional CI/CD, an external system pushes changes using cluster credentials it holds. In GitOps, an in-cluster agent pulls changes, so no external system ever holds cluster admin credentials. Emphasize the pull model, drift detection, and Git as the audit trail.