Welcome to Day 26 of our #30DaysOfKubernetes journey! 🚀 Today, we’re diving into the magic of Helm, the Kubernetes package manager. Let’s simplify your deployments and embrace the power of Helm charts! 🎩💡
Helm is a Kubernetes package manager in which the multiple numbers of YAML files such as the backend, and frontend come under one roof(helm) and deploy using helm.
Let’s understand with the help of a simple example.
Suppose you have an application where frontend, backend, and database code needs to deploy on Kubernetes. Now, the task becomes hectic if you have to deploy frontend and backend codes because your application will be Stateful. For frontend, backend, and database you will have to create different YAML files and deploy them too but it will be complicated to manage. So, Helm is an open-source package manager that will help you to automate the deployment of applications for Kubernetes in the simplest way.
Let’s understand again with the help of the above architecture.
As you know, to deploy your code you need to write a minimum of two YAML files which is deployment and service file. Those files will be deployed with the help of the kubectl command. These files act differently from each other but you know that the files are dependent on each other.
In the help deployment, all the YAML files related to the application deployment will be in the helm chart. So, if you want to deploy your application you don’t need to deploy each YAML file one by one. Instead, you can just write one command helm install <your-chart-name> and it will deploy your entire application in one go. Helm is the Package manager for the Kubernetes which helps to make the deployment simple.
- Because of the helm, the time will be saved.
- It makes the automation more smoothly
- Reduced complexity of deployments.
- Once files can be implemented in different environments. You just need to change the values according to the environmental requirements.
- Better scalability.
- Perform rollback at any time.
- Effective for applying security updates.
- Increase the speed of deployments and many more.
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
chmod 700 get_helm.sh
To list the all repositories
Create a stable repository using the helm
helm repo add stable https://charts.helm.sh/stable
List the repo, again
helm repo list
To remove the repo
helm repo remove stable
To create our own repo
helm create my-repo
To see the files inside the created repo
Let’s do a simple demo where we will host the nginx page on Kubernetes using the helm chart.
Create a chart using the command
helm create helloworld
The file structure should look like the below snippet.
Go to the Helm Chart directory helloworld and edit the values.yaml file
Replace the ClusterIP with NodePort
Now deploy your helm chart
To do that, you have to be present in the directory where the chart is present.
In my case, my helloworld chart is in the Helm directory. So, I have to be in the Helm directory and run the below command to install the Helm Chart.
helm install thehelloworld hellowolrd
helm install <custom-chart-release-name> <given-chart-name>
Now, check the services whether your application is running or not
kubectl get svc
Now, access your application via browser by copying the port number(in my case 30738) with minikube private IP in starting.
To get the IP, you can simply run the command on the terminal minikube ip and use it to view the content.
As you can see in the below snippet, our application is successfully deployed with the help of Helm Chart.
If you want to see the minikube dashboard GUI then run the below command on the terminal.
Once you run the command, a new tab will open in your browser that will look like the below snippet.
Now, if you want to uninstall your deployment. You can simply run the below command.
helm uninstall thehelloworld
Once you uninstall the deployment you will see nothing on your K8s dashboard because the deployment has been deleted.
Demo of Helm Cheat Sheets
Create the helm chart
helm create helloworld
Create the release and deploy the helm chart
helm install thehelloworld helloworld
Now, if you want 2 replicas instead of 1. So you will make the changes in the values.yaml file and replace the replica 2 with 1. But you have to redeploy the changes which will be done by the below command after doing the changes.
helm upgrade thehelloworld helloworld
Now, you think that you did something wrong or unexpected and you want to switch to the previous deployment. To do that, first of all, you need to know that to which revision number you have to switch.
To check the current revision use the below command.
helm list -a
Now, I want to switch to the 1 Revision number. So, I will roll back the changes by the below command.
helm rollback thehelloworld 1
If you want to dry-run the chart before installation use the below command.
helm install thehelloworld — debug — dry-run helloworld
If you want to validate your YAML files within the helm chart then, use the below command.
helm template helloworld
If you want to validate your Charts then use the below command.
helm lint helloworld
If you want to delete or release the deployment then, use the below command.
helm uninstall thehelloworld
Cheers to unlocking the Helm magic on Day 26! 🎉 Dive into Helm charts for simplified Kubernetes deployments. We will cover some advanced things related to Helm in the next Chapter(Not on Next Day).
Stay tuned for more Kubernetes insights on our #30DaysOfKubernetes journey! 🚀🌐
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 in the Next Chapter 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.