How to use the command `argocd` (with examples)
The argocd
command-line interface is used to control an Argo CD server. It provides various subcommands, such as argocd app
, which have their own usage documentation. This article will showcase two common use cases of the argocd
command, including logging in to the Argo CD server and listing applications.
Use case 1: Login to Argo CD server
Code:
argocd login --insecure --username user --password password argocd_server:port
Motivation: The argocd login
command is used to authenticate and establish a session with the Argo CD server. By logging in, you gain access to the server’s resources and can perform various actions.
Explanation:
--insecure
: This flag is used to disable SSL certificate verification. It is commonly used in development environments where self-signed certificates are used.--username user
: This option specifies the username to be used for authentication.--password password
: This option specifies the password corresponding to the provided username.argocd_server:port
: This argument specifies the address and port of the Argo CD server.
Example output:
INFO[0000] 'user' logged in successfully
Use case 2: List applications
Code:
argocd app list
Motivation: The argocd app list
command allows you to retrieve a list of applications managed by the Argo CD server. This is useful to get an overview of the deployed applications and their current states.
Explanation: The argocd app list
command does not require any additional arguments or options. It simply fetches the list of applications from the Argo CD server and displays them in the console.
Example output:
NAME CLUSTER NAMESPACE PROJECT STATUS HEALTH SYNCPOLICY
my-app my-cluster default my-project Synced Healthy Auto
another-app my-cluster default another-project Synced Healthy Manual
Conclusion:
The argocd
command-line interface provides a convenient way to control an Argo CD server. By using the argocd login
command, you can authenticate and establish a session with the server. Furthermore, the argocd app list
command allows you to retrieve a list of applications managed by the server. With these functionalities, you can effectively manage and monitor your applications deployed through Argo CD.