Skip to main content
Welcome to the GitOps and Continuous Delivery lesson. Scenario: It’s 2 a.m. and your pager goes off — production is down. You SSH into the cluster to investigate, but something changed and you have no record of what, when, or who. You’re flying blind. This is the world before GitOps. In this lesson you’ll learn:
  • The problems GitOps solves,
  • The four pillars of GitOps,
  • How the reconciliation loop functions, and
  • How drift detection and self-healing work.
The image lists four learning objectives related to GitOps, including understanding its problems, defining its pillars, explaining the reconciliation loop, and understanding drift detection and self-healing strategies.
Why incidents like this occur Many Kubernetes environments grant developers direct kubectl access to production. That enables ad-hoc, imperative changes from developers’ laptops. Those changes are applied directly, often without a centralized audit trail or version history. Example (imperative action):
When multiple people make ad-hoc changes—especially during high-pressure incidents—conflicting modifications can be introduced simultaneously. With no single source of truth and no formal change history, teams cannot track who changed what, when, or why.
The image illustrates a flowchart titled "Deployment Roulette," showing three uncoordinated teams (Dev, Ops, SRE) sending conflicting changes to a production cluster.
Consequences: configuration drift, unpredictable behavior, and prolonged outages Uncoordinated changes create configuration drift between environments, unpredictable production behavior, and outages caused by incompatible or unintended changes. This makes root cause analysis difficult and puts production stability in the hands of human coordination and memory rather than an auditable system.
The image outlines the concept of "Deployment Roulette," highlighting three issues: configuration drift between environments, unpredictable production behavior, and prolonged outages from incompatible or unintended changes.
Imperative vs. Declarative Root cause: the imperative model. Running imperative commands (scale, set image, etc.) immediately changes cluster state and leaves only ephemeral terminal history. Imperative examples:
There is no integrated version history, no central audit trail, and no automatic detection when the same resource changes later. By contrast, the declarative model records desired state in files (YAML/JSON) committed to Git. Git automatically provides a versioned history so you can see who changed what, when, and why (when commit messages are used). Example (declarative snippet):
The key insight: GitOps replaces imperative “do this now” commands with declarative desired state and automation that converges actual cluster state to that declared state.
The image compares imperative commands (before) with declarative commands (after), highlighting a shift from step-by-step instructions to automation and desired state declaration.
What is GitOps? GitOps is an operational model where Git repositories store declarative descriptions of infrastructure and applications. Automated controllers running in the cluster ensure the cluster state matches those Git-declared states.
The image illustrates Git as the single source of truth in a GitOps operational model, connecting Git repositories to declarative descriptions in YAML/JSON format.
The four pillars of GitOps
The image illustrates four features of Git as a single source of truth: Declarative, Versioned, Pulled, and Reconciled, with brief descriptions of each.
If it’s not in Git, it does not exist. If it’s in Git, it should be in the cluster. How the reconciliation loop works The reconciliation loop is the engine of GitOps. Controllers such as Argo CD and Flux operate continuously in three core phases:
  • Watch: The controller detects Git changes via polling, webhooks, or provider notifications.
  • Compare: It compares the declared desired state in Git against the actual cluster state resource-by-resource.
  • Sync: When differences are found, the controller applies the necessary changes (create/update/delete) to align the cluster with Git.
This loop integrates with developer workflows: Code & Push → Detect & Compare → Sync & Deploy → Continuous Watch.
The image depicts "The Reconciliation Loop," a cyclical process involving four steps: Code & Push, Detect & Compare, Sync & Deploy, and Continuous Watch, each with brief descriptions.
Example: you change a Deployment’s image from 1.0 to 2.0 and push the commit. Within the controller’s detection window (seconds to minutes), it sees the Git commit, compares the cluster’s running 1.0 deployment, and applies the update to 2.0. The loop is continuous; it’s not a one-time deployment. Drift detection and self-healing Drift occurs when the cluster diverges from Git-declared desired state. Controllers handle drift in several ways depending on policy and environment sensitivity.
The image outlines a drift detection and self-healing process using GitHub, featuring auto-sync for self-healing and alert and manual sync for human approval.
Common sources of drift
  • Manual kubectl edits and ad-hoc changes.
  • Autoscalers (HPA/VPA) adjusting replicas or resource requests/limits.
  • Other controllers or operators adding annotations/labels or modifying resources.
Principle to follow: Git is authoritative. Either the controller syncs the cluster to Git, or you update Git to reflect an intentional change in the cluster. The cluster is not the source of truth.
Using a pull-based model (agents inside the cluster pulling from Git) reduces secret sprawl. CI/CD systems do not need persistent cluster credentials to apply changes, improving security and auditability.
Recap — core takeaways
  • Git is the single source of truth: desired state belongs in version-controlled repositories.
  • Prefer declarative manifests over imperative commands: state is described, automation handles convergence.
  • Continuous reconciliation prevents unintentional drift: controllers compare and correct constantly.
  • Pull-based deployments are more secure and auditable because the cluster pulls from Git and CI/CD systems avoid persistent credentials.
Further reading and references This concludes the lesson on GitOps, desired state, drift, and reconciliation.

Watch Video