The aim of this assignment is to understand the hands-on experience with GitOps practices, utilizing Argo CD for continuous deployment and Argo Rollouts for advanced deployment strategies within a Kubernetes environment. You will be responsible for setting up a GitOps pipeline that automates the deployment and management of a simple web application.
Our application is a simple web application that displays system metrics such as CPU utilization and memory usage. It is built using Python Flask and utilizes the psutil library to collect system metrics. The application serves a single-page HTML template using Flask's render_template function.
Before getting started, ensure you have the following prerequisites installed:
- Docker.
- Git Bash.
- Minikube: To run a local Kubernetes cluster for testing purposes.
- Download and install Minikube locally using the following command:
Invoke-WebRequest -OutFile 'c:\minikube\minikube.exe' -Uri 'https://github.com/kubernetes/minikube/releases/latest/download/minikube-windows-amd64.exe' -UseBasicParsing
New-Item -Path 'c:\' -Name 'minikube' -ItemType Directory -Force
minikube start
minikube status
kubectl create namespace argo
kubectl apply -n argo -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
kubectl get pods -n argo
kubectl -n argo get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 --decode
kubectl -n argo get secret argocd-initial-admin-secret -o jsonpath="{.data.password}"
and than go to your browser and search for base 64 decode and decode the encoded password you recieved and save the decoded password.
kubectl port-forward svc/argocd-server -n argo 8080:443
Access the Argo CD UI by opening a web browser and navigating to https://localhost:8080 and logging in with username "admin" and the password retrieved earlier.
Repository URL: https://github.com/Rohit3Pandey/Flask-monitoring-app.git
Path: Deployment (This is the path to your "deplyment.yml" file which is consisted of all the configurations that will be used by Argo CD to deploy the application)
Cluster URL: default Kubernetes cluster - https://kubernetes.default.svc
After the deployment of the application on Argo CD go to you terminal and run the following commands-
minikube servive my-web-app --url
the output of this command would be like this - http://127.0.0.1:50436 and you can use this to access your application on browser.
If you see something like this which is shown below than congrats, you have successfully deployed the web-app on kubernetes using Argo CD.
Navigating the intricacies of Argo CD and orchestrating the deployment of a web application on Kubernetes presented a formidable challenge, particularly for someone approaching these technologies for the first time. In response, I diligently sought out resources and guidance, consulting the official documentation of Argo CD, leveraging insights from ChatGPT, and meticulously studying a variety of YouTube tutorials. Through these efforts, I gained invaluable insights into the nuances of crafting deployment YAML files and mastering essential practices, enabling me to execute the project with confidence and precision.
To remove all resources created during this assignment from the Kubernetes cluster, follow these steps:
kubectl delete application flask-web-app
kubectl delete namespace argo
minikube stop
minikube delete
By following this guide, you have successfully set up a GitOps pipeline with Argo CD for continuous deployment in a Kubernetes environment.