Argo CD and Helm: Deploy Applications the GitOps Way!

pavanbelagatti

Pavan Belagatti

Posted on December 19, 2022

Argo CD and Helm: Deploy Applications the GitOps Way!

GitOps has become the talk of the town these days. The popularity this approach has gained in the application deployment space is remarkable. Developers find it straightforward to deploy applications using this approach as it removes many bottlenecks. Argo CD & Helm Charts, on the other side, make this GitOps approach easy. Also, with Git being the only source of truth, tracking and observability become easy. Today, we will see how the GitOps approach can be implemented using Argo CD. Using this approach, we will show how to deploy a simple application and Helm charts.

GitOps works as a modern continuous delivery model where a GitOps agent is used between the Git and target environment (for example, Kubernetes) where our applications get deployed, and it keeps track of all the changes that happen in Git. If there is any change, it pulls the changes to match the expected configuration. The agent compares the actual and desired state. For example, when a developer changes pod numbers in the yaml file from 2 to 4, the agent compares the two states, and when the change gets identified, it pulls the changes to make the two states (actual and desired) even. Argo CD and Kubernetes make a great pair when it comes to a well-thought GitOps approach.

What is Argo CD?

Argo CD is a declarative, GitOps-based continuous delivery tool that helps you deploy applications from Git, manage their lifecycle, and keep your environment in sync. By choosing Argo CD, you can keep your deployments up to date and ensure that your application always follows the desired state. Argo CD allows you to define your applications and their environments as code and then deploy and update them on any Kubernetes cluster.

What is Helm?

Kubernetes has become the defacto container orchestration tool for modern cloud-native enterprises and it has made the deployment of enterprise applications easier and more efficient.

But the learning curve involved with Kubernetes is still overwhelming and the it might be a complex tool for some. Understanding Kubernetes requires time. The process of configuring and deploying an application on Kubernetes can be a daunting task. Fortunately, with Helm and Helm Charts, it is now possible to automate the deployment process and quickly deploy and manage applications on Kubernetes. Helm is an open-source tool that helps you manage Kubernetes applications. Helm Charts are packages of pre-configured Kubernetes resources that can be deployed quickly and easily. With the help of Helm and Helm Charts, developers can streamline their Kubernetes deployment process and quickly get their applications up and running.

Argo CD vs Helm

Both are popular open-source tools for managing and deploying cloud-native applications, but they have some major differences. Let's take a look at how they compare with each other.

  • The first difference between Argo CD and Helm is the way they deploy applications. Argo CD is a continuous delivery tool/platform that can be used to deploy applications to multiple environments. Whereas Helm is a package manager that can be used to deploy applications to a single environment. Hence, Argo CD is better suited for more complex deployments, and Helm is better suited for simple deployments.

  • The second difference is the way they manage applications. Argo CD is a GitOps-based tool, which means that it uses Git as a single source of truth and uses it as a focal point to store and track application configurations and manifests. This makes observability very easy and easier to keep track of changes. Even you can roll back to previous versions if needed. Whereas Helm considers Helm charts as a focal point to manage and deploy applications and the changes must be tracked manually.

  • The third difference is the way they help scale applications. Argo CD is designed to scale horizontally and can easily be deployed to multiple clusters. But with Helm, you can only deploy to a single cluster. This shows that Argo CD is well suited for large-scale deployments, and Helm is well suited for small-scale deployments.

Tutorial

For this tutorial, the only pre-requisite is to have access to a Kubernetes cluster. You can also use Minikube or Kind to get a one-node cluster.

First, create a namespace
kubectl create namespace argocd

Apply the manifest file to the namespace created
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
argocd namespace

Make sure all your pods are running properly inside the namespace

kubectl get pods -n argocd
argocd pods running

Now, let’s expose our ArgoCD server UI through port forwarding
kubectl port-forward svc/argocd-server -n argocd 8080:443

Once you do that, you can now see the ArgoCD UI on https://localhost:8080/
Argo CD UI

Now, you need a username and password to log in. By default, the Username is ‘admin’ and the password can be generated using the following command,

kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d; echo

You will get an output as below and use it as your password,
argo pass

Once you have the username (admin) and the password (zb8EurqNxJkA1eQE), login to ArgoCD

Argo cd dashboard

Also, make sure you can use Argo CD locally via CLI, hence install the Argo CD CLI

brew install argocd

Now, you can login and talk to your Argo CD via CLI.

argocd login localhost:8080

It will ask you for the username and password. Set both, and the login will be successful.

Deploying Application via Helm to Argo CD

https://github.com/argoproj/argocd-example-apps is a very successful ArgoCD example repo and will make use of it to deploy a guestbook application via Helm.

Let’s create an application on ArgoCD

argocd app create helm-guestbook --repo https://github.com/argoproj/argocd-example-apps.git --path helm-guestbook --dest-server https://kubernetes.default.svc --dest-namespace default

You should see the application getting created.
application 'helm-guestbook' created

Let’s check the status of the application created,
argocd app get helm-guestbook

argocd app created

You can see that both Service and Deployment are in OutOfSync status. Let’s sync the application with the following command,

argocd app sync helm-guestbook

argocd app sync

You can now see that the health status of our Service is Healthy and Deployment is Progressing. The Deployment will take some time and becomes Healthy.

You can verify the created application on Argo CD by going to the UI.
Helm Guestbook

Here you can see that the status is Healthy and Synced.

By doing the port-forward, you can easily access your deployed application.
kubectl port-forward svc/helm-guestbook 9090:80
kubectl port forwarding

Let’s access our application at http://localhost:9090/

guestbook application

Deploying Helm Charts with Argo CD

Let us use Argo CD to deploy Helm Charts.

Go to settings in the Argo CD UI and add Repositories.
Argocd repositories

Add the following details and connect.
argocd connect

You should see your added repository in the list.
argo helm

Now, click on create a new application. We will deploy NGINX Helm chart on Argo CD.

Make sure to specify the required details.
helm example argocd
argo source

Once you click on create, you should be able to see your application on the Argo CD dashboard.

At first, the application will be out of sync and once we synchronize the application, it gets synced and shows healthy.
helm status

Click on ‘Sync’ and then ‘Synchronize’
argo cd sync cancel

Now, if you go back and see, your application should show Healthy and Synced status.
Helm healthy status

GitOps Using Harness

Harness provides native GitOps functionality that lets you deploy services by syncing the Kubernetes manifests in your source repos with your target clusters. First, you set up Harness GitOps by installing a GitOps Agent in your environment. Next, you define how to manage the desired and target state in a GitOps Application in Harness. The GitOps Agent performs the sync operations defined in the Application and reacts to events in the source and target states.
Harness GitOps

You will need to sign up for a Free Harness Account and navigate to the GitOps tab.

Harness GitOps Dashboard

You can follow this simple Harness GitOps tutorial to see how intuitive and simple it is to deploy applications via Harness GitOps.

💖 💪 🙅 🚩
pavanbelagatti
Pavan Belagatti

Posted on December 19, 2022

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related