GitOps From Basic Introduction To App Deployment using ArgoCD

Ghazanfar Ali
6 min readSep 19, 2023

--

What is GitOps?

GitOps uses git as single source of truth to deliver applications and infrastructure.

Let suppose you do not have gitops and you are trying to build infrastructure on kubernetes like a person x update the node conf in K8s custer, and after 10 days someone ask you what changes you have made there is no mechanism to tracking the change, there is no versioning or auditing. Gitops came with the idea if your source code has a mechanism of tracking then why not the deployment. ArgoCD is famous gitops controller. Gitops also use to manage the infrastructure in kubernetes when you have thousands of resources.

GitOps Principles:

Continuous reconcile mean gitops will not allow to change anything directly in the K8s cluster, it will ask to changes through git then it will deploy the changes on cluster so it achieve security also.

Is GitOps is for Kubernetes only?

By principle the answer is No, But the popular gitops tools like ArgoCD and Flux targets kubernetes.

Advantages of GitOps:

1- Security

2- Versioning

3- Auto Upgrade

4- Auto Healing

5- Continuous reconciliation

Some popular tools in GitOps:

ArgoCD Architecture:

ArgoCD usually have three micro-services one for user interaction and one to get the state from git and one to get the state from k8s.

When we install argoCD it install the light weight server called DEX, it is basically for the SSO (single sign in option like from google)service like single sign on service, second is Redis which is use for cache let suppose application server goes down when it comes up it need the cache of previous state.

How to install ArgoCD:

Now we will install ArgoCD using yaml manifests approach and also see the application deployment on K8s cluster using ArgoCD.

First we need to have kubernetes cluster in our system i will use minikube for this lab:

Follow the below document to install the argo cd in your machine:

https://argo-cd.readthedocs.io/en/stable/getting_started/

Once it is installed check the pods in argocd namespace:

Pods:

1- Argocd-server pod is basically the api server of argocd, it takes all the requests from the user.

2- argocd repo-server is use to interact with the version control system like git, argocd only supports git base VCS.

3- redis is for caching and keeping the state.

4- dex server is use for SSO in argoCD. Dex is an identity service that’s often used with ArgoCD to provide a unified and secure way to manage user authentication and authorization in Kubernetes environments.

5- The ApplicationSet Controller is an advanced feature in ArgoCD that extends the capabilities of the ArgoCD Application Controller. It allows you to define and manage multiple similar applications using a single configuration, making it easier to manage large numbers of applications with similar characteristics or configurations.

6- The Application Controller in ArgoCD is a critical component responsible for managing the desired state of applications deployed in a Kubernetes cluster. Its primary role is to synchronize the actual state of applications with their desired state, ensuring that applications are deployed, updated, and maintained correctly. Here’s how the Application Controller is used in ArgoCD.

Below are the services that installed with the argocd installation:

We will change the argocd-server service cluster ip to node ip so that it could interact outside the cluster:

Now we will check tunnel detail so that we could access this service from our browser:

Currently we do not see any SSO option here because we did not integrated any sign in option like google with argoCD dex server.

To get the password of argoCD admin password:

Decrypt your secret with base 64:

We have login to argoCD UI:

The best way to play with argoCD is use the github repo maintain by argocd:

https://github.com/argoproj/argocd-example-apps

Lets start with the plain yaml example without helm chart:

Create new application on argoCD:

Give the github url and path mean folder of repo:

Give destination mean where to deploy the application:

Click on create button it will start deployment:

It have successfully deployed our application on kubernetes cluster:

Now we will see how argocd will deploy our application using helm chart not plain text:

Delete the previous application and create the new one, use the same github repo but different folder:

It have deployed it also:

Now we will see how to use the argoCD using cli:

Again follow the above shared document for argocd cli installation:

Or use below command:

wget https://github.com/argoproj/argo-cd/releases/download/v2.8.4/argocd-linux-amd64 -O /usr/local/bin/argocd

chmod +x /usr/local/bin/argocd

Now we can use argocd cli.

First we will login to the argocd using cli:

We will use basic command to deploy the same application of guestbook example:

It started deployment:

--

--

Ghazanfar Ali
Ghazanfar Ali

Written by Ghazanfar Ali

I write technical blogs on DevOps and AWS, Azure and GCP

No responses yet