This guide explains how to create, synchronize, and verify an ArgoCD application using the command-line interface.
In this guide, you will learn how to create, synchronize, and verify an ArgoCD application using the command-line interface (CLI). Previously, we explored creating and deleting applications via the UI. Now, we’ll delve into performing these tasks with the CLI for a more automated and scriptable approach.
You can create an ArgoCD application with the argocd app create command. This command supports various configuration options, allowing you to deploy applications managed as Git directory-based manifests, Jsonnet, Helm (from both Git and Helm repositories), Kustomize, or even using a custom configuration management plugin.Below are examples for different application types:
In these examples, you provide the application name, repository URL, path to your manifest files within the repository, destination namespace, and target server details.
Next, create a Git directory application named “solar-system-app-2”. This command specifies all required parameters, including the repository URL, the path to the application manifests, destination namespace, and the Kubernetes API server.
After creating the application, list all applications to verify its creation:
Copy
Ask AI
argocd app list
Once executed, the output will include the new application with details about its repository, destination namespace, and target server. Initially, the status may appear as “OutOfSync”.
Synchronizing your application with its repository is simple with the argocd app sync command. This command handles syncing for individual applications, multiple applications, or even resources filtered by label selectors.
Copy
Ask AI
# Sync a single applicationargocd app sync solar-system-app-2# Sync multiple applications at onceargocd app sync my-app other-app# Sync applications by label (helpful for app-of-apps scenarios)argocd app sync -l app.kubernetes.io/instance=my-app# Sync a specific resource within an applicationargocd app sync my-app --resource :Service:my-serviceargocd app sync my-app --resource argoproj.io:Rollout:my-rolloutargocd app sync my-app --resource argoproj.io:Rollout:my-namespace/my-rollout
When you update your application (for example, by switching to a new Docker image version), you can inspect the updated Deployment manifest. Below is an example manifest that uses an updated image version (“vi”), ensuring that all nine planets are displayed in the solar system view:
After updating the manifest, synchronize the application using the CLI. Once applied, accessing the application via the designated NodePort should display all nine planets of the solar system.
This article demonstrated how to manage ArgoCD applications using the CLI. The guide included creating applications using various configuration management tools, synchronizing those applications, and verifying their deployments within a Kubernetes cluster. This CLI-based approach provides a flexible, efficient alternative to managing GitOps workflows via the UI.For further details and related guides, explore the following resources: