Simple definition#
GitOps manages infrastructure and applications by keeping their desired state in Git and running agents in the cluster that continuously pull that state and reconcile the cluster to match it. Git becomes the audit log, the review process and the rollback mechanism.
The four OpenGitOps principles#
- Declarative — the system’s desired state is expressed declaratively.
- Versioned and immutable — desired state is stored in a way that keeps full history (Git).
- Pulled automatically — software agents pull the desired state from the source.
- Continuously reconciled — agents observe actual state and correct drift.
Push vs pull#
flowchart LR
subgraph Push["Push-based"]
CI1["CI pipeline<br/>holds cluster credentials"] -->|"kubectl / helm"| K1["Cluster"]
end
subgraph Pull["Pull-based GitOps"]
CI2["CI pipeline<br/>no cluster credentials"] -->|"PR: new digest"| G[("Git config repo")]
AG["Agent in cluster<br/>Argo CD / Flux"] -->|"pull"| G
AG -->|"reconcile"| K2["Cluster"]
end
Pull wins on security (no cluster credentials outside), drift correction and auditability.
The end-to-end flow#
Argo CD#
flowchart LR
UI["UI / CLI / API"] --> SRV["argocd-server"]
SRV --> CTRL["application-controller<br/>compare + sync"]
CTRL --> REPO["repo-server<br/>render Helm, Kustomize, YAML"]
REPO --> GIT[("Git / OCI")]
CTRL --> CL1["Cluster A"]
CTRL --> CL2["Cluster B"]
- Application — source (repo, path, chart, revision) + destination (cluster, namespace) + sync policy (auto, prune, self-heal).
- ApplicationSet — generate many Applications from templates (per cluster, per environment, per Git directory or pull request).
- App of apps — a parent Application that manages others; useful for bootstrapping clusters.
- Sync waves and hooks — order resources (CRDs before CRs, migrations before deployments).
- Projects — RBAC boundaries: which repos, clusters and namespaces a team may use.
- Argo CD 3.x (2025–2026) tightened RBAC defaults, removed deprecated features and improved ApplicationSet scale; releases arrive roughly quarterly.
Flux#
- A set of controllers (GitOps Toolkit): source-controller (Git, OCI, Helm repos), kustomize-controller, helm-controller, notification-controller, image automation.
- Fully CRD-driven and CLI-first; native OCI artifact sources; multi-tenancy via namespaced controllers and impersonation.
- CNCF graduated, like Argo.
| Argo CD | Flux | |
|---|---|---|
| UX | Rich UI, visual diff and health | CLI/CRDs, UI via add-ons |
| Helm | Renders templates (no Helm release objects) | Real Helm releases via helm-controller |
| Multi-cluster | Central instance managing many clusters, or agents per cluster | Usually one Flux per cluster, hub patterns possible |
| Tenancy | Projects + RBAC + SSO | Namespaced controllers + impersonation |
| Ecosystem | Argo Rollouts, Workflows, Events; Kargo for promotion | Flagger for progressive delivery |
Repository structure#
platform-config/ # owned by the platform team
├── clusters/
│ ├── prod-eu-1/ # cluster add-ons: ingress/gateway, cert-manager, policies
│ └── prod-us-1/
└── applicationsets/ # generate apps per cluster/team
team-shop-config/ # owned by the shop team
├── apps/orders/
│ ├── base/ # Kustomize base or Helm values defaults
│ └── overlays/
│ ├── dev/
│ ├── staging/
│ └── prod/ # image digest, replicas, resources
- Separate application source repos from configuration repos (different change rates and permissions).
- Prefer directories per environment over long-lived branches per environment.
- Protect production paths with code owners and required reviews.
Promotion between environments#
- CI or a bot (Renovate, Argo CD Image Updater, Flux image automation) opens a PR to bump the image digest in
dev. - After tests pass, promotion to
staging/prodis another PR (manual or automated). - Kargo (from the Argo ecosystem) and release orchestrators such as Digital.ai Release manage multi-stage promotion with verification and approvals.
Secrets in GitOps#
Never store plaintext secrets in Git. Options:
| Option | How |
|---|---|
| External Secrets Operator | Git stores a reference; the operator fetches from Vault/cloud secret managers |
| Sealed Secrets | Encrypt with the cluster’s public key; only the controller decrypts |
| SOPS | Encrypt values with KMS/age; Flux/Argo plugins decrypt |
Drift and self-healing#
- Detect drift: someone runs
kubectl editin production → the app shows OutOfSync. - Self-heal: the controller reverts the change automatically.
- Allow intentional runtime changes (HPA replica counts, injected fields) with ignoreDifferences rules.
Common mistakes#
Quick check#
What are the OpenGitOps principles? Declarative, versioned and immutable, pulled automatically, continuously reconciled.
Why is pull-based deployment more secure? CI never holds cluster credentials; the in-cluster agent pulls from Git, and every change is a reviewed commit.
What is an ApplicationSet? An Argo CD resource that generates Applications from templates and generators (clusters, Git directories, lists, pull requests) — ideal for fleets and many teams.
How do you promote a release between environments in GitOps? By changing the environment’s desired state in Git — usually a pull request that updates the image digest or chart version in that environment’s overlay.
How do you handle secrets with GitOps? External Secrets Operator references, Sealed Secrets or SOPS-encrypted values — never plaintext in Git.
Summary#
- GitOps = desired state in Git + agents that pull and reconcile.
- Argo CD (UI, ApplicationSets, Rollouts) and Flux (toolkit, real Helm releases, OCI) are both CNCF graduated.
- Separate app and config repos; folders per environment; promotion by PR.
- External secrets, drift detection, self-heal and tenant isolation.