What is Helm and why do we need it?
Helm is an open source package manager for Kubernetes. Most software development processes need a package manager which can simplify installation and maintenance. However, with increase in the number of components in an infrastructure, managing clusters in Kubernetes can become very complicated. This is where Helm comes into the picture as it wraps up all the components in a single package. It also helps automate software installation, configure software deployments and fetch relevant data. Let's take an example of an app that needs:
- Deployments
- Service to expose the application
- Persistent volume to store data
- Secrets to hold confidential data.
Now, every object of the application requires a separate 'yaml' file. To create these objects, we need to run the 'kubectl' command. Complications may arise in situations where a bug is introduced or we need to modify the value of secrets. In these situations, we need to rollback, which requires revisiting every file individually to keep them in a particular order.
This problem can be solved by creating one huge file and defining all the object resources in it. By doing this, we can avoid frequent rollbacks. But think in terms of the need to modify values in a large file. For example, what if we need to modify the persistent volume size from 10GB to 100GB?. Given the size of the file, we would need to make sure we are making changes in the right place, and also not introduce any new bugs.
Let's take the example of rpm. An application consists of configuration files, binary files, etc. Rather than placing all these files in an individual directory of our system, we can run one rpm command, which will take care of installing all configuration and binary files in an appropriate directory. Helm takes a similar approach to solve this problem in the previous scenario.
It wraps together all the necessary components (deployments, services, secrets, persistent volume) in a single package. Whenever we need to install these resources, we just need to trigger the requirement in Helm to install a package, and it will install all the corresponding resources. Also, we only need to modify a single file (values.yaml) to update all the resources that are packaged using Helm.
Advantages of using Helm
- Application installation with a single command (helm install <application name>) even if it consists of thousands of objects.
- One place to update/modify the resource values (values.yaml).
- Upgrade your application with a single command (helm upgrade <application name>). Helm keeps track of individual objects that require updates.
- Single command to rollback your application (helm rollback <application name>). It maintains records of updates made to the application, so it can rollback to the previous versions.
- Single command to uninstall the app (helm uninstall <application name>). It keeps track of all the objects and knows which object needs to be removed.
Helm Installation
Prerequisites
- A running Kubernetes cluster (For more info, refer here)
- Installed Kubectl (For more info, refer here)
- Helm installation on Mac, Linux, or Windows operating system.
Installation
- To install Helm, run the commands