Course contentsShow
← Software Engineering
Lesson 1497 of 1,93343. Infrastructure as CodeFree lesson

The GitOps Workflow

Understand the GitOps workflow: commit changes to Git, automated sync agents detect drift, and reconcile actual state with desired state.

The GitOps Workflow

You'll learn: How GitOps automates infrastructure reconciliation by using Git as the single source of truth and automated agents to detect and fix drift.

The Core Idea

The GitOps workflow turns your Git repository into an operational control center. Every change to your infrastructure starts with a Git commit. From there, automated sync agents continuously watch both your Git repo (desired state) and your actual running infrastructure (actual state). When they detect differences—called drift—they automatically reconcile by updating the infrastructure to match what's declared in Git.

Think of it like a thermostat: you set your desired temperature (commit to Git), the thermostat constantly monitors the actual temperature (polls your cluster), and when it detects a difference (drift detection), it automatically adjusts the heating or cooling (reconciliation) to match your setting.

The Workflow Steps

  1. Commit Changes to Git: Developers or operators push infrastructure changes (Kubernetes manifests, Terraform configs, etc.) to a Git repository. This becomes the desired state.

  2. Automated Detection: Sync agents (like ArgoCD or Flux) continuously poll both the Git repository and the live infrastructure, comparing them.

  3. Drift Detection: When the agent discovers that actual state doesn't match desired state—whether from manual changes, failures, or configuration drift—it flags the difference.

  4. Automated Reconciliation: The agent automatically applies the Git-declared configuration to the infrastructure, bringing it back into alignment with the desired state.

This loop runs continuously, ensuring your infrastructure always converges toward what's declared in Git, without manual intervention.

Key Takeaway: The GitOps workflow automates infrastructure management through a continuous loop: commit desired state to Git → agents detect drift → agents automatically reconcile actual state with Git, ensuring consistency and eliminating manual configuration drift.