Skip to content

ArgoCD — Commands & Recipes

Installation

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

# Install CLI
curl -sSL -o argocd-linux-amd64 https://github.com/argoproj/argo-cd/releases/latest/download/argocd-linux-amd64
sudo install -m 555 argocd-linux-amd64 /usr/local/bin/argocd

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

# Login
argocd login localhost:8080

Application Management

# Create application
argocd app create myapp \
  --repo https://github.com/org/repo.git \
  --path k8s/overlays/production \
  --dest-server https://kubernetes.default.svc \
  --dest-namespace production \
  --sync-policy automated \
  --auto-prune --self-heal

# Sync (manual)
argocd app sync myapp

# Sync with specific revision
argocd app sync myapp --revision feature-branch

# View app status
argocd app get myapp
argocd app diff myapp

# Rollback
argocd app rollback myapp <history-id>

# Delete (with PreDelete hooks)
argocd app delete myapp --cascade

Multi-Cluster

# Add target cluster
argocd cluster add my-context --name production-cluster

# List clusters
argocd cluster list

ApplicationSet

# Deploy to all clusters from monorepo directories
apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
  name: cluster-addons
  namespace: argocd
spec:
  generators:
    - matrix:
        generators:
          - clusters: {}
          - git:
              repoURL: https://github.com/org/infra.git
              revision: HEAD
              directories:
                - path: addons/*
  template:
    metadata:
      name: "{{name}}-{{path.basename}}"
    spec:
      project: default
      source:
        repoURL: https://github.com/org/infra.git
        targetRevision: HEAD
        path: "{{path}}"
      destination:
        server: "{{server}}"
        namespace: "{{path.basename}}"
      syncPolicy:
        automated:
          prune: true
          selfHeal: true

Sources