Skip to content

GitOps

First PublishedLast UpdatedByAtif Alam

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.

Traditional CI/CD DeployGitOps
CI pipeline pushes to the clusterCluster pulls from Git
Pipeline needs cluster credentialsOnly the in-cluster operator needs access
”What’s running?” → check the cluster”What’s running?” → check Git
Drift goes unnoticedDrift is auto-corrected
Rollback = rerun old pipelineRollback = git revert
Audit trail in CI logsAudit trail in Git history
Push-based (traditional CI/CD):
Developer ──► Git ──► CI Pipeline ──► kubectl apply ──► Cluster
Pull-based (GitOps):
Developer ──► Git ◄── GitOps Operator (in cluster) ──► reconcile ──► Cluster
Push-BasedPull-Based (GitOps)
Who deploysCI pipelineIn-cluster operator
Cluster credentialsStored in CI (secret)Only the operator has access
Drift detectionManual or noneContinuous (operator watches)
SecurityCI needs write access to clusterCluster pulls (no inbound access)
ToolsGitHub Actions, GitLab CI, JenkinsArgoCD, Flux

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.

Git Repository
│
▼
Source Controller ──► fetches manifests from Git, Helm repos, OCI
│
▼
Kustomize Controller ──► applies Kustomize overlays to the cluster
Helm Controller ──► installs/upgrades Helm releases
│
▼
Notification Controller ──► sends alerts (Slack, Teams, webhook)
Image Automation Controller ──► updates image tags in Git
Terminal window
# Install Flux CLI
brew 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 \
--personal
# GitRepository — tells Flux where to fetch manifests
apiVersion: source.toolkit.fluxcd.io/v1
kind: GitRepository
metadata:
name: myapp
namespace: flux-system
spec:
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 repo
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
metadata:
name: myapp
namespace: flux-system
spec:
interval: 5m
path: ./apps/myapp
prune: true # Delete removed resources
sourceRef:
kind: GitRepository
name: myapp
healthChecks:
- apiVersion: apps/v1
kind: Deployment
name: myapp
namespace: myapp
# HelmRepository — where to find charts
apiVersion: source.toolkit.fluxcd.io/v1
kind: HelmRepository
metadata:
name: bitnami
namespace: flux-system
spec:
interval: 1h
url: https://charts.bitnami.com/bitnami
---
# HelmRelease — what to install
apiVersion: helm.toolkit.fluxcd.io/v2
kind: HelmRelease
metadata:
name: redis
namespace: flux-system
spec:
interval: 10m
chart:
spec:
chart: redis
version: "18.x"
sourceRef:
kind: HelmRepository
name: bitnami
values:
architecture: standalone
auth:
enabled: false
FeatureArgoCDFlux
UIRich web UI + CLICLI only (use Weave GitOps for UI)
ArchitectureMonolithic (single controller)Modular (multiple controllers)
Multi-clusterBuilt-in (single ArgoCD manages many clusters)One Flux per cluster (or remote apply)
Helm supportRenders Helm templates, applies as plain YAMLNative HelmRelease CRD (proper Helm lifecycle)
KustomizeSupportedNative Kustomization CRD
Image automationNot built-in (use Argo Image Updater)Built-in Image Automation Controller
NotificationsBuilt-inNotification Controller
RBACBuilt-in with SSO integrationUses Kubernetes RBAC
App-of-appsYes (Application/ApplicationSet)Yes (Kustomization dependencies)
Learning curveLower (great UI)Higher (CRD-based, CLI-focused)
CNCF statusGraduatedGraduated
ScenarioChoose
Want a web UI for visibilityArgoCD
Prefer Helm lifecycle (install/upgrade/rollback)Flux
Managing many clusters from one placeArgoCD
Want modular, composable controllersFlux
Team already uses Kustomize heavilyEither (both support Kustomize)
Need image auto-update (tag in Git)Flux (built-in)

GitOps tools work with your existing manifest management:

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.

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.yaml

ArgoCD 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.

A common platform layout separates what runs, how it is packaged, and what version runs where:

RepoPurposeOutput
imagesDockerfiles, base images, build/scan pipelinesVersioned images in a registry (for example ECR). What runs.
chartsHelm charts (workloads, RBAC, PDBs, HPA); wrappers for upstream chartsVersioned charts in a registry (often OCI). How it is packaged.
deploymentsGitOps source of truth: Argo Applications / ApplicationSets, per-env values, pinned versionsWatched by Argo CD. What version runs where.
Images and charts produce versioned artifacts; the deployments repo selects which versions go where. Nothing reaches a cluster until deployments changes.
  1. App / base-image upgrade (for example a CVE patch): build in images → push tag → PR bumps the tag in deployments (dev → staging → prod).
  2. Chart change: edit charts → bump chart version → publish → bump targetRevision (or chart version) in deployments per environment.
  3. Cluster add-on upgrade (cert-manager, ingress, CNI, Karpenter): chart-version bump in deployments; roll cluster by cluster.
  4. 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.

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.

# Repo per environment
myorg/k8s-staging/
└── apps/
└── myapp/
myorg/k8s-production/
└── apps/
└── myapp/

Pros: Strongest isolation between environments, different access controls. Cons: Duplication, harder to promote changes.

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 cluster

Self-heal is powerful until you must keep a production hotfix alive for an hour. Safer patterns:

  1. Codify first — commit the hotfix to Git and let the controller converge (best audit trail).
  2. Temporarily pause automation — in Argo CD, disable auto-sync or selfHeal on the Application for a time-boxed window documented in the incident channel.
  3. Annotation-based ignores — some teams use sync options to skip specific resources during recovery; treat as debt with a ticket to remove.
  4. Always return to Git — merge equivalent YAML before closing the incident so the next sync does not undo patient care.

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 diff to 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.

BenefitWhy
Git as audit trailEvery deployment is a Git commit — who, what, when
DeclarativeDesired state in Git, not imperative scripts
Drift detectionOperator auto-corrects manual changes
Easy rollbackgit revert = rollback
SecurityCI pipeline doesn’t need cluster credentials
ConsistencySame tool manages all environments
Trade-OffConsideration
Secret managementSecrets can’t live in Git as plain text — use Sealed Secrets, SOPS, or External Secrets Operator
Learning curveRequires understanding ArgoCD/Flux CRDs and Git workflows
Multi-cluster complexityManaging many clusters and environments adds repo structure complexity
DebuggingWhen sync fails, you troubleshoot via the operator logs, not your usual CI pipeline
Database migrationsNeed a separate mechanism (Jobs, init containers) — not purely declarative
  • 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.
  • 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.