GitOps workflows with ArgoCD for Kubernetes deployments
GitOps workflows for Kubernetes deployments using ArgoCD.
Use this skill when:
# Login to ArgoCD server
argocd login argocd.example.com
# With SSO
argocd login argocd.example.com --sso
# Skip TLS verification (dev only)
argocd login argocd.example.com --insecure
# Check current context
argocd context
# All applications
argocd app list
# With output format
argocd app list -o wide
argocd app list -o json
# Filter by project
argocd app list -p myproject
# Filter by label
argocd app list -l team=backend
# Application details
argocd app get myapp
# Manifests
argocd app manifests myapp
# Diff against live
argocd app diff myapp
# History
argocd app history myapp
# Check status
argocd app get myapp -o json | jq '.status.health.status'
# Resources status
argocd app resources myapp
# Events
argocd app logs myapp
# Sync (apply Git state to cluster)
argocd app sync myapp
# Sync with prune (remove deleted resources)
argocd app sync myapp --prune
# Sync specific resources
argocd app sync myapp --resource :Deployment:myapp
# Dry run
argocd app sync myapp --dry-run
# Force sync (bypass hooks)
argocd app sync myapp --force
# Wait for sync completion
argocd app wait myapp
# Skip schema validation
argocd app sync myapp --validate=false
# Apply out-of-sync only
argocd app sync myapp --apply-out-of-sync-only
# Sync with timeout
argocd app sync myapp --timeout 300
# Enable auto-sync
argocd app set myapp --sync-policy automated
# With prune
argocd app set myapp --sync-policy automated --auto-prune
# Self-heal (revert manual changes)
argocd app set myapp --self-heal
# Disable auto-sync
argocd app set myapp --sync-policy none
# View history
argocd app history myapp
# Rollback to specific revision
argocd app rollback myapp <history-id>
# Rollback to previous Git commit
argocd app rollback myapp --revision HEAD~1
# 1. Rollback ArgoCD history
argocd app history myapp
argocd app rollback myapp 5
# 2. Revert Git commit and sync
git revert HEAD
git push
argocd app sync myapp
# 3. Manual override then rollback
argocd app set myapp --revision <old-commit>
argocd app sync myapp
# 1. Deploy to dev (auto-sync)
git commit -m "feat: new feature"
git push origin main
# ArgoCD auto-syncs dev
# 2. Promote to staging
argocd app set myapp-staging --revision $(argocd app get myapp-dev -o json | jq -r '.status.sync.revision')
argocd app sync myapp-staging
# 3. Promote to production (manual)
argocd app set myapp-prod --revision <staging-revision>
argocd app sync myapp-prod
# Set Helm values per environment
argocd app set myapp-prod --values-literal-file values-prod.yaml
# Set Kustomize overlay
argocd app set myapp-staging --kustomize-image nginx=nginx:1.25
argocd app create myapp \
--repo https://github.com/org/repo.git \
--path k8s/overlays/production \
--dest-server https://kubernetes.default.svc \
--dest-namespace production \
--project default
# With Helm
argocd app create myapp \
--repo https://github.com/org/repo.git \
--path charts/myapp \
--dest-server https://kubernetes.default.svc \
--dest-namespace production \
--helm-set image.tag=v1.2.3
argocd app create myapp \
--repo https://charts.example.com \
--helm-chart myapp \
--revision 1.2.3 \
--dest-server https://kubernetes.default.svc \
--dest-namespace production
# Check sync status
argocd app get myapp
# View sync errors
argocd app get myapp -o json | jq '.status.conditions'
# Check resource status
argocd app resources myapp
# View logs
argocd app logs myapp
| Issue | Cause | Fix |
|---|---|---|
| OutOfSync | Drift from Git | argocd app sync myapp |
| SyncFailed | Invalid manifests | Check argocd app get myapp |
| Degraded | Pods unhealthy | Check pod logs |
| Unknown | Can't reach cluster | Check network/auth |
# Refresh from Git
argocd app get myapp --refresh
# Hard refresh (invalidate cache)
argocd app get myapp --hard-refresh
# Terminate current sync
argocd app terminate-op myapp
# Force sync
argocd app sync myapp --force
# List projects
argocd proj list
# Create project
argocd proj create myproject \
--src https://github.com/org/* \
--dest https://kubernetes.default.svc,production
# View project
argocd proj get myproject
# List clusters
argocd cluster list
# Add cluster
argocd cluster add my-context
# Remove cluster
argocd cluster rm https://cluster.example.com
# Get app health for CI/CD
argocd app wait myapp --health --timeout 300
# Exit code for scripting
argocd app get myapp -o json | jq -e '.status.health.status == "Healthy"'
# Deploy new version
argocd app set myapp --revision <commit-sha>
argocd app sync myapp --prune
# Check if healthy
argocd app wait myapp --health
# Quick rollback
argocd app history myapp
argocd app rollback myapp <id>
# Force refresh from Git
argocd app get myapp --hard-refresh
argocd app sync myapp