ArgoCD CLI

ArgoCD CLI cheatsheet — create apps, sync, rollback, manage projects. argocd app sync myapp, argocd app rollback, argocd login. Full GitOps CLI reference.

8 min read

What it is

The ArgoCD CLI is a command-line interface for interacting with an Argo CD GitOps continuous delivery system, allowing you to manage applications, projects, repositories, and more.

Installation

Linux

# Download the latest release
curl -sSL -o argocd https://github.com/argoproj/argo-cd/releases/latest/download/argocd-linux-amd64

# Make it executable
chmod +x argocd

# Move to your PATH
sudo mv argocd /usr/local/bin/

Mac

# Download the latest release
curl -sSL -o argocd https://github.com/argoproj/argo-cd/releases/latest/download/argocd-darwin-amd64

# Make it executable
chmod +x argocd

# Move to your PATH
sudo mv argocd /usr/local/bin/

Windows

Download the appropriate executable from the Argo CD releases page and place it in a directory that is in your system’s PATH.

Core Concepts

  • Application: A Kubernetes resource managed by Argo CD. It defines how to deploy a set of Kubernetes resources from a Git repository to a target cluster.
  • Project: A logical grouping of Argo CD applications. Projects can define RBAC rules and repository/cluster white/blacklists.
  • Repository: A Git repository that Argo CD monitors for application manifests.
  • Cluster: A Kubernetes cluster that Argo CD can deploy applications to.
  • Sync: The process of reconciling the desired state defined in Git with the actual state in the Kubernetes cluster.
  • Health Status: Indicates whether an application is healthy, progressing, or degraded in the cluster.
  • Sync Status: Indicates whether an application’s state in the cluster matches the state in Git (Synced, OutOfSync, Unknown).

Commands / Usage

Connecting to Argo CD

  • Log in to your Argo CD instance:

    argocd login argocd.example.com
    

    (Prompts for username and password or token)

  • Log in using a username and password:

    argocd login argocd.example.com --username admin --password my-secret-password
    
  • Log in using a token:

    argocd login argocd.example.com --username admin --grpc-web --token eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
    
  • Set the context for future commands:

    argocd context create my-cluster --grpc-web --url argocd.example.com
    argocd context use my-cluster
    

Application Management

  • List all applications:

    argocd app list
    
  • Get details of a specific application:

    argocd app get my-app
    
  • Create an application:

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

    (Creates an application named my-app from a Git repo, path, and destination cluster/namespace)

  • Create an application from a file:

    argocd app create --file my-app-definition.yaml
    
  • Delete an application:

    argocd app delete my-app
    
  • Sync an application (manually trigger reconciliation):

    argocd app sync my-app
    
  • Sync an application with a specific revision (Git commit SHA):

    argocd app sync my-app --revision abc123def456
    
  • Rollback an application to a previous revision:

    argocd app rollback my-app 5 # Rollback to the 5th revision in history
    
  • View application diff (changes between Git and cluster):

    argocd app diff my-app
    
  • View application manifest (rendered Kubernetes manifests):

    argocd app manifest my-app
    
  • View application health and sync status:

    argocd app get my-app
    
  • Set application parameters (e.g., for Helm):

    argocd app set my-app --parameter my-param=my-value --parameter another-param=other-value
    
  • Set the sync policy for an application:

    argocd app set my-app --sync-policy automated
    argocd app set my-app --sync-policy manual
    
  • Set the sync window for an application:

    argocd app set my-app --sync-window '0 0 * * *' # Sync every day at midnight
    
  • Enable/disable pruning for an application:

    argocd app set my-app --auto-prune true
    argocd app set my-app --auto-prune false
    
  • Enable/disable automated sync for an application:

    argocd app set my-app --sync-options CreateNamespace=true
    
  • Get the current live state of an application’s resources:

    argocd app get my-app --live
    
  • Watch an application’s status:

    argocd app wait my-app --health --sync --timeout 300
    

    (Waits for the application to be healthy and synced, with a 5-minute timeout)

  • Get the Argo CD resource name for a Kubernetes resource:

    argocd app get my-app --resource-name my-deployment
    

Repository Management

  • List all Git repositories configured:

    argocd repolist
    
  • Add a Git repository:

    argocd repo add https://github.com/my-org/my-repo.git --username my-git-user --password my-git-password
    
  • Add a SSH Git repository:

    argocd repo add git@github.com:my-org/my-repo.git --ssh-private-key-path ~/.ssh/id_rsa
    
  • Remove a Git repository:

    argocd repo rm https://github.com/my-org/my-repo.git
    

Cluster Management

  • List all Kubernetes clusters configured:

    argocd cluster list
    
  • Add a Kubernetes cluster:

    argocd cluster add-context my-prod-cluster --namespace default
    

    (Adds the current context from your kubeconfig)

  • Add a Kubernetes cluster by URL and token:

    argocd cluster add https://192.168.1.100:6443 --label-with-context=my-cluster --token my-kube-token
    
  • Remove a Kubernetes cluster:

    argocd cluster rm https://192.168.1.100:6443
    

Project Management

  • List all projects:

    argocd proj list
    
  • Create a project:

    argocd proj create my-project \
      --description "My awesome project" \
      --repo https://github.com/my-org/my-repo.git \
      --cluster https://kubernetes.default.svc
    
  • Get details of a project:

    argocd proj get my-project
    
  • Delete a project:

    argocd proj delete my-project
    
  • Add repository access to a project:

    argocd proj add-repo my-project https://github.com/another-org/another-repo.git
    
  • Add cluster access to a project:

    argocd proj add-cluster my-project https://k8s.prod.example.com
    

RBAC and Accounts

  • List all users and groups:

    argocd account list
    
  • Create a new user account:

    argocd account create-user dev-user --password dev-password
    
  • Create an OIDC provider:

    argocd account create-oidc-provider https://accounts.google.com --client-id <your-client-id> --client-secret <your-client-secret>
    
  • List RBAC policies:

    argocd rbac list-policies
    
  • Add an RBAC policy (e.g., grant project admin role):

    argocd rbac create-policy \
      'g, my-team, role:admin, proj:my-project'
    
  • List RBAC roles:

    argocd rbac list-roles
    

Settings and Configuration

  • Get Argo CD settings:

    argocd settings list
    
  • Set Argo CD settings:

    argocd settings set auto-heal=true
    

Version and Health

  • Get the Argo CD CLI version:

    argocd version
    
  • Check the health of the Argo CD instance:

    argocd-server --healthz
    

    (This command is typically run against the Argo CD server directly, not via the CLI after connection)

Common Patterns

  • Get the current Git commit SHA of an application:

    argocd app get my-app --output yaml | grep 'source.repoURL' -A 2 | grep 'targetRevision' | awk '{print $2}'
    
  • Get the health and sync status of all applications in a project:

    argocd app list --project my-project -o wide
    
  • Manually sync all applications that are out of sync:

    argocd app list --output json | jq -c '.items[] | select(.status.sync.status != "Synced") | .metadata.name' | xargs -I {} argocd app sync {}
    
  • Generate a Kustomize overlay with specific parameters and apply it:

    # Assume your Argo CD app uses Kustomize and you want to override values
    argocd app set my-kustomize-app \
      --kustomize-image my-app=my-docker-registry/my-app:v1.2.3 \
      --kustomize-namespace production
    argocd app sync my-kustomize-app
    
  • View the live Kubernetes resources for an application:

    argocd app get my-app --live -o yaml
    
  • Stream Argo CD application events:

    argocd app get my-app --stream
    
  • Get the Argo CD server URL:

    argocd cluster get kubernetes.default.svc --output json | jq -r '.config.server'
    

Gotchas

  • Authentication: When logging in, ensure you are using the correct credentials or token. If using SSO/OIDC, the login flow might differ. The --grpc-web flag is often necessary for browser-based authentication flows.
  • Context vs. Server: argocd login connects to a specific Argo CD server. argocd cluster add-context adds Kubernetes clusters to Argo CD’s known clusters. argocd context manages CLI connections to different Argo CD servers.
  • RBAC Permissions: Commands that modify Argo CD resources (like app create, repo add, proj delete) require appropriate RBAC permissions within Argo CD itself.
  • Application Definitions: When creating applications, ensure the --repo, --path, --dest-server, and --dest-namespace flags correctly point to your Git repository and target Kubernetes environment.
  • Sync Status vs. Health Status: An application can be Synced but not Healthy (e.g., a Deployment is at the correct revision but pods are failing). Conversely, an application can be OutOfSync but still Healthy.
  • Resource IDs: Argo CD uses a specific format for resource IDs (e.g., apps/v1,Kind=Deployment,my-deployment,default). The CLI might sometimes require these specific IDs, especially for operations on individual resources.
  • argocd-server vs. argocd CLI: Some commands, like health checks, are inherently tied to the argocd-server process itself and might not be directly callable via the CLI after connecting. They are usually accessed via the API or by querying the argocd-server pod directly.