Kubernetes

How to Make a Kubernetes Helm Chart

Helm is commonly referred to as Kubernetes’ package manager. Although it appears to be a basic package manager, it has more capabilities. Helm is a fully accessible project that was originally developed by DeisLabs and is now maintained by CNCF. Helm was created to give users the best way to handle all of the Kubernetes YAML files they build on Kubernetes projects.

Helm Charts are a set of Kubernetes YAML artifacts that can be distributed to your Kubernetes clusters as a single package. It also maintains a version history with all released maps allowing you to revert to an old iteration if anything unexpected happens. This chart comes with native Kubernetes assistance so you won’t have to write any complicated syntax files or something to get started with Helm. Simply drag your design files into a new chart and you are done.

This step-by-step guide walks you through the process of creating and deploying a Helm chart in Kubernetes.

Pre-Requisites

To make a Kubernetes helm chart on Ubuntu 20.04 LTS, make sure you have installed and configured minikube in your system. You must have sudo privileges for the implementation of this detailed article.

Steps to Create Helm Chart

To create a helm chart in Ubuntu 20.04, initially, you have to open the command line terminal. You can complete this task by navigating through applications or by simply using the shortcut key of Ctrl+Alt+T.

As soon as your terminal window is popped up, you have to execute the following written command in your terminal to install Helm on your system.

$ Sudo snap install helm --classic

As you can see from the above-attached screenshot, that helm is already installed in our system. If it is not present, the installation will begin after the execution of the above-cited command.

To verify the installation of the helm, you can use the following listed command. The output will return a path to the helm.

$ which helm

Now, this is the time to create a helm chart. For this purpose, you have to execute the listed command in your terminal.

$ Helm create linuxhint

Note: You can replace “linuxhint” with any of your desired names. From the output displayed below, you can see that the chart has been created. If you want to view the structure of your created helm chart, you can execute the below-listed command.

$ Ls linuxhint

The created chart directory includes charts, chart.yaml, templates, and values.yaml files.

Now you have to make little amendments to the values.yaml file. To view values.yaml file, you have to navigate through the files directory and open this file in any text editor.

As soon as you open values.yaml file, you have to locate the below-shown image values in the file. You can currently see that the value of pullPolicy is “IfNotPresent”.

You have to update the value of pullPolicy as “Always”. The updates are shown in the below-cited image. You can also see that we have updated the following fields as:

nameOverride: “linuxhint-app”

fullnameOverride: “linuxhint-chart”

Do remember that these changes will help you in the creation of your desired helm chart.

Currently, in the service account field, you can see that the “name” has no value in it.

You have to add your required name in this field. In our scenario, we have updated this field as:

Name: “linuxhint”

When you operate the cluster, the service account name for the Helm chart is created. However, a manual setting is a good idea. The service account name ensures that the program is specifically linked to a relevant chart-controlled user. It is empty by default, but you can set it as per your desire.

Now, it is time to modify the networking service type. Initially, it is as follows:

Type: ClusterIP

It is recommended to use NodePort. So, we have replaced “ClusterIP” with “NodePort” as shown in the attached snapshot.

After updating all fields in the values.yaml file. You have to save all changes and close.

Deployment of Helm Chart

The deployment of the helm chart can be done by the implementation of the appended steps mentioned in this guide. Initially, you have to install the already created helm chart. For this purpose, you have to write the following command in your Ubuntu 20.04 LTS terminal:

$ helm install linuxhint-chart linuxhint/ --values linuxhint/values.yaml

You can add the full name override and chart name the same as you have mentioned in your values.yaml file. In the output of this command, you can see that the application has been deployed successfully.

In the attached image, you can see “Get the application URL by executing these commands”.

So, to get the pod Node Port, you have to run the first export command mentioned in the above image. There will be no output upon the execution of this command.

Now, to get the pod Node Port again, you have to run the second export command mentioned in the above image. Again, there will be no output upon the execution of this command.

The echo command was also displayed. For the installation of the helm chart, you just need to copy that command and execute it.

$ Echo http://$NODE_IP:$NODE_PORT

This command will return the IP address and port number.

Now, you have to copy the displayed IP address and port number and write it into your favorite browser. You can view that the application has been successfully deployed.

Conclusion

In this guide, we have explained to you the usage of the helm chart in Kubernetes along with the creation of the helm chart, its installation, and deployment. I believe, after following every step, you can easily create your helm chart.

About the author

Kalsoom Bibi

Hello, I am a freelance writer and usually write for Linux and other technology related content