Day 26 Chapter 2- Deploy Flask Application using Helm Chart and many more features- Kubernetes

Day 26 Chapter 2- Deploy Flask Application using Helm Chart and many more features- Kubernetes

Introduction

🚀 Welcome to Day 26 of #30DaysOfKubernetes! 🎉 Today, we’re diving into Chapter 2 of the Helm Charts saga! 📊✨ Let’s unravel the magic of Helm, simplifying Kubernetes deployments.

Docker Project of Python Flask Repo- https://github.com/AmanPathak-DevOps/Docker-Projects/tree/master/Python-Project-for-Helm-K8s

Kubernetes Manifest file Repo- https://github.com/AmanPathak-DevOps/Kubernetes-files

In the Previous Chapter, we have covered some theory and basic hands-on. But today, we will deep dive and do more hands-on.

The topics that we will cover today:

✅ Deploy Python Flask Application using Helm Chart

✅ What is Helmfile?

✅ Demo of Helmfile(Deploy HelmCharts using declarative method)

✅ Test Cases for your Helm Chart

Demonstration

Create a helm chart for the Python application by using the below command

helm create helm-deploy-rest-api
ls -lart Helm-Deploy-Rest-API

Comment Out the appVersion in the Chart.yaml file

vim helm-deploy-rest-api/Chart.yaml

Replace the image repository with nginx

vim helm-deploy-rest-api/values.yaml

Replace the service type from ClusterIP to NodePort in the same values.yaml file

vim helm-deploy-rest-api/templates/deployment.yaml

Remove the appversion set and write only the image repository name

In the same deployment.yaml file.

Modify the port to 9001 according to our application

Now in the same deployment.yaml file comment out all the liveness probe and readiness probe function

Now, install your helm chart

helm install pythonhelm helm-deploy-rest-api/

Now, check whether the pod is running or not

kubectl get pods

Check the service to get the port number

kubectl get svc

Now, get the minikube ip using the minikube ip command and paste it on the browser to get the content of the application

Use the ‘/main’ because this is our path where content is present. Otherwise, you will get errors on different paths.

You can uninstall the release for the helm chart

Helmfile

Earlier, we used to deploy helm charts in an imperative way. But if you want to deploy helm charts using a declarative way then we will use Helmfile. Helmfile also helps to deploy multiple charts in one go.

Demo of Helmfile

Install the file

github.com/roboll/helmfile/releases/downloa..

Rename the file name to helmfile

mv helmfile_linux_amd64 helmfile

Change the permissions of the helmfile

chmod 777 helmfile

Now, move the helmfile to the bin folder

mv helmfile /usr/local/bin

Validate the version by the command

helmfile — version

Now, We will try to deploy our previous Python application using helmfile.

Once you run the command helmfile sync, your chart will be deployed.

If you want to uninstall the release then, go to the yaml file replace the true with false in the installed line, and run helm sync.

As we run the command to uninstall the deployment the pod is terminating now.

Helmfile using Git repository

Suppose your charts are present on the Git repository and you want to install them. So, Helm provides you with a feature in which you don’t need to clone the repo manually to deploy the chart. Instead of this, you just have to provide the git repository URL in the helmfile and helm will deploy the charts automatically.

Demo

To leverage this feature, you need to install one plugin for it. To install it just copy and paste the below command.

helm plugin install github.com/aslafy-z/helm-git — version 0.15.1

Now, add your repo accordingly in the yaml file

Now, run the helmfile using the below command

helmfile sync

Install multiple charts using helmfile

You just need to add the charts in the previous helmfile below

Now, run the command to install the charts

helmfile sync

Test your helm chart

Once I deploy the chart, I want to test the chart whether it’s working or not.

So, you can define your test cases in the test-connection.yaml file which is presented in the tests folder of the chart itself.

As we have deployed our charts in the previous demo. So, we will test those charts.

To test the particular chart use the below command.

helm test

As you can see in the below snippet. Our helloworld chart test is succeeded.

🎩✨ Conclusion: Chapter 2 of our Helm adventure brought us closer to Helmfile and its powerful capabilities. We explored declarative deployments, and Git repository integration, and even tested the reliability of our Helm charts. As we continue our Kubernetes journey, Helm remains a key ally, streamlining the deployment process and enhancing automation. Ready for more Helm magic? Stay tuned! 🚀✨ #Kubernetes #HelmMagic #DevOps #Conclusion

Want to Know About Challenge?

If you’re eager to learn more and join our challenge through the GitHub Repository, stay tuned for the upcoming posts. Follow for more exciting insights into the world of Kubernetes!

GitHub Repository: https://github.com/AmanPathak-DevOps/30DaysOfKubernetes

#Kubernetes #DaemonSet #StatefulSets #NetworkPolicy #Operators #ContainerOrchestration #DevOps #K8sLearning

See you on Day 27 as we unravel more Kubernetes mysteries!

Stay connected on LinkedIn: LinkedIn Profile

Stay up-to-date with GitHub: GitHub Profile

Feel free to reach out to me, if you have any other queries.

Happy Learning

Chapter 2 finished