100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace

What is GitOps?

Learn what GitOps is — Git as source of truth, pull-based reconciliation, drift correction and rollback — with a DevOps interview answer.

mediumQ16 of 224 in DevOps Est. time: 6 minsLast updated:
Open Code Lab

Expected Interview Answer

GitOps is an operational practice where a Git repository is the single source of truth for declarative infrastructure and application configuration, and an automated agent continuously reconciles the live cluster state to match what is committed in Git.

Instead of running deploy commands manually or from a pipeline that pushes changes out, a GitOps controller such as Argo CD or Flux runs inside the cluster and pulls the desired state from Git, then applies any difference. Every change goes through a pull request, giving Git’s history, review, and rollback as the audit trail and change-control mechanism for infrastructure. If someone manually edits the live cluster, the controller detects the drift and reverts it back to match Git, so the repository always reflects reality. This pull-based model improves security because the cluster does not need external credentials pushed in, and it makes rollback as simple as reverting a commit.

  • Git history becomes the full audit trail for infrastructure changes
  • Automatic drift detection and self-healing reconciliation
  • Rollback is as simple as reverting a Git commit
  • Improved security via pull-based, credential-free deployment

AI Mentor Explanation

GitOps is like a team where the official team sheet in the clubhouse is the only source of truth for who plays, and the umpires continuously check the field against that sheet. If a player wanders onto the field who is not on the sheet, the umpire pulls them off automatically to match reality back to the sheet — that is drift correction. Changing the line-up means editing and approving the team sheet first, never just swapping players out on the ground. The sheet’s revision history shows every selection change ever made, and reverting a bad pick is as simple as restoring the previous sheet version.

Step-by-Step Explanation

  1. Step 1

    Declare desired state in Git

    Infrastructure and app configuration are committed as declarative manifests in a repository.

  2. Step 2

    Propose via pull request

    Every change is proposed as a pull request, reviewed, and merged.

  3. Step 3

    Controller pulls and applies

    A GitOps agent inside the cluster pulls the merged state and applies it.

  4. Step 4

    Detect and correct drift

    The controller continuously compares live state to Git and reverts any manual drift.

What Interviewer Expects

  • Git as the single source of truth for infrastructure
  • Pull-based reconciliation by an in-cluster controller
  • Drift detection and automatic correction
  • Rollback via reverting a Git commit

Common Mistakes

  • Confusing GitOps with simply storing YAML files in Git
  • Thinking GitOps requires pushing credentials into the cluster
  • Not mentioning drift detection and reconciliation
  • Ignoring that changes must go through pull requests

Best Answer (HR Friendly)

GitOps means we treat Git as the single source of truth for how our systems should be configured. A tool running inside our infrastructure constantly checks that reality matches what is in Git, and automatically fixes anything that has drifted — so rolling back a bad change is as easy as reverting a Git commit.

Code Example

A GitOps Application definition (Argo CD)
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: web
spec:
  source:
    repoURL: https://github.com/org/infra-repo
    path: apps/web
    targetRevision: main
  destination:
    server: https://kubernetes.default.svc
    namespace: web
  syncPolicy:
    automated:
      prune: true
      selfHeal: true

Follow-up Questions

  • How does GitOps differ from a traditional push-based CI/CD deploy?
  • What tools implement GitOps controllers?
  • How does GitOps handle configuration drift?
  • How would you roll back a bad deployment under GitOps?

MCQ Practice

1. In GitOps, what is the single source of truth for infrastructure state?

GitOps treats a Git repository of declarative configuration as the authoritative desired state.

2. How does a GitOps controller typically apply changes?

GitOps uses a pull-based model where an in-cluster agent pulls state from Git rather than external systems pushing changes in.

3. What happens when a GitOps controller detects manual drift in the cluster?

Self-healing GitOps controllers detect drift between live state and Git, then reconcile the cluster back to match Git.

Flash Cards

What is GitOps?An operational practice using Git as the single source of truth, reconciled automatically into live infrastructure.

Push vs pull model?GitOps is pull-based — an in-cluster controller pulls desired state from Git.

What is drift correction?The controller detects manual changes that diverge from Git and reverts them automatically.

How do you roll back in GitOps?Revert the Git commit; the controller reconciles the cluster to the prior state.

1 / 4

Continue Learning