GitOps is not "deploy from CI". It is a state where git is the single source of truth and the cluster converges to it on its own. The difference looks subtle and is fundamental in practice: CI builds and publishes the artifact, and it enters the cluster through a controller that compares desired state against actual. Continuously.

Manual kubectl apply is a door left unlocked: not always the culprit, always undocumented.

What changes with ArgoCD

  • Drift is visible immediately. Someone tweaked a config in the console — Argo shows OutOfSync before it becomes the mystery of an incident. Without GitOps such a "fix" lives until the resource is recreated.
  • Rollback is a commit revert. Not a search for "what the manifest used to be" in personal notes or chat history.
  • Sync waves impose order. First the database, then migrations, then the application — as in the runbook, not as luck would have it:
metadata:
  annotations:
    argocd.argoproj.io/sync-wave: "-1"   # goes first
spec:
  # wave 0 - the application
  # wave 1 - post-deploy checks

Application: the working minimum

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: platform-stack
  namespace: argocd
spec:
  project: default
  source:
    repoURL: https://gitlab.internal/platform/argocd-apps
    targetRevision: main
    path: overlays/prod
  destination:
    server: https://kubernetes.default.svc
    namespace: platform
  syncPolicy:
    automated:
      prune: true        # git deleted - the cluster deletes
      selfHeal: true     # manual edits roll back to git
    syncOptions:
      - CreateNamespace=true
    retry:
      limit: 5
      backoff:
        duration: 15s

The first thing to do after installing

Enable auto-prune and selfHeal. Without them git and the cluster drift apart silently, and you're back where you started: half the resources live "by git's truth", the other half "by a console edit". The difference between the two modes:

Modeprune: falseprune: true
Resource deleted in gitlives in the cluster foreverdeleted on the next sync
A manual console editlives until recreatedselfHeal reverts it instantly

App of apps: scaling without manual input

Once there are more than three Applications, every new cluster/stack connects with a single commit: a root application describes the list of child applications, and ArgoCD creates them itself. A new region = a new line in the git catalog, without a manual "add an Application in the UI".

Environments and separation

  • A per-environment catalog: overlays/dev, overlays/stage, overlays/prod via kustomize. Need a B2B context — overlays/customer-x.
  • Production goes through MRs only. The UI sync button is off for prod (automated with a manual gate, or an AppProject restriction) — a production release passes review like any code.
  • Secrets are not in git. Sealed Secrets / External Secrets / Vault CSI: git stores the reference to a secret, not the secret itself. A secret in a git repository is the shortest path to a leak.

The GitOps acceptance checklist

  1. Every cluster change leaves a trace in git (otherwise OutOfSync becomes the norm).
  2. Cluster recovery = applying the catalog; regular "rebuild from scratch" drills have confirmed it.
  3. A drift dashboard: how many Applications are out-of-sync right now; a long-standing divergence = a signal.
  4. A commit revert restores the previous state; verified on a test bench.

GitOps doesn't cancel CI — it cancels "hands in the cluster". The maturity of the setup is measured by whether an incident review ends with "the patch went into git" or "we fixed it by hand, then scattered it around the repo". The first option reproduces; the second doesn't.

AppProject: the boundaries of what an application may do

Without an AppProject any application can deploy anything anywhere. With an AppProject — centralized quotas and bans:

apiVersion: argoproj.io/v1alpha1
kind: AppProject
metadata:
  name: payments
  namespace: argocd
spec:
  destinations:
    - server: https://kubernetes.default.svc
      namespace: payments-{dev,stage,prod}   # their own only
  sourceRepos:
    - "https://gitlab.internal/payments/*"    # their repository only
  clusterResourceWhitelist:
    - group: ""
      kind: Namespace                        # and no cluster-wide CRDs
  namespaceResourceBlacklist:
    - group: ""
      kind: ResourceQuota                    # quotas are created by the platform, not the team

The maturity rule: a team cannot deploy into someone else's namespace, from someone else's repository, or resources outside its area of responsibility — and that whole rule fits in three AppProject fields.

Notifications and the "deploy report"

ArgoCD Notifications answers "did we really deploy?" without opening the UI:

apiVersion: v1
kind: ConfigMap
metadata:
  name: argocd-notifications-cm
data:
  trigger.on-sync-succeeded: |
    - when: app.status.sync.status == "Synced"
      send: [deploy-ok]
  service.webhook.messenger: |
    url: https://messenger.internal/api/v2/hook
  template.deploy-ok: |
    webhook:
      messenger:
        method: POST
        body: |
          {"text": "✅ {{.app.metadata.name}} deployed {{.app.status.sync.revision | slice 0 7 }}"}

The team gets the sync hash in chat — and the "when did the fix ship" questions are closed forever.

How to pull a cluster into GitOps without downtime

  1. Import existing resources: argocd app create --directory over live objects with syncStrategy: dry-run — the comparison changes nothing but records the divergences.
  2. The initial "sponsored" sync: ArgoCD takes over by applying what already lives there — the code must become equal to the fact, not vice versa.
  3. Enabling prune gradually: first drift monitoring only, then selfHeal, and only then prune — so "needed but forgotten in git" doesn't get deleted in one sweep.
  4. The first week is a dedicated divergence dashboard, not trust in the green checkmark: the drift shows what should move into git first.