GitOps
GitOps is a deployment practice where Git is the single source of truth for your infrastructure and application state. Instead of running kubectl apply or helm install from a CI pipeline, a GitOps operator running in the cluster watches a Git repository and automatically synchronizes the cluster to match the desired state in Git.
For push-based, multi-cloud pipeline CD (manual judgment, VM + Kubernetes), see Spinnaker overview.
Why GitOps?
Section titled “Why GitOps?”| Traditional CI/CD Deploy | GitOps |
|---|---|
| CI pipeline pushes to the cluster | Cluster pulls from Git |
| Pipeline needs cluster credentials | Only the in-cluster operator needs access |
| ”What’s running?” → check the cluster | ”What’s running?” → check Git |
| Drift goes unnoticed | Drift is auto-corrected |
| Rollback = rerun old pipeline | Rollback = git revert |
| Audit trail in CI logs | Audit trail in Git history |
Push vs Pull Model
Section titled “Push vs Pull Model”Push-based (traditional CI/CD): Developer ──► Git ──► CI Pipeline ──► kubectl apply ──► Cluster
Pull-based (GitOps): Developer ──► Git ◄── GitOps Operator (in cluster) ──► reconcile ──► Cluster| Push-Based | Pull-Based (GitOps) | |
|---|---|---|
| Who deploys | CI pipeline | In-cluster operator |
| Cluster credentials | Stored in CI (secret) | Only the operator has access |
| Drift detection | Manual or none | Continuous (operator watches) |
| Security | CI needs write access to cluster | Cluster pulls (no inbound access) |
| Tools | GitHub Actions, GitLab CI, Jenkins | ArgoCD, Flux |
Argo CD
Section titled “Argo CD”Argo CD is the most popular GitOps controller for Kubernetes (CNCF graduated). It runs in-cluster and syncs Applications from Git with prune, self-heal, and a rich UI.
Install, Application YAML, CLI, App of Apps, ApplicationSets, sync waves, and multi-cluster / EKS registration live under Kubernetes Delivery:
Argo CD — tool reference and worked examples.
This page keeps GitOps practice (below) and Flux. For how Argo CD sits next to Helm and operators, see Helm vs operators vs GitOps.
Flux is another CNCF GitOps tool for Kubernetes. It’s a set of controllers that watch Git repositories, Helm charts, and OCI artifacts and reconcile them to the cluster.
Flux Architecture
Section titled “Flux Architecture”Git Repository │ ▼Source Controller ──► fetches manifests from Git, Helm repos, OCI │ ▼Kustomize Controller ──► applies Kustomize overlays to the clusterHelm Controller ──► installs/upgrades Helm releases │ ▼Notification Controller ──► sends alerts (Slack, Teams, webhook)Image Automation Controller ──► updates image tags in GitInstalling Flux
Section titled “Installing Flux”# Install Flux CLIbrew install fluxcd/tap/flux
# Bootstrap Flux in the cluster (also creates the Git repo structure)flux bootstrap github \ --owner=myorg \ --repository=k8s-config \ --branch=main \ --path=./clusters/production \ --personalFlux Resources
Section titled “Flux Resources”# GitRepository — tells Flux where to fetch manifestsapiVersion: source.toolkit.fluxcd.io/v1kind: GitRepositorymetadata: name: myapp namespace: flux-systemspec: interval: 1m # Check for changes every minute url: https://github.com/myorg/k8s-config.git ref: branch: main---# Kustomization — tells Flux what to deploy from the repoapiVersion: kustomize.toolkit.fluxcd.io/v1kind: Kustomizationmetadata: name: myapp namespace: flux-systemspec: interval: 5m path: ./apps/myapp prune: true # Delete removed resources sourceRef: kind: GitRepository name: myapp healthChecks: - apiVersion: apps/v1 kind: Deployment name: myapp namespace: myappFlux with Helm
Section titled “Flux with Helm”# HelmRepository — where to find chartsapiVersion: source.toolkit.fluxcd.io/v1kind: HelmRepositorymetadata: name: bitnami namespace: flux-systemspec: interval: 1h url: https://charts.bitnami.com/bitnami---# HelmRelease — what to installapiVersion: helm.toolkit.fluxcd.io/v2kind: HelmReleasemetadata: name: redis namespace: flux-systemspec: interval: 10m chart: spec: chart: redis version: "18.x" sourceRef: kind: HelmRepository name: bitnami values: architecture: standalone auth: enabled: falseArgoCD vs Flux
Section titled “ArgoCD vs Flux”| Feature | ArgoCD | Flux |
|---|---|---|
| UI | Rich web UI + CLI | CLI only (use Weave GitOps for UI) |
| Architecture | Monolithic (single controller) | Modular (multiple controllers) |
| Multi-cluster | Built-in (single ArgoCD manages many clusters) | One Flux per cluster (or remote apply) |
| Helm support | Renders Helm templates, applies as plain YAML | Native HelmRelease CRD (proper Helm lifecycle) |
| Kustomize | Supported | Native Kustomization CRD |
| Image automation | Not built-in (use Argo Image Updater) | Built-in Image Automation Controller |
| Notifications | Built-in | Notification Controller |
| RBAC | Built-in with SSO integration | Uses Kubernetes RBAC |
| App-of-apps | Yes (Application/ApplicationSet) | Yes (Kustomization dependencies) |
| Learning curve | Lower (great UI) | Higher (CRD-based, CLI-focused) |
| CNCF status | Graduated | Graduated |
When to Choose Which
Section titled “When to Choose Which”| Scenario | Choose |
|---|---|
| Want a web UI for visibility | ArgoCD |
| Prefer Helm lifecycle (install/upgrade/rollback) | Flux |
| Managing many clusters from one place | ArgoCD |
| Want modular, composable controllers | Flux |
| Team already uses Kustomize heavily | Either (both support Kustomize) |
| Need image auto-update (tag in Git) | Flux (built-in) |
GitOps with Helm and Kustomize
Section titled “GitOps with Helm and Kustomize”GitOps tools work with your existing manifest management:
Helm Charts
Section titled “Helm Charts”Both ArgoCD and Flux can deploy Helm charts from:
- A Helm repository (e.g. Bitnami, your private chart repo).
- A chart stored in a Git repository.
- An OCI registry.
The values can be stored in Git alongside the chart reference, making the full configuration auditable.
Kustomize Overlays
Section titled “Kustomize Overlays”A common pattern — base manifests with per-environment overlays:
apps/myapp/ ├── base/ │ ├── deployment.yaml │ ├── service.yaml │ └── kustomization.yaml ├── overlays/ │ ├── staging/ │ │ ├── kustomization.yaml # Patches: 1 replica, staging ingress │ │ └── ingress-patch.yaml │ └── production/ │ ├── kustomization.yaml # Patches: 3 replicas, prod ingress, HPA │ ├── ingress-patch.yaml │ └── hpa.yamlArgoCD and Flux both detect kustomization.yaml and apply the overlay automatically.
For more on Helm and Kustomize with Kubernetes, see Helm and Helm Templating. For hpa.yaml in production overlays, see Autoscaling on EKS.
Repository Structure Patterns
Section titled “Repository Structure Patterns”Three-Repo Structure
Section titled “Three-Repo Structure”A common platform layout separates what runs, how it is packaged, and what version runs where:
| Repo | Purpose | Output |
|---|---|---|
| images | Dockerfiles, base images, build/scan pipelines | Versioned images in a registry (for example ECR). What runs. |
| charts | Helm charts (workloads, RBAC, PDBs, HPA); wrappers for upstream charts | Versioned charts in a registry (often OCI). How it is packaged. |
| deployments | GitOps source of truth: Argo Applications / ApplicationSets, per-env values, pinned versions | Watched by Argo CD. What version runs where. |
Promotion and Upgrades
Section titled “Promotion and Upgrades”- App / base-image upgrade (for example a CVE patch): build in images → push tag → PR bumps the tag in deployments (dev → staging → prod).
- Chart change: edit charts → bump chart version → publish → bump
targetRevision(or chart version) in deployments per environment. - Cluster add-on upgrade (cert-manager, ingress, CNI, Karpenter): chart-version bump in deployments; roll cluster by cluster.
- Cluster version upgrade (EKS via Terraform, eksctl, or similar): scan manifests for deprecated APIs (Pluto, kubent), bump add-ons in deployments to versions compatible with the target Kubernetes version, then upgrade control plane and nodes. See Cluster upgrades.
Promotion is a series of PRs in deployments. Rollback is revert the PR. Automation: Renovate or Argo Image Updater open version-bump PRs.
Pattern 1: Monorepo (App + Config Together)
Section titled “Pattern 1: Monorepo (App + Config Together)”myapp/ ├── src/ # Application code ├── Dockerfile ├── .github/workflows/ # CI pipeline └── k8s/ # Kubernetes manifests (GitOps watches here) ├── base/ └── overlays/Pros: Everything in one place, simple. Cons: App code changes trigger GitOps reconciliation (noisy), tight coupling.
Pattern 2: Separate Config Repo (Recommended)
Section titled “Pattern 2: Separate Config Repo (Recommended)”# Repo 1: myorg/myapp (application code)myapp/ ├── src/ ├── Dockerfile └── .github/workflows/ci.yml # CI: build, test, push image
# Repo 2: myorg/k8s-config (deployment config)k8s-config/ ├── apps/ │ ├── myapp/ │ │ ├── base/ │ │ └── overlays/ │ ├── api-service/ │ └── worker/ └── infrastructure/ ├── cert-manager/ └── ingress-nginx/Pros: Clear separation of concerns, CI doesn’t need cluster access, config changes are auditable. Cons: Extra repository to manage, need to update image tags across repos.
Pattern 3: Config Per Environment Repo
Section titled “Pattern 3: Config Per Environment Repo”# Repo per environmentmyorg/k8s-staging/ └── apps/ └── myapp/
myorg/k8s-production/ └── apps/ └── myapp/Pros: Strongest isolation between environments, different access controls. Cons: Duplication, harder to promote changes.
Recommended: Separate Config Repo
Section titled “Recommended: Separate Config Repo”The separate config repo is the most common pattern. The CI pipeline (in the app repo) builds and pushes the image, then updates the image tag in the config repo:
App repo (CI): push ──► build ──► test ──► docker build + push ──► update image tag in config repo
Config repo (GitOps): ArgoCD/Flux detects tag change ──► sync to clusterHotfix without losing GitOps
Section titled “Hotfix without losing GitOps”Self-heal is powerful until you must keep a production hotfix alive for an hour. Safer patterns:
- Codify first — commit the hotfix to Git and let the controller converge (best audit trail).
- Temporarily pause automation — in Argo CD, disable auto-sync or selfHeal on the Application for a time-boxed window documented in the incident channel.
- Annotation-based ignores — some teams use sync options to skip specific resources during recovery; treat as debt with a ticket to remove.
- Always return to Git — merge equivalent YAML before closing the incident so the next sync does not undo patient care.
Sync loops and partial applies
Section titled “Sync loops and partial applies”When the controller never reaches Synced/Healthy:
- Read Application or Kustomization status conditions and controller logs (ordering, validation, webhook rejections).
- CRDs before CRs — install or upgrade CRD bundles before instances that reference new
apiVersions. - Retry with backoff — transient API errors clear; permanent errors need manifest fixes.
- Diff first —
argocd app diff/flux diffto see what the reconciler believes is out of sync.
Pair with Policy as code for CI-time catches and Kubernetes admission controllers for in-cluster failure modes.
Benefits and Trade-Offs
Section titled “Benefits and Trade-Offs”Benefits
Section titled “Benefits”| Benefit | Why |
|---|---|
| Git as audit trail | Every deployment is a Git commit — who, what, when |
| Declarative | Desired state in Git, not imperative scripts |
| Drift detection | Operator auto-corrects manual changes |
| Easy rollback | git revert = rollback |
| Security | CI pipeline doesn’t need cluster credentials |
| Consistency | Same tool manages all environments |
Trade-Offs
Section titled “Trade-Offs”| Trade-Off | Consideration |
|---|---|
| Secret management | Secrets can’t live in Git as plain text — use Sealed Secrets, SOPS, or External Secrets Operator |
| Learning curve | Requires understanding ArgoCD/Flux CRDs and Git workflows |
| Multi-cluster complexity | Managing many clusters and environments adds repo structure complexity |
| Debugging | When sync fails, you troubleshoot via the operator logs, not your usual CI pipeline |
| Database migrations | Need a separate mechanism (Jobs, init containers) — not purely declarative |
Key Takeaways
Section titled “Key Takeaways”- GitOps uses Git as the single source of truth — the cluster continuously reconciles to match Git.
- Pull-based (GitOps) is more secure than push-based (CI deploys) because the cluster pulls from Git instead of CI pushing to the cluster.
- Argo CD is best for teams that want a rich UI, multi-cluster management, and app-of-apps patterns — see Argo CD for install and multi-app patterns.
- Flux is best for teams that prefer modular controllers, native Helm lifecycle, and built-in image automation.
- Prefer a deployments (or config) repo that pins image and chart versions — promotion is PRs, rollback is
git revert. - Drift detection and self-healing are key GitOps benefits — manual changes are auto-corrected.
- Handle secrets with Sealed Secrets, SOPS, or External Secrets Operator — never store plain-text secrets in Git.
Related
Section titled “Related”- Argo CD — Install, Applications, ApplicationSets, sync waves, cluster registration.
- Helm vs operators vs GitOps — Mental model for packaging vs reconciliation.
- Crossplane — GitOps for cloud infrastructure next to workloads.
- Multi-cluster management — Fleet delivery alongside ApplicationSets.
- Cluster lifecycle tools — How clusters themselves are created before GitOps delivers workloads.
- Cluster upgrades — Control plane, add-ons, and CRD compatibility during version bumps.
- AIOps — LLM-assisted runbooks, RAG over operational knowledge, and evaluating AI suggestions alongside Git-defined desired state.