GitOps with Argo CD and Flux

GitOps explained: the four OpenGitOps principles, push vs pull deployment, Argo CD and Flux architectures, repository structures, environment promotion, multi-cluster with ApplicationSets, secrets, drift detection and self-healing, and common pitfalls.

On this page

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#

  1. Declarative — the system’s desired state is expressed declaratively.
  2. Versioned and immutable — desired state is stored in a way that keeps full history (Git).
  3. Pulled automatically — software agents pull the desired state from the source.
  4. Continuously reconciled — agents observe actual state and correct drift.

Push vs pull#

Push-based CD vs pull-based GitOps
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#

GitOps: from pull request to running release · drawn with Archify · zoom, guided views, search and SVG/PNG export. © 2026 Samir Kumar Sahoo, all rights reserved. Open full screen ↗

Argo CD#

Argo CD architecture
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/prod is 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 edit in 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.

References#