Ask me anything
Ithy Logo
Sign in to save

Mastering Argo CD: Your Essential CLI Command Guide

Unlock the power of GitOps on Kubernetes with these crucial Argo CD command-line tools for efficient application management.

important-argocd-cli-commands-smpsjj2o

Argo CD streamlines Kubernetes application deployment and lifecycle management using GitOps principles. Its command-line interface (CLI), invoked with the argocd command, is a powerful tool for interacting with your Argo CD instance, managing applications, repositories, clusters, and more directly from your terminal. Understanding these commands is key to leveraging Argo CD effectively.


Key Takeaways: Argo CD CLI Essentials

  • Comprehensive Management: The argocd CLI provides commands to manage the full lifecycle of applications, clusters, repositories, and projects within your GitOps workflow.
  • Declarative Control: Commands like app create, app sync, and app diff allow you to define, synchronize, and inspect application states based on configurations stored in Git.
  • Automation & Integration: The CLI is crucial for scripting automation tasks and integrating Argo CD into broader CI/CD pipelines, enhancing efficiency and reliability.

Understanding the Argo CD CLI

Argo CD operates by continuously monitoring running applications and comparing their live state against the desired target state defined in a Git repository. The CLI acts as your primary interface for instructing Argo CD, performing administrative tasks, and gaining insights into your deployments.

Argo CD Architecture Diagram

Conceptual overview of Argo CD's GitOps workflow.

Core Command Structure

Most interactions follow the pattern argocd <noun> <verb> [flags]. For example, argocd app list uses the noun app and the verb list.

  • Nouns: Represent objects Argo CD manages (e.g., app, cluster, repo, proj, account).
  • Verbs: Specify the action to perform (e.g., create, list, get, sync, delete, add, rm).
  • Flags: Modify command behavior (e.g., --output yaml, --force, --selector). Use --help on any command or subcommand for specific options.

Essential Argo CD Commands by Category

Here’s a breakdown of the most important argocd commands, grouped by their function:

1. Connection & Authentication

argocd login

Authenticates the CLI with your Argo CD server instance. This is the first step for most interactions.

  • Usage: argocd login <ARGOCD_SERVER> [--username <USER>] [--password <PASS>] [--sso]
  • Key Flags: --sso for Single Sign-On, --insecure to skip TLS verification (use cautiously).

argocd logout

Logs out from the current Argo CD server.

  • Usage: argocd logout <ARGOCD_SERVER>

argocd context

Manages different Argo CD server contexts, useful if you interact with multiple Argo CD instances.

  • Usage: argocd context [create|switch|delete] <NAME>

2. Application Management (argocd app)

These commands are central to managing the deployment and lifecycle of your applications.

argocd app list

Lists all applications managed by Argo CD.

  • Usage: argocd app list [flags]
  • Key Flags: -l, --selector to filter by labels, -o, --output (e.g., yaml, json, wide).

argocd app create

Registers a new application with Argo CD based on repository details.

  • Usage: argocd app create <APP_NAME> --repo <REPO_URL> --path <PATH_IN_REPO> --dest-server <CLUSTER_URL> --dest-namespace <NAMESPACE> [flags]

argocd app get

Displays detailed information about a specific application, including sync status, health, and resources.

  • Usage: argocd app get <APP_NAME> [flags]

argocd app sync

Manually triggers a synchronization of the application's live state to match the desired state defined in Git.

  • Usage: argocd app sync <APP_NAME> [flags]
  • Key Flags: --revision to sync to a specific commit/tag, --force to bypass certain safety checks, --prune to delete resources not defined in Git.

argocd app diff

Shows the differences (diff) between the live state in the cluster and the desired state in Git.

  • Usage: argocd app diff <APP_NAME> [flags]

argocd app history

Displays the deployment history for an application, showing past sync operations and revisions.

  • Usage: argocd app history <APP_NAME>

argocd app rollback

Rolls back an application to a previous successfully deployed state based on its history.

  • Usage: argocd app rollback <APP_NAME> [HISTORY_ID]
  • Key Flags: --to-revision to rollback to a specific revision instead of using history ID.

argocd app delete

Removes an application from Argo CD management and optionally deletes its resources from the cluster.

  • Usage: argocd app delete <APP_NAME> [flags]
  • Key Flags: --cascade=false to only remove the AppProject definition without deleting resources.

argocd app wait

Waits for an application to reach a specific health and sync status (e.g., Synced and Healthy).

  • Usage: argocd app wait <APP_NAME> [flags]

3. Cluster Management (argocd cluster)

Manages the Kubernetes clusters where Argo CD deploys applications.

argocd cluster add

Registers a new Kubernetes cluster with Argo CD using a kubeconfig context.

  • Usage: argocd cluster add <CONTEXT_NAME> [flags]

argocd cluster list

Lists all Kubernetes clusters known to Argo CD.

  • Usage: argocd cluster list

argocd cluster get

Shows details about a specific connected cluster.

  • Usage: argocd cluster get <SERVER_URL_OR_NAME>

argocd cluster rm

Removes a cluster's credentials from Argo CD.

  • Usage: argocd cluster rm <SERVER_URL_OR_NAME>

4. Project Management (argocd proj)

Projects provide logical grouping and control policies (RBAC, allowed destinations/sources) for applications.

argocd proj list

Lists all configured projects.

  • Usage: argocd proj list

argocd proj create

Creates a new project with specified policies.

  • Usage: argocd proj create <PROJECT_NAME> [flags]
  • Key Flags: --description, --src (allowed source repo), --dest (allowed destination cluster/namespace).

argocd proj get

Displays detailed information about a specific project.

  • Usage: argocd proj get <PROJECT_NAME>

argocd proj delete

Deletes a project.

  • Usage: argocd proj delete <PROJECT_NAME>

argocd proj role

Manages RBAC roles within a project.

  • Usage: argocd proj role [create|delete|add-policy|remove-policy] <PROJECT_NAME> <ROLE_NAME> [flags]

5. Repository Management (argocd repo)

Manages the Git or Helm repositories that contain your application manifests.

argocd repo add

Adds a Git or Helm repository to Argo CD's list of allowed sources.

  • Usage: argocd repo add <REPO_URL> [--username <USER>] [--password <PASS>] [--ssh-private-key-path <PATH>] [--type git|helm]

argocd repo list

Lists all repositories configured in Argo CD.

  • Usage: argocd repo list

argocd repo rm

Removes a repository from Argo CD.

  • Usage: argocd repo rm <REPO_URL>

6. Account and Admin Commands

argocd account update-password

Allows the currently logged-in user to change their password.

  • Usage: argocd account update-password

argocd admin

Provides subcommands for administrative tasks, often requiring cluster-level access.

  • Examples: argocd admin initial-password (retrieve initial admin password), argocd admin settings (manage system settings), argocd admin dashboard (open the web UI).

7. General Utility

argocd version

Displays the version of the Argo CD CLI client and the connected Argo CD server.

  • Usage: argocd version

argocd help

Shows help information for argocd or any subcommand.

  • Usage: argocd help or argocd <command> --help

Visualizing Command Importance

While all command categories are important, their frequency of use can vary depending on your role and workflow. This chart provides a relative view of how often different command groups might be used in typical Argo CD operations.

This chart highlights that application management commands (app list, app sync, app get, app diff) are generally used most frequently, especially in day-to-day operations and automation scripts. Authentication is crucial but less frequent after initial setup. Cluster, project, and repository management are important for setup and changes but used less often daily.


Argo CD Command Structure Mindmap

This mindmap provides a visual overview of the main command groups and some key subcommands within the argocd CLI structure.

mindmap root["argocd CLI"] id1["Authentication"] id1a["login"] id1b["logout"] id1c["context"] id2["Application Mgmt (app)"] id2a["list"] id2b["create"] id2c["get"] id2d["sync"] id2e["diff"] id2f["rollback"] id2g["history"] id2h["delete"] id2i["wait"] id3["Cluster Mgmt (cluster)"] id3a["add"] id3b["list"] id3c["get"] id3d["rm"] id4["Project Mgmt (proj)"] id4a["list"] id4b["create"] id4c["get"] id4d["delete"] id4e["role"] id5["Repository Mgmt (repo)"] id5a["add"] id5b["list"] id5c["rm"] id6["Account Mgmt (account)"] id6a["update-password"] id7["Admin Tasks (admin)"] id7a["initial-password"] id7b["settings"] id7c["dashboard"] id8["Utility"] id8a["version"] id8b["help"]

Example CLI Workflow

Here's a typical sequence of commands you might use to deploy and manage an application:

# 1. Log in to your Argo CD server
argocd login my-argocd-server.example.com --username admin --password $ARGO_PASSWORD

# 2. (If needed) Add the target Kubernetes cluster
# Replace 'my-k8s-context' with your actual kubeconfig context name
argocd cluster add my-k8s-context

# 3. Add the Git repository containing your application manifests
argocd repo add https://github.com/my-org/my-app-repo.git --username gituser --password $GIT_PASSWORD

# 4. Create the application definition in Argo CD
argocd app create my-guestbook-app \
  --repo https://github.com/my-org/my-app-repo.git \
  --path guestbook \
  --dest-server https://kubernetes.default.svc \
  --dest-namespace guestbook-prod \
  --project default \
  --sync-policy automated # Optionally enable auto-sync

# 5. Check the application's status
argocd app get my-guestbook-app

# 6. Manually sync the application (if auto-sync is not enabled or immediate sync needed)
argocd app sync my-guestbook-app

# 7. List all applications to see the new one
argocd app list

# 8. Check for configuration drift
argocd app diff my-guestbook-app

# 9. If something goes wrong, check history and rollback
# argocd app history my-guestbook-app
# argocd app rollback my-guestbook-app <HISTORY_ID>

# 10. Log out when finished
argocd logout my-argocd-server.example.com

Video Guide: Argo CD CLI Introduction

For a visual walkthrough of installing the Argo CD CLI and using some basic commands, check out this helpful video:

This video provides a practical demonstration covering CLI installation and foundational commands, complementing the text-based information provided here.


Command Category Summary

This table summarizes the primary purpose of the main Argo CD CLI command categories:

Command Category Primary Function Key Commands
Authentication & Context Connect to Argo CD server(s) and manage sessions. login, logout, context
Application Management (app) Manage the lifecycle of deployed applications (create, sync, view, delete, rollback). list, create, get, sync, diff, history, rollback, delete
Cluster Management (cluster) Manage Kubernetes clusters as deployment targets. add, list, get, rm
Project Management (proj) Organize applications and manage access control policies. list, create, get, delete, role
Repository Management (repo) Manage source Git/Helm repositories. add, list, rm
Account Management (account) Manage user account settings (e.g., password). update-password
Administration (admin) Perform server-level administrative tasks. initial-password, settings, dashboard
Utility General helper commands. version, help

Frequently Asked Questions (FAQ)

How do I log in using Single Sign-On (SSO)?

Use the --sso flag with the argocd login command. By default, it will attempt to launch a browser for authentication with your configured identity provider.

argocd login <ARGOCD_SERVER> --sso

You might need specific flags like --sso-port if the default redirect port (8085) is unavailable, or --sso-launch-browser=false if you need to manually open the URL provided in the terminal.

What is the difference between `argocd app sync` and `argocd app rollback`?

`argocd app sync` synchronizes the application to the state defined in the target revision (usually the latest commit in the tracked branch/tag in Git). It applies the desired state.

`argocd app rollback` reverts the application to a previous, successfully deployed revision recorded in the application's deployment history. It's used to quickly undo a problematic deployment.

How can I see the differences between my live application state and the Git configuration?

Use the `argocd app diff` command. It compares the manifests generated from the target Git revision with the actual resources running in the cluster.

argocd app diff <APP_NAME>

This helps identify configuration drift or pending changes before performing a sync.

How do I add a private Git repository?

Use the `argocd repo add` command with appropriate authentication flags. For HTTPS repositories, use `--username` and `--password`. For SSH repositories, use `--ssh-private-key-path` pointing to the private key file.

# HTTPS Example
argocd repo add https://github.com/my-private-org/my-private-repo.git --username myuser --password $MY_GIT_PAT

# SSH Example
argocd repo add git@github.com:my-private-org/my-private-repo.git --ssh-private-key-path ~/.ssh/id_rsa

Ensure the Argo CD server has network access to the repository.


Recommended Further Exploration


References

enbuild-docs.vivplatform.io
ArgoCD | ENBUILD
argo-cd.readthedocs.io
argocd Command Reference

Last updated May 4, 2025

AI-assisted research. Sources, methodology and corrections · Source-checked guides and tools · Explore published answers

Ask Ithy AI