GitOps Delivery with Argo CD

Repository layout, sync policies, drift handling and secret management for a Kubernetes delivery pipeline that stays auditable.

Published May 5, 202610 min read4 views
  • automation
  • ci-cd
  • iac
  • kubernetes

The contract

Git holds the desired state; a controller reconciles the cluster towards it. CI builds and pushes artefacts and opens a change to the manifests — CI never talks to the cluster.

Repository layout

text
platform/
  apps/
    payments/
      base/
        deployment.yaml
        service.yaml
        kustomization.yaml
      overlays/
        staging/kustomization.yaml
        prod/kustomization.yaml
  argocd/
    projects/payments.yaml
    applications/payments-prod.yaml

An Application with sensible sync policy

YAML
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: payments-prod
  namespace: argocd
spec:
  project: payments
  source:
    repoURL: [email protected]:acme/platform.git
    targetRevision: main
    path: apps/payments/overlays/prod
  destination:
    server: https://kubernetes.default.svc
    namespace: payments
  syncPolicy:
    automated: { prune: true, selfHeal: true }
    syncOptions: [CreateNamespace=true, PrunePropagationPolicy=foreground]
    retry:
      limit: 5
      backoff: { duration: 10s, factor: 2, maxDuration: 3m }

Secrets

Plain Secret manifests do not belong in Git. Use Sealed Secrets or the External Secrets Operator so the repository holds a reference or a ciphertext, never a credential.

Promotion

  1. CI builds the image and pushes it by digest.

  2. An automated commit updates the staging overlay.

  3. Argo CD syncs staging; smoke tests run against it.

  4. A human opens a pull request promoting the same digest to prod.

What to alert on

  • Application health degraded for more than five minutes.

  • OutOfSync with automated sync enabled — the controller is failing.

  • Repeated sync retries, which usually means an admission webhook is rejecting the manifest.

Back to all docs