🔄 The GitOps Model

GitOps is an operating model where Git is the single source of truth for both application code and infrastructure state. A controller continuously reconciles the live cluster state to match what's declared in the Git repository — the same reconciliation pattern Kubernetes uses internally, extended to the deployment level.

Four GitOps Principles (OpenGitOps)

1. Declarative

The entire system — apps, configs, infra — is described declaratively. No imperative scripts.

2. Versioned & Immutable

Desired state is stored in Git. Every change is a commit. History is the audit trail. Rollback is a git revert.

3. Pulled Automatically

A software agent pulls from Git and applies changes — no CI system needs cluster credentials pushed into it.

4. Continuously Reconciled

The agent detects and corrects drift automatically. Manual kubectl apply changes are overwritten on the next sync.

Git Repo manifests / Helm charts / Kustomize poll/webhook ArgoCD Application Controller Repo Server API Server + UI apply Kubernetes Cluster live state ✓ Synced ✗ OutOfSync → reconcile drift detected → auto-sync

Key ArgoCD Concepts

ConceptWhat it is
ApplicationCRD that links a Git source (repo + path + revision) to a cluster destination (cluster + namespace)
AppProjectGroups Applications; defines allowed source repos, destination clusters, and permitted resource kinds
SyncThe act of applying Git state to the cluster. Can be manual or automatic
Sync StatusSynced (matches Git) or OutOfSync (drift detected)
Health StatusHealthy / Progressing / Degraded / Missing — based on resource readiness
ApplicationSetGenerates many Applications from a template — one per cluster, environment, or Git directory
App of AppsAn Application whose manifests are other Application manifests — bootstraps a whole cluster from Git

⚡ ArgoCD Quick Start & Core Patterns

Install ArgoCD

kubectl create namespace argocd
kubectl apply -n argocd \
  -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml

# Access the UI
kubectl port-forward svc/argocd-server -n argocd 8080:443

# Get initial admin password
argocd admin initial-password -n argocd

Declare an Application

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: my-app
  namespace: argocd
spec:
  project: default
  source:
    repoURL: https://github.com/my-org/my-app-config
    targetRevision: HEAD
    path: environments/production
  destination:
    server: https://kubernetes.default.svc
    namespace: my-app
  syncPolicy:
    automated:
      prune: true       # delete resources removed from Git
      selfHeal: true    # revert manual kubectl changes
    syncOptions:
      - CreateNamespace=true

App of Apps Pattern

Bootstrap an entire cluster by pointing one root Application at a directory of Application manifests. Adding a new app is a Git commit — no manual ArgoCD UI interaction required.

my-cluster-apps/
├── root-app.yaml          ← the App of Apps Application
└── apps/
    ├── cert-manager.yaml
    ├── ingress-nginx.yaml
    ├── monitoring.yaml
    └── my-app.yaml        ← each is an Application CRD

ArgoCD vs Flux v2

DimensionArgoCDFlux v2
UIRich built-in web UICLI-first; optional Weave GitOps UI
Multi-clusterHub-and-spoke (central ArgoCD manages N clusters)Agent per cluster (pull model)
Helm supportNative (renders server-side)HelmRelease CRD (Helm Controller)
Image automationArgocd Image Updater (addon)Built-in ImagePolicy controller
CNCF statusGraduatedGraduated
Best forTeams wanting visibility and UI-driven opsTeams wanting pure GitOps automation, agent model
💡 GitOps is the deployment layer for everything you've learned Every manifest in this course — Deployments, Services, NetworkPolicies, RBAC, Karpenter NodePools, cert-manager Issuers — belongs in a Git repository managed by ArgoCD or Flux. GitOps ties the whole curriculum together.

📝 Knowledge Check

Q1. A developer runs kubectl scale deployment my-app --replicas=5 directly on a cluster managed by ArgoCD with selfHeal: true. What happens next?
  • A) ArgoCD accepts the change and updates the Git repo to replicas=5
  • B) ArgoCD detects drift and reverts the deployment back to the replica count in Git
  • C) ArgoCD marks the Application as OutOfSync but takes no action
  • D) The change is permanent until the next manual sync
B) ArgoCD reverts the change. With selfHeal: true, ArgoCD continuously compares live state to Git state. When it detects the replica count drifted from what Git declares, it automatically applies the Git state — overwriting the manual change. Git is the only way to change the cluster.
Q2. What is the "App of Apps" pattern in ArgoCD?
  • A) Running multiple ArgoCD instances in the same cluster
  • B) A root Application whose Git path contains Application manifests — bootstrapping all cluster apps from a single Git commit
  • C) Packaging multiple microservices into one Helm chart
  • D) Using ApplicationSets to generate apps across multiple clusters
B) A root Application managing other Applications. The App of Apps pattern uses one ArgoCD Application pointing at a directory of Application YAMLs. ArgoCD applies those, creating child Applications that each manage their own workloads. The result: the entire cluster state is bootstrapped from a single root Git path.