Skip to content
intermediate Phase 13 · GitOps & CI/CD

GitOps Principles

Learn GitOps principles: declarative, versioned, automated, and observable.

45m
0 problems
Topic Progress 0%

The Four Principles

The Four Principles

OpenGitOps distills GitOps into four statements:

  1. Declarative — desired system state is described as data, not imperative commands
  2. Versioned and immutable — that description lives in Git: every change is a commit with an author, review, and history
  3. Automated delivery — agents apply changes automatically; divergence is detected and corrected
  4. Continuously reconciled — the agent reports and drives the actual state toward the declared state

Practical consequences: git revert is your rollback, PR review is your change advisory board, and cluster state becomes reconstructible from the repository plus an image registry.

Push vs Pull Delivery

Push vs Pull Delivery

Push: CI pipelines run kubectl apply or helm upgrade with cluster credentials. Simple to start — but nothing corrects manual changes afterward, credentials fan out to every pipeline, and history splits across Git and cluster events.

Pull: a controller inside the cluster watches the repository, renders manifests, diffs them against live state, and applies differences — then keeps doing it. A human edit to a Deployment gets reverted (or alerted on) within minutes.

Prerequisites for either style: everything expressively declarative (Helm values, Kustomize overlays), a plan for secrets (SOPS, external secret stores), and no kubectl edit in normal operations — hand edits are exactly the drift the system exists to remove.

Pitfalls and Interview Angles

Pitfalls and Interview Angles

Git-as-backup only. Storing manifests in Git without an applying agent is just versioning — no automation, no reconciliation, no GitOps.

Secrets in plaintext. Git becomes the single most attractive target; encrypt (SOPS) or reference external stores, and protect branches with signed commits.

Double-writers. If pipelines AND a reconciler both apply changes, they fight: pipeline applies v2, reconciler reverts to Git's v1. Pick one writer per cluster — usually the reconciler.

Repo layout mismatches. Overlapping paths between two controllers cause resources to be adopted and pruned by different owners; give each application/env a disjoint path.

Interview angle: define drift concretely (live state ≠ Git state), explain how the pull agent resolves it, and contrast it with what push CI would leave behind after a manual edit.

Quiz

1. Which best describes GitOps' source of truth?

Question 1 options

2. What happens when someone kubectl edits a Deployment in a pull-GitOps cluster?

Question 2 options

3. Why is push-only CI considered incomplete GitOps?

Question 3 options

Flashcards

Question

OpenGitOps principles

Answer

Declarative, versioned/immutable, automated delivery, continuously reconciled.

Question

Pull-based reconciliation

Answer

In-cluster agent diffs Git state against live objects and re-applies divergences continuously.

Question

Drift

Answer

Live cluster state differing from Git-declared state — detected and corrected (or alerted) by the reconciler.

Question

Push vs pull

Answer

Push = CI applies with cluster creds; pull = in-cluster agent owns writes, enabling self-healing and single-writer semantics.

Revision Notes

Key Takeaways

  • 1. GitOps = Git as desired state + an agent that reconciles continuously
  • 2. Pull models deliver self-healing, auditability, and one writer per cluster
  • 3. Secrets strategy and disjoint repo paths are prerequisites, not afterthoughts

Interview Tips

  • • Define the four principles and immediately ground them in an operational example each
  • • Explain drift with a scenario: someone edits a replica count — what happens, and why that behavior matters

Cheat Sheet

GitOps: declarative + versioned in Git + automated + continuously reconciled. Pull agent diffs live vs Git, reverts drift, git revert = rollback. One writer/cluster; encrypt secrets.

Continue Learning

Before You Start

  • No prerequisites listed.

Next Topics