Skip to main content

How to set up GitOps continuous delivery with Argo CD

Argo CD implements GitOps by reconciling the cluster to manifests in Git. Install it, define an Application pointing at a repo path, enable automated prune and self-heal, and watch drift correct itself.

Difficulty
Intermediate
Duration
45 minutes
Steps
6

GitOps continuous delivery with Argo CD

GitOps treats a Git repository as the single source of truth for cluster state. Argo CD continuously compares the live cluster to the manifests in Git and reconciles any difference. Deployments become Git commits, and the cluster self-heals back to the declared state.

Prerequisites

  • A Kubernetes cluster and kubectl access.
  • A Git repository containing Kubernetes manifests, Kustomize, or Helm.

Steps

1. Install Argo CD

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

2. Access the Argo CD API

kubectl -n argocd port-forward svc/argocd-server 8080:443
kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath='{.data.password}' | base64 -d

Log in with the CLI or web UI as admin.

3. Structure the Git repo

Keep environment manifests in clear paths, for example apps/myapp/overlays/prod. Argo CD will watch a path and revision.

4. Create an Application

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: myapp
  namespace: argocd
spec:
  project: default
  source:
    repoURL: https://github.com/org/repo
    targetRevision: main
    path: apps/myapp/overlays/prod
  destination:
    server: https://kubernetes.default.svc
    namespace: prod

5. Enable automated sync

  syncPolicy:
    automated:
      prune: true
      selfHeal: true

prune removes objects deleted from Git; selfHeal reverts manual cluster edits.

6. Observe drift and self-heal

Edit a live resource with kubectl and watch Argo CD mark the app OutOfSync, then revert it. Commits to Git trigger automatic syncs.

Verification

Confirm the Application shows Synced and Healthy in the UI or via argocd app get myapp. Make a manual change to a managed resource and confirm Argo CD reverts it. Push a manifest change to Git and confirm the cluster updates automatically.

Next Steps

Adopt the app-of-apps pattern to manage many applications, integrate with Kustomize or Helm sources, add sync waves and hooks for ordered rollouts, and protect production with manual sync approvals and RBAC.

Prerequisites

  • A Kubernetes cluster
  • A Git repo with manifests
  • kubectl access

Steps

  • 1
    Install Argo CD
  • 2
    Access the Argo CD API
  • 3
    Structure the Git repo
  • 4
    Create an Application
  • 5
    Enable automated sync
  • 6
    Observe drift and self-heal

Category

DevOps