How to manage your Helm Charts by using Helmfile

Reading Time: 5 minutes

In this blog, we will learn the concepts of Helm and Helmfile so, Stay Tuned!

First, let us understand what is Helm?

Helm is the package manager for Kubernetes. Therefore, think of it as Apt, Yum, and Homebrew for Kubernetes, it is a convenient way of packaging and collecting Kubernetes YAML files and distributing them in public and private repositories.

Example:- You want to deploy your application on Kubernetes cluster. Now, you want to deploy Elastic Search also in your cluster so that your application use it to collect logs.

Therefore, in order to deploy an elastic stack in your Kubernetes cluster, you need some components like:-

  • Firstly, stateful sets(for stateful applications like Databases)
  • Secondly, configMap(for external configuration)
  • Thirdly, secrets(for credentials) etc.

Now, if you create these files manually searching through the Internet and applying them is a tedious job. It is better if someone makes these YAML files once and packages them somewhere so other people can use them. So, this package or bundle of YAML files is known as HELM CHARTS.

You can create your own helm charts, PUSH them to the helm repository to make them available to others and also you can download and use the existing ones.

Example:- Database applications and Monitoring applications, they are very complex so there charts are already available.

Use case

When you deploy the same set of applications in different environments.

Example:- You have your microservice application in your Kubernetes cluster that you want to deploy on Development, Staging and Production environment.

So, instead of deploying a single YAML file separately in each cluster, you can package them up in your own chart.

That chart will have all the necessary YAML files that a particular deployment needs.

Helm chart structure

Chart is made up of some directory structures in which we have:-

  • CHARTS- charts will have chart(folder) dependencies.
  • CHARTS.YAML- CHARTS.YAML contains the meta-information about the chart(like version, name, dependencies, etc).
  • HELPERS.TPL- It contains the values and configurations in the template that can be reused again and again by namespace, service, or any other of the manifest.
  • TEMPLATE- A template is a directory of templates that, when combined with values, will generate valid Kubernetes manifest files.
  • VALUES.YAML- VALUES.YAML is the one place where you go, update and modify the configuration so that, the helm can fetch those values and update them inside the DEPLOYMENT.YAML.

Difference between Helm 2 and Helm 3

Version 2 comes in two parts, we have:-

Whenever you deploy the helm chart using helm install [chartname], the helm client will send the YAML files to the tiller that runs in the Kubernetes cluster.

Tiller will execute this request and create components from these YAML files inside the Kubernetes cluster.

Whenever you create or change deployment, tiller will store a copy of each configuration that client sends for future refernces.

Release management keeps track of all chart executions:-

  • When you do helm install, helm upgrades the changes that are applied to the existing deployment instead of creating a new one. Moreover, we can also do rollback in helm.

Disadvantages:-

  • Firstly, the tiller has too much power inside the Kubernetes cluster
  • Secondly, it can create, update and delete components and it has too many permissions
  • Thirdly, it becomes a big security issue that’s why the tiller is removed from Helm 3.

How Helm charts are managed by Helmfile?

Helmfile is a very simple YAML or a configuration file where you only need to mention your helm chart. With the helmfile, we are going to manage our helmfile means we are going to install, uninstall and also do multiple helm chart deployments.

NEED:-

Instead of installing charts one by one, using the helmfile we can install multiple charts using this one YAML file.

Now, let’s move to the Demo part

1. Download Helmfile

Link- helmfile_linux_amd64

2. Change the name of the file

mv helmfile_linux_amd64 helmfile

3. Change the permission of the file

chmod 777 helmfile

4. Move the file to /usr/local/bin

mv helmfile /usr/local/bin

5. Chech the version

helmfile --version

6. Create a chart

helm create [chartname]

helm create dev-chart

7. Now, create helmfile for the helm chart

--- 
releases:

  - name: devops

    chart: ./dev-chart

    installed: true

In this file, you have to specify the release name for your chart, likewise, the chart that you want to install, and installed: true means to install the chart using the helmfile.

8. To install the chart

helmfile sync

OUTPUT:-

In order to verify the output, use kubectl get pods, deployments, etc.

9. Verify installation

helm list

OUTPUT:-

How to deploy multiple charts using Helmfile?

1. Create charts

helm create kubernetes

helm create revision

helm create docker

2. Now, create helmfile

---
releases: 

  - name: kube

    chart: ./kubernetes

    installed: true

  - name: notes

    chart: ./revision

    installed: true

  - name: container

    chart: ./docker

    installed: true

OUTPUT:-

As you can see all the charts are installed successfully by using a single file only

3. For verification

helm list

4. Therefore, to uninstall chart using the file

---
releases:
 
  - name: kube

    chart: ./kubernetes

    installed: false
Just write false in place of true

CONCLUSION:-

To reduce your time, therefore, use helmfile to install your charts.

REFERENCES:-

Helm

Helmfile

Leave a Reply