Argo CD — A GitOps Tool for Continuous Delivery
Before learning about Argo CD, let’s first know about how CD is implemented commonly. Say we have microservices, which need to be deployed in the Kubernetes cluster. Whenever we commit the application code, it will trigger the CI pipeline, test the changes, build the image, and push the image to any repository like jFrog, GCR, ECR, etc.
After pushing it to the repository, we update the Kubernetes deployment file with a new image tag. Then we apply the changes to the Kubernetes cluster.
Challenges in this approach are
To overcome these problems, Argo CD was introduced. Argo CD is a GitOps tool built into the Kubernetes cluster based on the pull mechanism.
What is Argo CD?
Argo CD is a container native K8 engine for orchestrating jobs on Kubernetes. Here the jobs will run entirely on Kubernetes and instead of accessing the cluster outside using a third-party tool, we install Argo CD, which will be installed as part of the cluster.
By using Argo CD, we will be keeping the application repository and configuration/manifests files in different repositories. As part of a cluster, Argo CD will be keeping track of the desired state, and whenever there are changes in the repository manifest files, Argo CD pulls the changes to the cluster, applies them, and achieve the target state.
Let us now know about the Architecture of Argo CD
Argo CD uses git repositories as the source of truth for the desired state of applications and the target deployment environments. Kubernetes manifests can be specified as YAML files or Helm packages. Argo CD automates the synchronisation of the desired application state with each specified target environment.
Whenever we commit to the git configuration repository, Argo CD will be notified and it will check what has changed. Argo CD will sync the current state to the desired state. Argo CD achieves the desired state automatically.
Benefits of Argo CD
Installation and application.yaml file in Argo CD
Pre-requisites:
As mentioned argocd will be installed inside the cluster. To install Argo CD, we need to create namespace argocd. The Argo CD will run on this namespace. The command to create argocd namespace is this.
kubectl create namespace argocd
After this namespace creation, install the Argo CD stable version using this command.
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
This will install argocd. Once you are done with installing just run the following command to list the pods.
kubectl get pods -n argocd
The output of this command will be something like this:
In the above diagram,
领英推荐
If you list the services in Kubernetes, It will print Argo-server running on port 443. To access the argocd UI run the following command. This command will map port 443 of the cluster to 8080 on localhost.
kubectl get svc -n argocd
kubectl port-forward svc/argocd-server -n argocd 8080:443
This will open up the UI at?https://localhost:8080 . This will open a login page first. The username is admin and to get the password run the following command.
kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d; echo
The UI will look like this:
Now the installation of the Argo CD is complete. Let us deploy a sample application, that will be maintained by Argo CD.
Deploy a Sample Application to Argo CD
For deploying the sample application, we will make use of the below repository of Argo CD.
Here we will make use of the folder guestbook. We will create Argo CD manifest file application.yaml file. We extend Kubernetes API with CRD. The main resource is application.yaml file, as mentioned below.
In this file,
We should run the following command to apply application CRD to tell Argo CD which repository to sync with:
kubectl apply -f application.yaml -n argocd
This will be the Argo CD UI after deploying guestbook:
To check if the application is running or not, we can use the port forwarding command. The service is running on port 80. So, we port-forward the application to 3333 on localhost. When we hit?https://localhost:3333 , it will show the following UI.
kubectl get svc -n medium
kubectl port-forward svc/guestbook-ui -n medium 3333:80
This is all about Argo CD and deploying an application to Argo CD.
Conclusion
This blog walks you through the basics of Argo CD and its benefits. If you want to have a hands-on on the same please refer to this article. This article tells how to install Argo CD, configure Argo CD and Deploy a sample application to minikube. For more understanding of the basics, please refer to the official documentation. https://argo-cd.readthedocs.io/en/stable/
To get started with more DevOps articles, do follow me on medium: https://medium.com/@raosharadhi11
Hope you enjoyed the article and learnt about Argo CD!!
Aspiring DevOps Engineer | AWS Enthusiast | CI/CD | Kubernetes Explorer | Passionate Learner ??
1 年Amazing content Sharadhi S.
Cloud & DevOps Engineer
1 年Thanks for sharing
Empowering and Mentoring People ?????? Kubernetes (CKAD) ?? GitLab ?? Ansible ??Terraform ?? Cloud-Native ??
1 年Thank you for sharing this!
Site Reliability Engineer | DevOps Engineer |DevSecOps | Ethical Hacker |GCP |AWS |Digital Ocean |CKA |Docker |GitOps |GitLab | Terraform | Ansible | Grafana | Prometheus | RHCSA
1 年Very useful.Thanks for sharing