Skip to main content
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.

Creating Applications

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.

Creating a Git Directory Application

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:
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 Applications

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.

Key Flags for the Sync Command

After syncing, ArgoCD will provide detailed output on the application’s sync status. For example:
This output confirms that the Deployment and Service were successfully applied to your Kubernetes cluster.

Verifying the Deployment

After synchronization, you can verify that the deployed resources are running correctly by using kubectl:
A sample output might be:
This output confirms that a new pod is running and that the service is exposed on a NodePort (31761).

Updating the Application

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.

Conclusion

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: Happy deploying!

Watch Video