Learning Argo CD? 3 Examples to Get You Started

What Is Argo CD?

Argo CD is a declarative, GitOps continuous delivery tool for Kubernetes. It automates the deployment of desired application states to Kubernetes, defined in Git repositories. By continuously monitoring Git repositories, Argo CD ensures that the live state of Kubernetes clusters matches the desired state declared in Git. 

Argo CD enables consistent, auditable, and automated deployments, aligning with the principles of GitOps for managing Kubernetes resources.

In this article, after explaining the basics of Argo CD, we’ll show three detailed examples that can help you get started with this versatile tool:

  1. Deploying Argo CD on Kubernetes for the first time.
  2. Installing a Kustomize Application on your Kubernetes cluster with Argo CD.
  3. Install a Helm Application with Argo CD via the convenient Argo UI.

How Argo CD Works 

Argo CD uses Git as the source of truth for defining the desired state of applications and Kubernetes configurations. Here’s a step-by-step overview of its workflow:

Configuration

In the initial configuration phase, developers create and store application configurations in a Git repository. These configurations can include Kubernetes manifests, Helm charts, or Kustomize configurations. This approach leverages Git’s version control capabilities to maintain a single source of truth for the desired state of applications and their Kubernetes environments. 

By defining these configurations declaratively, developers ensure consistency and reproducibility in application deployment and management, allowing for straightforward tracking and rollback of changes.

Repository Monitoring

Argo CD continuously monitors the specified Git repositories to detect any changes in the application configurations. This monitoring is automated and persistent, ensuring that the system is always aware of the current state of the repository. 

By keeping track of the repository, Argo CD can promptly identify updates or modifications, which is crucial for maintaining synchronization between the Git-defined desired state and the actual state of the Kubernetes cluster.

Synchronization

When Argo CD detects changes in the Git repository, it triggers a synchronization process to align the live state of the Kubernetes cluster with the desired state defined in Git. This involves applying the updated Kubernetes manifests, Helm charts, or Kustomize configurations to the cluster. 

The synchronization process ensures that any modifications are correctly implemented, maintaining the desired state as specified by the developers. This mechanism is important for achieving continuous delivery and deployment, as it automates the application of changes to the cluster.

Application Management

Users have multiple options for managing and visualizing applications through Argo CD. The platform provides a web UI, CLI, and API, enabling users to interact with their applications in a way that best suits their workflow. 

Through these interfaces, users can manually trigger synchronization processes, perform rollbacks, and manage applications across multiple clusters. The comprehensive management capabilities of Argo CD enable flexibility and control over application deployments and lifecycle management.

Health Monitoring

Argo CD includes accurate health monitoring features that offer real-time status updates and health assessments of managed applications. This functionality is useful for ensuring that any deviations from the desired state are promptly identified and addressed. 

By continuously assessing the health of applications, Argo CD helps maintain operational stability and performance, automatically correcting any detected drift to keep the system in line with the defined configurations. This proactive monitoring contributes to the reliability and resilience of applications running in Kubernetes environments.

Related content: Read our guide to Argo Kubernetes

Understanding Argo CD with Examples 

Let’s look at some of the ways to use Argo CD.

1. Deploying Argo CD on Kubernetes

To deploy Argo CD on a Kubernetes cluster, follow these steps:

  1. You first need to create a namespace for Argo CD and then apply the Argo CD installation manifest:
kubectl create namespace argocd
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml

The first command creates a namespace named argocd, and the second command installs Argo CD using the provided manifest file.

  1. You can interact with Argo CD via its web UI or CLI. To install the CLI, use the following command:
brew install argocd
  1. After installing the CLI, you need to access the Argo CD server. Change the ‘argocd-server’ service type to ‘LoadBalancer’ and forward the service to your local machine:
kubectl patch svc argocd-server -n argocd -p '{"spec": {"type": "LoadBalancer"}}'
kubectl port-forward svc/argocd-server -n argocd 8080:443

The first command updates the Argo CD-server service type, and the second command forwards the server to localhost on port 8080. You can now access the Argo CD web UI by navigating to https://localhost:8080/.

  1. To log in, retrieve the initial password using:
argocd admin initial-password -n argocd

Use the username admin and the password obtained from the above command to log in to Argo CD.

2. Install a Kustomize Application with Argo CD

To deploy a Kustomize application using Argo CD, first ensure you have Kustomize and Argo CD installed and configured. Follow these steps:

  1. Clone the repository containing the Kustomize application to your local environment:
git clone https://github.com/hseligson1/kustomize-gitops-example.git

The application’s structure includes directories for base configurations and overlays for different environments (production, staging).

  1. Configure the cluster with overlays using the following commands:
kustomize build kustomize-gitops-example/overlays/staging

Or for the production environment:

kustomize build kustomize-gitops-example/overlays/production
  1. Apply the configurations to the cluster:
kubectl apply -k kustomize-gitops-example/overlays/staging

Or for the production environment:

kubectl apply -k kustomize-gitops-example/overlays/production
  1. Inspect the deployment to ensure it’s ready:
kubectl get deployment staging-the-deployment

Or for the production environment:

kubectl get deployment production-the-deployment
  1. To deploy the same application using Argo CD, log into the Argo CD UI and create a new application. 
  1. Navigate to +NEW APP and fill in the details as follows:
  • Application Name: kustomize-gitops-example
  • Project: default
  • Sync Policy: Automatic

In the source section:

  • Repository URL: https://github.com/hseligson1/kustomize-gitops-example.git
  • Revision: main
  • Path: overlays/staging

In the destination section:

  • Cluster URL: default
  • Namespace: default
  1. Enable the auto-sync feature to keep the application state in Kubernetes in sync with the GitHub repository. Argo CD will read the kustomization.yaml file and deploy the resources accordingly.
  1. After the synchronization process completes, you can review the application health and the resources deployed in the Argo CD UI. If needed, you can also roll back to a previous version or view the deployment history through the UI, which includes links to the specific Git commits that triggered the deployments.

3. Install a Helm Application with Argo CD

To deploy a Helm application using Argo CD, follow these steps:

  1. Set up your Helm repository in Argo CD to access Helm charts. Start the Argo CD UI, navigate to Settings, then Repositories, and select Connect Repo using… (choose SSH, HTTPS, or GitHub App as applicable). 
  2. Set the repository Type to Helm, and provide a unique Name and Repository URL. If it is a private repository, add access credentials.
  3. In the Argo CD UI, select Applications and then New App
  4. Enter an Application Name, choose a Project, and set the Sync Policy to Manual. 
  5. For Repository URL, select your Helm repo. 
  6. The Chart field will populate with Helm charts available in this repository—select a Helm chart. 
  7. The Revision field will show available versions of the Helm chart—choose the version you want to deploy. 
  8. Specify the destination Kubernetes cluster’s Cluster URL and Namespace
  9. Click Create. The application will initially be in an OutOfSync status as it is not yet deployed.
  10. To deploy the application, select the application tile in the dashboard and click Synchronize. Argo CD will deploy the application to the Kubernetes cluster using the Helm chart. The dashboard will show the application running in your Kubernetes cluster. You can also run kubectl get all to view the created pods.

Important note: When you deploy Helm charts with Argo CD, they are no longer recognized as Helm deployments by Kubernetes. Regular Helm commands may not work because Kubernetes considers the application an Argo CD application, not a Helm deployment.

Codefresh: An Argo-Based CI/CD Solution for Kubernetes

The Codefresh platform, powered by Argo, combines the best of the open-source with an enterprise-grade runtime allowing you to fully tap the power of Argo Workflows, Events, CD, and Rollouts. It provides teams with a unified GitOps experience to build, test, deploy, and scale their applications.

You can use Codefresh for your platform engineering initiative either as a developer portal or as the machinery that takes care of everything that happens in the developer portal. Your choice depends on how far your organization has adopted Kubernetes and micro-services.

The World’s Most Modern CI/CD Platform

A next generation CI/CD platform designed for cloud-native applications, offering dynamic builds, progressive delivery, and much more.

Check It Out

How useful was this post?

Click on a star to rate it!

Average rating 4.5 / 5. Vote count: 4

No votes so far! Be the first to rate this post.