How to Create a Simple Helm Chart
Tags: helm, kubernetes, beginners, tutorial
Published: 2022-07-13 09:34:44

The world of DevOps has given so many opportunities for software organizations. Software development best practices have given rise to many platforms and tools to deploy software quickly and easily. Kubernetes and Helm can do so much together in helping developers deploy software with less effort. Kubernetes is the most popular open-source platform for running container-based apps in the enterprise. In fact, organizations aim at running all their production deployments on Kubernetes. 

These are exciting times for those in the Kubernetes community because we’re seeing more and more users leverage its extended capabilities for even deeper operational insight and control. One such capability is the use of Helm to package and deploy individual Kubernetes applications. 

###What is Helm?

![what is helm](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8254r1dvv0qibnaydqgc.png)_**Image credits: IBM Developer**_

Helm is a popular open-source tool for managing Kubernetes clusters. It simplifies the process of installing, updating, and removing applications on your cluster by packaging them as "charts." These charts are then installed on your cluster with one command. 

Helm relies on the concept of charts. A chart is an archive of all the resource definitions that are needed to deploy an application to Kubernetes, including the configuration files and scripts needed for deployment. To get started with Helm, you need to create a chart for your application or find one online that suits your needs. Today, we will see a simple tutorial on how to create a simple Helm chart.

You can quickly install software onto your Kubernetes cluster, and the public Helm charts are readily available in the [ArtifactHub](https://artifacthub.io/).

![Artifact Hub](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0y78t2xb0xc5jke8q4dy.png)

###Pre-requisites for this tutorial:
- Install Helm from [the official Helm website](https://helm.sh/docs/intro/install/)
- Install [Rancher Desktop](https://rancherdesktop.io/) or [Docker Desktop](https://www.docker.com/products/docker-desktop/) (with Kubernetes enabled) 
- Signup for the [Harness Software Delivery](https://app.harness.io/auth/#/signup) Platform to deploy to any Kubernetes environment

###Tutorial: Create a Simple Helm Chart
Use your terminal to create a new directory to store our code

```
mkdir helm-example
```

```
cd helm-example
```

Create a new chart and give it a name as you wish

```
helm create new-chart
```

This creates a simple chart that will deploy an Nginx pod.

You should see the output on your terminal as below, 
`Creating new-chart`

Change the directory into the folder of the new chart that we just created, 

```
cd new-chart
```
With `ls` command, you can see the contents of the new-chart folder

`Chart.yaml`	`charts`	`templates`	`values.yaml`

Keeping everything as it is, we will deploy our first chart

```
helm install new-chart ./helm-example/new-chart
```

**Note:** Use this command outside of your directory to set the path correctly as shown.

![new chart](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mhkw0sa2fu07zz1cqhj3.png)

With the command `helm ls` you can see your deployed helm chart.

![helm ls](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/osw2hi28fzcz221oyyus.png)

You can also confirm that the pods are up and running with the command 

```
kubectl get pods
```

![get pods](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/octjy8ozptawvwifp5zj.png)

I am using Rancher Desktop so it is easy to access the deployed chart. You can download [Rancher Desktop from their official website](https://rancherdesktop.io/).

![port forward](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0pm1x4ed045nq4jcb20m.png)

And when I check my localhost:56253, I can see the nginx container running.

Like I said before, if you are using Rancher Desktop, it is very easy to access your newly deployed app.

![Rancher Desktop](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7tr8q0ljlgz92be4gou9.png)

Next, you can package this chart to share it with anyone with the command

```
helm package ./new-chart
```

![new chart helm](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kyml7xvy55bpcj8elc9v.png)

It is very easy to use Helm charts and do deployments with Harness CD. Further in this tutorial, let us see how to deploy a publicly available Docker image to your Kubernetes cluster using Helm charts and a Rolling deployment strategy through Harness CD. 

Assuming you have a Kubernetes cluster setup with 3 nodes, 4vCPU machine type, 16GB memory, and 100GB disk.

Head on to [app.harness.io](http://app.harness.io) and signup if this is your first time using the Harness platform. 
Once you login, switch to the NextGen mode which is the advanced and new version.

Create a project with any name you want, select continuous delivery and start creating the pipeline to deploy a MongoDB chart.

![helm tutorial](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8ymiheelhdj335jw6r14.png)

Every stage is self-explanatory - Add the required fields. Specify the service, select deployment type as Kubernetes, add the manifest details as Helm chart and you need to create a New HTTP Helm repo connector. 


![Helm chart store](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/odtnex4njl1c0b9t5j8o.png)

I have already created the HTTP Helm Repo Connector, you have to create a new one if you are new. 

Once you click on + HTTP Helm Repo Connector, it will ask for some details and you need to provide them. Provide Helm Repository URL as [https://charts.bitnami.com/bitnami](https://charts.bitnami.com/bitnami) as we are using the official chart. 

![manifest details](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/euvr036moxsjkygxea5y.png)

In the infrastructure setup, give cluster details.

![cluster details](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ps6llpn0lerv2e26y3q0.png)

In the execution step, select the Rolling deployment strategy.

![rolling deployment](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/66vwlozuke0v5sebg2lv.png)

Once everything is set up, save the pipeline and run it.

![Helm quickstart](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d3m6l7e9gs5igsdw95y2.png)

![Helm start](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u8l0wp0z958lem7yy8af.png)

You should see a successful deployment of the MongoDB image.

![Helm deployment](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nmv7npt3muo9yss8y6ea.png)

![Helm deploy](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/513oyfiphoz91z25bjgq.png)

Confirm that by going to your cluster set-up. I have my cluster created on GCP and I can confirm that the MongoDB image has been successfully deployed through the Helm chart.

![terminal](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nhz1nfbtwu0st99nu42b.png)

Congratulations!!! You have successfully learned how to create a helm chart and deploy it with the help of [Harness](https://app.harness.io/auth/#/signup/).