How to Create your first Helm Charts kubernetes

Are you spending hours or even days to deploy applications in kubernetes because of dozens of deployment yaml files which are unorganised? Instead why not consider helm charts the best tool for deploying and building efficient clusters in Kubernetes.

In this tutorial, you will learn step-by-step how to create a Helm chart, set up, and deploy on a web server. Helm charts simplify application deployment on a Kubernetes cluster.

Without any delay, lets dive into it.

Join 50 other followers

Table of Content

  1. What is Helm?
  2. What is Helm charts in kubernetes?
  3. Prerequisites
  4. How to Install Helm on windows 10
  5. How to Install Helm on Ubuntu machine
  6. Installing Minikube on Ubuntu machine
  7. Creating Helm charts
  8. Configuring the Helm chart
  9. Deploying Helm chart on ubuntu machine
  10. Verifying the Kubernetes application deploying using Helm chart
  11. Conclusion

What is Helm?

Helm is a package manager for kubernetes which makes application deployments and management easier. Helm is a command-line tool that allows you to create a helm charts.

What is Helm charts in kubernetes?

Helm charts is a collection of templates and settings which defines a set of kubernetes resources. In Helm charts, you need to define all the resources which are needed as part of the application and using REST API it communicate with kubernetes cluster.

Helm chart allows you to deploy or manage the application deployment easier in kubernetes cluster and stores various versions of charts.

Prerequisites

  • An ubuntu machine with Kubectl and docker installed. This tutorial will use Ubuntu 20.04 version.

How to Install Helm on windows 10

Now that you have basic idea of what is helm and helm charts in kubernetes, lets kick off this section by learning how to install helm on windows 10 machine.

  • Open the browser and navigate to the Github repository where Helm package is already stored on https://github.com/helm/helm/releases. On the Github page search for Windows amd64 download link.
Downloading the Helm package manager from Github
Downloading the Helm package manager from Github
  • Now, extract the windows-amd64 zip to the preferred location. After you extract you will see helm application.
Extract the Helm package manage on Windows machine
Extract the Helm package manage on Windows machine
  • Now open command prompt and navigate to the same path on which you extracted helm package. Next, on the same path run helm.exe.
Executing the helm package manager
Executing the helm package manager
  • Once helm is installed properly, verify helm by running the below helm version command.
Verifying the helm package manager
Verifying the helm package manager

How to Install Helm on Ubuntu machine

Previously you learned how to install helm on windows 10 machine but in this section lets learn how to install Helm on ubuntu machine.

  • Log in to the Ubuntu machine using your favorite SSH client.
  • Next, download the latest version of Helm package using the below command.
 wget https://get.helm.sh/helm-v3.4.1-linux-amd64.tar.gz
Downloading the latest version of Helm package on ubuntu machine
Downloading the latest version of Helm package on ubuntu machine
  •  Further, package is downloaded then unpack the helm package manager using tar command.
tar xvf helm-v3.4.1-linux-amd64.tar.gz

Unpack the helm package manager
Unpack the helm package manager
  • Now move linux-amd64/helm to /usr/local/bin so that helm command can run from anywhere on ubuntu machine.
sudo mv linux-amd64/helm /usr/local/bin
  • Finally verify helm package manager by running the helm version.
helm version
Verifying the helm package manager on ubuntu machine
Verifying the helm package manager on ubuntu machine

Installing Minikube on Ubuntu machine

Now that you have installed helm package manager successfully on ubuntu machine. But to deploy helm charts you needs kubernetes to be installed on your machine and one of the most widely used lightweight kubernetes cluster is minikube just like a local Kubernetes focusing on making it easy to learn and develop for Kubernetes.

So, lets dive in and install minikube on Ubuntu machine.

  • First download the minikube package on ubuntu machine by running curl command as shown below.
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube_latest_amd64.deb
  • Next, install minikube on Ubuntu machine by running dpkg command.
sudo dpkg -i minikube_latest_amd64.deb
Installing minikube on ubuntu machine
Installing minikube on ubuntu machine
  • Now start minikube with normal user but not with root user by running minikube start command.
minikube start
Starting minikube on ubuntu machine
Starting minikube on ubuntu machine
  • Now verify if minikube is installed properly by running minikube status command.
minikube status
Verifying the minikube on ubuntu machine
Verifying the minikube on ubuntu machine

Creating Helm charts

Now that you have helm and minikube installed successfully on Ubuntu machine. To create helm charts follow the below steps.

  • In the home directory of your ubuntu machine create helm chart by running below command.
helm create automate
Creating a new helm chart
Creating a new helm chart
  • Once helm chart is created it also creates a folder with the same name containing different files.
Viewing the files and folders of helm chart created.
Viewing the files and folders of helm chart created.

Configuring the Helm chart

Now you have Helm chart created successfully which is great, but to deploy application you need to configure files that got generated earlier with helm create command.

  • Chart.yaml file contains details of helm chart such as name, description, api version, chart version to be deployed etc.
  • template: It contains the configurations files required for application that will be deployed to the cluster such as ingress.yaml , service.yaml etc. For this tutorial you dont need to modify this directory.
template directory inside the helm chart folder
template directory inside the helm chart folder
  • charts: This directory contains is empty initially. Other dependent charts are added if required. For this tutorial you dont need to modify this directory.
  • values.yml: This file contains all the configuration related to deployments. Edit this file as below:
    • replicaCount: is set to 1 that means only 1 pod will come up.
    • pullPolicy : update it to Always.
    • nameOverride: automate-app
    • fullnameOverride: automate-chart
    • There are two types of networking options available a) ClusterIP address which exposes service on cluster internal IP and b) NodePort exposes service on each kubernetes node IP address. You will use NodePort for this tutorial.

Your values.yaml file should look like something below.

replicaCount: 1

image:
  repository: nginx
  pullPolicy: Always
  # Overrides the image tag whose default is the chart appVersion.
  tag: ""

imagePullSecrets: []
nameOverride: "automate-app"
fullnameOverride: "automate-chart"

serviceAccount:
  # Specifies whether a service account should be created
  create: true
  # Annotations to add to the service account
  annotations: {}
  # The name of the service account to use.
  # If not set and create is true, a name is generated using the fullname template
  name: "automateinfra"

podAnnotations: {}

podSecurityContext: {}
  # fsGroup: 2000

securityContext: {}
service:
  type: NodePort
  port: 80

ingress:
  enabled: false
  annotations: {}
    # kubernetes.io/ingress.class: nginx
    # kubernetes.io/tls-acme: "true"
  hosts:
    - host: chart-example.local
      paths: []
  tls: []
  #  - secretName: chart-example-tls
  #    hosts:
  #      - chart-example.local

resources: {}
autoscaling:
  enabled: false
  minReplicas: 1
  maxReplicas: 100
  targetCPUUtilizationPercentage: 80
  # targetMemoryUtilizationPercentage: 80

nodeSelector: {}

tolerations: []

affinity: {}

Deploying Helm chart on ubuntu machine

Now that you’ve made the necessary changes in the configuration file to create a Helm chart, next you need to deploy it using a helm command.

helm install automate-chart automate/ --values automate/values.yaml
Deploying the applications using helm chart
Deploying the applications using helm chart
  • Helm install command deployed the application successfully, next run export commands to retrive Node_Port and Node_Ip details as shown below.
export NODE_PORT=$(kubectl get --namespace default -o jsonpath="{.spec.ports[0].nodePort}" services automate-chart)

export NODE_IP=$(kubectl get nodes --namespace default -o jsonpath="{.items[0].status.addresses[0].address}")

Verifying the Kubernetes application deploying using Helm chart

Previously you deployed application using helm install command but it is important to verify if application is successfully deployed. To verfiy perform below steps:

  • Run echo command as shown below to obtain the application URL. Node_Port and Node_IP were fetched when you executed export command in previous section.
echo http://$NODE_IP:$NODE_PORT
Verifying the kubernetes application URL
Obtaining the kubernetes application URL
  • Next run the curl command to test the application.
Running the Kubernetes application
Running the Kubernetes application

Verifying the Kubernetes pods deployed using Helm charts

Application is deployed successfully and as you can see nginx page loaded but lets verify from kubernetes pods by running the below kubectl command.

kubectl get nodes
kubectl get pods
Kubernetes pods and Kubernetes Nodes
Kubernetes pods and Kubernetes Nodes

Conclusion

After following the outlined step-by-step instructions, you have a Helm chart created, set up, and deployed on a web server. Helm charts simplify application deployment on a Kubernetes cluster.

Which applications do you plan to deploy next on kubernetes cluster using helm charts.

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s