A quick reference for ArgoCD โ GitOps continuous delivery for Kubernetes. Bookmark this page.
CLI Setup
# Install ArgoCD CLI
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/
# Login
argocd login argocd.example.com
argocd login argocd.example.com --grpc-web # If gRPC blocked
# Get admin password (initial)
kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -dApplication Management
# Create an application
argocd app create my-app \
--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
# List applications
argocd app list
argocd app list -o wide
# Get application details
argocd app get my-app
argocd app get my-app --hard-refresh # Force manifest refresh
# Sync (deploy)
argocd app sync my-app
argocd app sync my-app --prune # Remove deleted resources
argocd app sync my-app --force # Force sync
argocd app sync my-app --dry-run # Preview changes
# Delete application
argocd app delete my-app
argocd app delete my-app --cascade # Delete app resources tooApplication YAML
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: my-app
namespace: argocd
spec:
project: default
source:
repoURL: https://github.com/org/repo.git
targetRevision: main
path: k8s/overlays/production
destination:
server: https://kubernetes.default.svc
namespace: production
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=true
- ApplyOutOfSyncOnly=true
retry:
limit: 5
backoff:
duration: 5s
maxDuration: 3mProjects
# List projects
argocd proj list
# Create project with restrictions
argocd proj create team-a \
--src https://github.com/org/* \
--dest https://kubernetes.default.svc,team-a-* \
--allow-cluster-resource Namespace
# Add allowed namespace
argocd proj add-destination team-a https://kubernetes.default.svc team-a-stagingCluster and Repo Management
# Add external cluster
argocd cluster add my-cluster-context
# List clusters
argocd cluster list
# Add private repo
argocd repo add https://github.com/org/private-repo.git --username git --password $TOKEN
# Add Helm repo
argocd repo add https://charts.bitnami.com/bitnami --type helm --name bitnamiTroubleshooting
# View application logs
argocd app logs my-app
# View sync history
argocd app history my-app
# View resource tree
argocd app resources my-app
# Diff between desired and live state
argocd app diff my-app
# Refresh application (re-read Git)
argocd app get my-app --refresh
argocd app get my-app --hard-refresh # Clear cacheTips and Tricks
- Use ApplicationSets for multi-cluster/multi-env deployments
- Enable
selfHeal: trueto auto-correct manual changes - Use
ignoreDifferencesfor fields managed by controllers - Set resource hooks for pre/post-sync jobs
- Use
argocd app wait my-appin CI/CD to wait for healthy state