Getting your Hands Dirty with Helm!!!

I am assuming you have running Kubernetes cluster and Kubeconfig file on your local machine.

If you are new to helm please go through my fist blog on what is helm ?.

Letssss get started with Helm!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

1) How to install helm:

Download the binary of helm :

https://kubernetes-helm.storage.googleapis.com/helm-v2.4.1-linux-amd64.tar.gz

Github Url: https://github.com/kubernetes/helm

Extract the tar file and move helm binary to /usr/local/bin/

2) Getting started with Helm:

Type $ helm init command to initialize the helm charts/repository on your local machine.

Helm is made of two components: A server called Tiller, which runs inside your Kubernetes cluster and a client called helm that runs on your local machine. A package is called a chart to keep with the maritime theme.

It will deploy a tiller pod in your Kube cluster as Deployment object.

You can try basic commands to check wheather everything is working fine .

e.g helm search jenkins

root@base-station:/home/manoj/# $ helm search jenkins

NAME VERSION DESCRIPTION

stable/jenkins 0.6.2 Open source continuous integration server. It s…

To install jenkins in Kubernetes using helm

$ helm install stable/jenkins

As you can see it will create all the neccessary objects such as Deployment ,Service ,ConfigMap,Secrets etc.

Thats how easy it is with helm charts !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

3) Creating your custom charts using helm :

First you need to create your project

$ helm create sample-php-app

Directory structure that will be created inside your sample-php-app is as below:.

| — charts

| — Chart.yaml

| — templates

| | — deployment.yaml

| | — _helpers.tpl

| | — ingress.yaml

| | — NOTES.txt

| ` — service.yaml

` — values.yaml

Chart.yaml contains metadata about the chart. You can use the defaults.

  • charts/ holds any dependency charts. You can delete this folder now. This is used when building a chart from component charts.
  • templates/ holds all of your template files! This is where you do your work.
  • values.yaml holds any variables you want to reference in your templates. These are the configuration options you present to the end user.

Note : Pass all the necessary varaible into values.yaml file .

My reference values.yaml file in GitHub:

Note : I have changed type to NodePort from ClusterIP as i want to access the application from internet.

4) So before deploying application in Kube cluster you can have dry run in debug mode to check wheather everything is working fine.

$ helm install — dry-run — debug — name sample-php-app — namespace default sample-php-app/

5) Now you can deploy the application in your Kube clsuter using Helm

$ helm install — name sample-php-app — namespace default sample-php-app

It has created a deployment object as well as Service with Type as NodePort in Kube Cluster

Now you can access the application using PUBLIC IP of your worker node & NodePort

6) How to Upgrade and Deploy application using helm.

Update the image tag in values.yaml and Chart version in Charts.yaml

Now you are all set to upgarde your application version using helm

$ helm upgrade sample-php-app sample-php-app/

Bingoooo !!!!! Maggiccc it has done rolling update in background with Zero-downtime

7) Rollback Application to old version using helm

$ helm history sample-php-app

Above command will give you the revision history

So currently i am running version 3 in cluster now i want to roll back to previuos version 2.

$ helm rollback sample-php-app 2

It will rollback your application to prevsious version with image having tag as 1 and version 2 .

7) To check all the deploymets done using helm :

$ helm list

8) Delete application using helm:

$ helm delete sample-php-app

Great!!!!!!! It has deleted all the objects it has created in Kubernetes cluster.

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.