Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

🏠 Back to Blog

Core Concepts

  • Argo CD is a declarative GitOps CD tool for k8s
  • Git is the source of truth (desired/target state), the cluster is the live state
  • It continuously compares the two and reports/fixes the difference

GitOps principles

  • Declarative: desired state is described, not scripted
  • Versioned: everything lives in git, so audit trail + easy rollback
  • Automatically pulled/applied: Argo CD pulls from git (no CI pushing to the cluster)
  • Continuously reconciled: drift is detected and (optionally) corrected

Architecture

  • Microservices, no single “Argo CD” component
  • Built on native k8s primitives (controllers, CRDs, ConfigMaps, Secrets)

Components

  • API Server
    • gRPC/REST, also serves the web UI
    • app management, sync/rollback/actions, repo + cluster creds, RBAC, auth
    • receives git webhooks
    • UI, CLI and CI all go through it
  • Repository Server
    • internal service, keeps a local cache of git repos
    • generates manifests from repo URL, revision, path and tool params (plain YAML, Helm, Kustomize, Jsonnet, plugins)
    • this is what polls git (not the controller)
  • Application Controller
    • k8s controller (StatefulSet)
    • compares live state vs. desired state from the repo server
    • sets sync status + health, runs sync operations and hooks
    • default reconciliation is every 3 minutes (timeout.reconciliation: 180s in argocd-cm)
  • ApplicationSet Controller
    • watches ApplicationSet and generates Applications
  • Redis
    • volatile cache only (repo/manifest cache, resource state), rebuilt on restart
    • etcd (CRs, ConfigMaps, Secrets) is the real state
  • Dex (optional)
    • SSO bridge for LDAP, SAML, GitHub, etc.
    • not needed if talking OIDC directly
  • Notifications controller
    • bundled since 2.3, triggers + templates

CRDs

  • Application
  • AppProject
  • ApplicationSet

Application

  • smallest unit of work, group of k8s resources defined by a git source
  • important parts are spec.source and spec.destination
  • spec.project defaults to default
## Local cluster
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: guestbook
  namespace: argocd
  finalizers:
    - resources-finalizer.argocd.argoproj.io  # cascade delete
spec:
  project: default
  source:
    repoURL: https://github.com/argoproj/argocd-example-apps.git
    targetRevision: HEAD   # branch, tag or SHA
    path: guestbook
  destination:
    server: https://kubernetes.default.svc   # or `name: in-cluster`
    namespace: guestbook
  syncPolicy:
    automated:
      prune: true
      selfHeal: true
    syncOptions:
      - CreateNamespace=true

Source types

  • plain directory (directory.recurse: true), Helm, Kustomize, Jsonnet, plugin
  • Helm: helm.valueFiles, helm.parameters, helm.values, helm.releaseName
    • Helm chart repo uses chart: instead of path:
    • Argo runs helm template and applies the YAML, so helm ls shows nothing
  • Kustomize: kustomize.namePrefix, commonLabels, images
  • sources (plural) allows multiple sources, e.g. chart from one repo and values from another:
sources:
  - repoURL: https://github.com/example/app.git
    path: helm
    helm:
      valueFiles:
        - $values/values-prod.yaml
  - repoURL: https://github.com/example/config.git
    ref: values

Sync status

  • Synced - live matches git
  • OutOfSync - live differs (new commit, manual change)
  • Unknown - can’t compare (cluster/repo unreachable, bad manifests)

Health status

  • Healthy - resource is ok
  • Progressing - not healthy yet, but expected to become so
  • Degraded - failed or unhealthy
  • Suspended - paused (e.g. CronJob suspended, paused Rollout)
  • Missing - not in the cluster
  • Unknown - health can’t be determined (no health check for that type)
  • Sync and health are independent: an app can be Synced and Degraded
  • App health is the worst health of its resources
  • Built-in checks for Deployment, StatefulSet, Service, Ingress, PVC, etc.
  • Custom checks are Lua in argocd-cm:
data:
  resource.customizations.health.argoproj.io_Rollout: |
    hs = {}
    if obj.status ~= nil and obj.status.phase == "Healthy" then
      hs.status = "Healthy"
      return hs
    end
    hs.status = "Progressing"
    hs.message = "Rollout is progressing"
    return hs

Sync Options

  • Manual or automatic sync - apply changes to apps automatically or manually
  • Auto prune resources - describes what happens when fils are deleted or removed from git
  • Self-heal of cluster - defines what ArgoCD does when you make imperative changes to the cluster

Conditions

  • in status.conditions of the app
  • ComparisonError, InvalidSpecError, OrphanedResourceWarning, SyncError

Hooks and waves

  • covered in sync-strategies
  • hook phases: PreSync, Sync, PostSync, SyncFail, PostDelete
  • waves via argocd.argoproj.io/sync-wave: "n"

CLI basics

argocd app list
argocd app get guestbook
argocd app diff guestbook
argocd app manifests guestbook
argocd app history guestbook
argocd app wait guestbook --sync --health