Getting started with Argo CD
- Vishal Arora
- Mar 27, 2022
- 3 min read
Updated: Feb 22
Argo CD is a declarative GitOps tool for continuous delivery in Kubernetes. It operates using a pull-based mechanism and runs as a controller within the Kubernetes cluster.
Argo CD is based on below key GitOps principles
The entire system is described declaratively.
Store Desired State in Git.
Apply Approved Changes Automatically.
Software agents ensure correctness and alertness on divergence.
Argo CD can work with helm, kustomize, YAML manifest files.
In the case of Kubernetes, a GitOps agent is deployed on the cluster, it will be monitoring one or more git repositories that define application and contain Kubernetes manifests. Once the git commit happens the GitOps agent is instructing the cluster to reach the desired state as described in Git

Let's run the Argo CD controller using the helm chart. will install the helm version 3.8 using the below commands.
wget https://get.helm.sh/helm-v3.17.0-linux-amd64.tar.gz
tar -zxvf helm-v3.17.0-linux-amd64.tar.gz
mv linux-amd64/helm /usr/local/bin/
helm version
Let's also set up the Nginx ingress controller for routing the traffic to Kubernetes services. It will be creating a public load balancer on AWS
helm upgrade --install ingress-nginx ingress-nginx --repo https://kubernetes.github.io/ingress-nginx --namespace ingress-nginx --create-namespace

Adding the Argo CD helm repo and installing the chart. In this, we are creating the ingress resource with host as argocd.thefinisher.xyz which will be pointing to the load balancer created by the ingress controller.
helm repo add argo https://argoproj.github.io/argo-helm
helm repo update
git clone https://github.com/vishal267/thefinisher
cd thefinisher/helm-charts/argocd
helm upgrade --install argocd argo/argo-cd -n argocd -f values.yaml --namespace argocd --create-namespace

Kubectl get ingress -n argocd

Let's fetch the password from the secret using the following command and open the Argo CD URL -
kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d
username will be admin which can be changed.

It's time to create a new app that can be synced with the application Github repo. we can do this using UI or by using the argocd command line.
Here we are using helm chart to deploy an application named simple-app
Repo path- https://github.com/vishal267/thefinisher/tree/main/helm-app
Click on a new app and in the general section fill the application name, keep the project type as default, and sync policy as manual for now. Also, select the auto-create namespace option which will ensure that the namespace will be created automatically

In source section provide the repo URL which contains the helm chart and path of the helm chart in our case it's in the root folder which is helm-app.

Under the destination section just select the cluster URL and define the name of the namespace in which we need our helm chart to be deployed. Remember this namespace will be created as we have selected the auto-create namespace option in the general section.

Now Just click on the CREATE option which is present at the left top. This will create the app1.

Initially the app will be out of sync state as we have selected the manual sync while creating the app. Let's do manual synchronization that will automatically create the resources defined in helm templates, Just select the sync option and click on SYNCHRONIZE option.

Now the Argo CD controller will make sure all the resources are created and app status will be changed to sync in a few minutes. We can also see the resources created using Argo CD UI.

Let's verify the resources using kubectl CLI.
kubectl get all -n app

It seems all resources as defined in the helm chart are created in the k8s cluster. In the case of Production setup, we should use auto-sync instead of manual sync which will automatically sync. By default sync period is 3 minutes.
Now let's create the same app using the Argo CD CLI.
Installing argocd cli
curl -sSL -o /usr/local/bin/argocd https://github.com/argoproj/argo-cd/releases/latest/download/argocd-linux-amd64
chmod +x /usr/local/bin/argocd
argocd help
We need to log in using the argocd login command, it will ask for username and password which will be the same used while login in using the argocd URL.
argocd login argocd.thefinisher.xyz

Let's create the new app using the argocd app create command and provide the project, repo, path, dest-namespace, dest-server values same as we provide while creating using Argo CD UI. We need to execute the argocd app sync command to sync it with the git repository.
argocd app create app1 --project default --repo https://github.com/vishal267/thefinisher --path "./helm-app/" --dest-namespace app --dest-server https://kubernetes.default.svc
argocd app sync app1
argocd app list
kubectl get all -n app

Keep in mind that this covers only the Continuous Delivery (CD) aspect. In a production setup, Continuous Integration (CI) is also required alongside CD, which can be handled using tools like Jenkins or Argo Workflows.