Kubernetes Deployments with ARGO CD
Alice Sophiya Samuel
Linux administrator | 2x RedHat Certified | Ansible | Linux | AWS | Azure | Datacenter Infrastructure Management | OpenShift | Docker
Argo CD is an open-source continuous delivery tool for Kubernetes that helps you automate the deployment of your applications to Kubernetes clusters. It provides a declarative way of managing your application manifests in Git repositories and ensures that the desired state of your applications in the Kubernetes cluster matches the state described in your Git repository.
How does Argo CD work?
Argo CD works in a reversed flow mechanism as compared to push-style deployments. The new mechanism enables ArgoCD to run from inside a Kubernetes cluster. Kubernetes faces challenges with the traditional? CD mechanism because CI/CD tools, like Jenkins, sit outside the cluster, whereas Argo CD sits inside the cluster. While inside the cluster, Argo CD pulls changes from git and applies them to the residing cluster. Instead of pushing changes like older generation tools by being inside the cluster, ArgoCD prevents sensitive information from being exposed to other tools outside the Kubernetes cluster and environment.?
Argo CD can be set up in two simple steps.
When Argo CD monitors change, it automatically applies them to the Kubernetes cluster. When developers commit the new code updates to the Git repository, automated CI pipelines will auto-start the build process and build the container image. Then as per the configurations, the CI pipeline will push and update the Kubernetes manifest files. The pipelines will update the new image version name and details on the deployment.yaml file. Argo CD can track this new update, pull the image, and deploy it onto the target cluster.
When the Kubernetes cluster is ready, Argo CD sends a report about the status of the application and that the synchronization is complete and correct. ArgoCD also works in the other direction, monitoring changes in the Kubernetes cluster and discarding them if they don’t match the current configuration in Git.
Benefits of using Argo CD
Let's start by installing Argo CD
Step 1: To install Argo CD, we must first install Docker and Kubernetes. Let’s put them in one by one. To install docker, run the command
sudo apt-get install docker.i
then Run the docker version to check whether the docker is installed or not:
Step 2: Let’s install minikube and kubectl, two Kubernetes utilities, after Docker. Minikube can be downloaded using the following methods:
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
Step 3: Instlall minikube using:
sudo install minikube-linux-amd64 /usr/local/bin/minikube
Step 4: After minikube has been installed, you can start a cluster to install Argo CD. To begin a new cluster, enter the following command:
领英推荐
Step 5: Now, let’s Install Argo CD using HELM. Run the following commands to install helm in your system:
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
chmod 700 get_helm.sh
./get_helm.sh
Step 6: Run the following commands to download and install Argo CD in your system:
git clone https://github.com/argoproj/argo-helm.git
cd argo-helm/charts/argo-cd/
kubectl create ns myargo
helm dependency up
helm install myargo . -f values.yaml -n myargo
kubectl port-forward service/myargo-argocd-server 8090:80 -n myargo –address 0.0.0.0
Step 7: Now go to localhost:8080 or remoteip:8080 to access the UI of Argo CD.
Step 8: To generate a password, execute the following command. The administrator username is the default.
kubectl -n myargo get secret argocd-initial-admin-secret -o jsonpath='{.data.password}' | base64 –d
Congratulations! Argo CD has been successfully installed on your system.
I wrote the following code in the application.yaml file:
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: myapp-argo-application
namespace: argocd
spec:
project: default
source:
repoURL: https://gitlab.com/nanuchi/argocd-app-config.git
targetRevision: HEAD
path: dev
destination:
server: https://kubernetes.default.svc
namespace: myapp
syncPolicy:
syncOptions:
- CreateNamespace=true
automated:
selfHeal: true
prune: true
Step 9: Apply the configuration file with kubectl apply -f application.yaml and you should get the following screen:
Conculsion
Argo CD simplifies Kubernetes application deployment through GitOps, promoting automation and consistency while offering robust management capabilities for cloud-native environments.