Published on

Kubernetes Helm Basics

Authors

Up until recently the Kubernetes infrastructure I have worked with has been bare bones standard yaml. This was very useful as it helped give me a view of how the different pieces in Kubernetes fit together. But there is a much better and easier way to manage apps in a Kubernetes environment - Helm. Helm is to Kubernetes what Maven/Gradle is to Java or pip is to Python. It is the Kubernetes package manager.

To install it simply follow the install guide. To install this on Linux it is slightly more involved but still fairly straightforward using the official script.

Once it is installed point kubectl to the cluster that you want to run Helm on and in the same shell run:

helm init

What this does is install the Helm Tiller pod on your target cluster. Tiller is Helm's server for managing dependencies on your cluster. To make life easier lets turn on Helm command completion by adding the following to our .bashrc:

source <(helm completion bash)

If you are using zsh simply swap bash for zsh and add this line to your .zshrc. I have added the following alias to my .bashrc to make it much easier for me to switch between Kubernetes clusters:

alias set-k8s-env-minikube='export KUBECONFIG=~/.kube/config.minikube'
alias set-k8s-env-your-other-cluster='export KUBECONFIG=~/.kube/config.yourothercluster'

And for safety I always make new shells point to minikube (I would rather mistakenly wipe minikube than an entire cluster):

export KUBECONFIG=~/.kube/config.minikube'

To install something you can search for the chart (this is Helms terminology for the recipe for the app you want) on Kubeapps. You can also use the helm command line tool to search helm search appYouAreLookingFor.Once you find what you want install it as below:

helm install stable/grafana --version 1.10.2

You can instruct helm as to which namespace to put the app into otherwise if you leave off --namespace this will go into the default namespace:

helm install stable/grafana --version 1.10.2 --namespace alpha

If you are done with a given app and want to remove it first find out what name it has (if you did not provide it a name with --name nameYouWant):

> helm list
NAME            REVISION        UPDATED                         STATUS          CHART           NAMESPACE
running-hydra   1               Thu Jun  7 16:08:20 2018        DEPLOYED        grafana-1.10.2  alpha
wishful-pike    1               Thu Jun  7 16:06:56 2018        DEPLOYED        grafana-1.10.2  default

Then delete the app you no longer want:

helm delete running-hydra