ArgoCD

GitOps continuous delivery for Kubernetes - sync apps from Git, auto-heal, declarative deployments

TL;DR

What: Declarative GitOps continuous delivery tool for Kubernetes.

Why: Git as single source of truth, automatic sync, visual dashboard, multi-cluster support.

Quick Start

Install in Kubernetes:

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

# Wait for pods
kubectl wait --for=condition=Ready pods --all -n argocd --timeout=300s

Install CLI:

# macOS
brew install argocd

# Linux
curl -sSL -o argocd https://github.com/argoproj/argo-cd/releases/latest/download/argocd-linux-amd64
chmod +x argocd && sudo mv argocd /usr/local/bin/

Access UI:

# Port forward
kubectl port-forward svc/argocd-server -n argocd 8080:443

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

# Login (user: admin)
argocd login localhost:8080

Cheatsheet

CommandDescription
argocd app listList applications
argocd app createCreate application
argocd app sync nameSync application
argocd app get nameGet app details
argocd app delete nameDelete application
argocd cluster add ctxAdd cluster
argocd repo add urlAdd Git repo

Gotchas

Application manifest

# application.yaml
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: my-app
  namespace: argocd
spec:
  project: default
  source:
    repoURL: https://github.com/user/repo.git
    targetRevision: HEAD
    path: k8s
  destination:
    server: https://kubernetes.default.svc
    namespace: my-app
  syncPolicy:
    automated:
      prune: true
      selfHeal: true
    syncOptions:
      - CreateNamespace=true

Create app via CLI

argocd app create my-app \
  --repo https://github.com/user/repo.git \
  --path k8s \
  --dest-server https://kubernetes.default.svc \
  --dest-namespace my-app \
  --sync-policy automated

Helm application

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: nginx
  namespace: argocd
spec:
  source:
    repoURL: https://charts.bitnami.com/bitnami
    chart: nginx
    targetRevision: 15.0.0
    helm:
      values: |
        replicaCount: 2
        service:
          type: LoadBalancer
  destination:
    server: https://kubernetes.default.svc
    namespace: nginx

Kustomize application

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: my-app
  namespace: argocd
spec:
  source:
    repoURL: https://github.com/user/repo.git
    path: overlays/production
    targetRevision: main
    kustomize:
      images:
        - myapp=myrepo/myapp:v2
  destination:
    server: https://kubernetes.default.svc
    namespace: production

Sync operations

# Manual sync
argocd app sync my-app

# Sync with prune
argocd app sync my-app --prune

# Force sync (replace)
argocd app sync my-app --force

# Rollback
argocd app rollback my-app

Next Steps