Skip to content

Provisioning prepackaged stacks easily on Kubernetes with helm

Today I am going to show how to provision prepackaged k8s stacks with helm.

So what is Helm – here is literally what is’t page says – a tool for managing Kubernetes charts and Charts are packages of pre-configured Kubernetes resources. So imagine you want to provision some stack, ELK for example, although there are many ways to do it, here is one I did as an example for Jenkins logs although not on k8s but with just docker, but nevertheless, so instead of reinventing the wheel you just provision it using helm.

So let’s just do it instead of talking.

Go to download page and get the right version from

Then untar, move to right dir and run:

➜  tar -xzvf helm-v2.7.2-darwin-amd64.tar.gz

➜   mv darwin-amd64/helm /usr/local/bin

➜   helm
The Kubernetes package manager

To begin working with Helm, run the 'helm init' command:

	$ helm init

So let’s do what is asks:

helm init
Creating /Users/kayanazimov/.helm
Creating /Users/kayanazimov/.helm/repository
Creating /Users/kayanazimov/.helm/repository/cache
Creating /Users/kayanazimov/.helm/repository/local
Creating /Users/kayanazimov/.helm/plugins
Creating /Users/kayanazimov/.helm/starters
Creating /Users/kayanazimov/.helm/cache/archive
Creating /Users/kayanazimov/.helm/repository/repositories.yaml
Adding stable repo with URL:
Adding local repo with URL:
$HELM_HOME has been configured at /Users/kayanazimov/.helm.

Tiller (the Helm server-side component) has been installed into your Kubernetes Cluster.
Happy Helming!	

We are now ready, let’s go with simple stack, mysql:

helm install --name mysqldb --set mysqlRootPassword=myrootpass,mysqlUser=myuser,mysqlPassword=mypass,mysqlDatabase=mydb stable/mysql
NAME:   mysqldb
LAST DEPLOYED: Wed Dec 20 16:26:23 2017
NAMESPACE: default

==> v1/Secret
NAME           TYPE    DATA  AGE
mysqldb-mysql  Opaque  2     1s

==> v1/PersistentVolumeClaim
NAME           STATUS  VOLUME                                    CAPACITY  ACCESS MODES  STORAGECLASS  AGE
mysqldb-mysql  Bound   pvc-852e3884-e5a2-11e7-8d68-0800277dff3a  8Gi       RWO           standard      1s

==> v1/Service
mysqldb-mysql  ClusterIP  <none>       3306/TCP  0s

==> v1beta1/Deployment
mysqldb-mysql  1        1        1           0          0s

==> v1/Pod(related)
NAME                            READY  STATUS   RESTARTS  AGE
mysqldb-mysql-7848c56495-qnc8d  0/1    Pending  0         0s

MySQL can be accessed via port 3306 on the following DNS name from within your cluster:

As you can see it created Deployment, PersistentVolumeClaim, Secret, etc all resources needed and you can view secret for example by doing:

kubectl get secret --namespace default mysqldb-mysql -o jsonpath="{.data.mysql-root-password}" | base64 --decode; echo

Now let’s install and run a mysql client on ubuntu and try to connect to db:

kubectl run -i --tty ubuntu --image=ubuntu:16.04 --restart=Never -- bash -il

apt-get update && apt-get install mysql-client -y

root@ubuntu:/# mysql -h mysqldb-mysql -p
Enter password:

Once inside put your password ‘myrootpass’ and it is ready, let’s show databases:

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 90
Server version: 5.7.14 MySQL Community Server (GPL)

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
| Database           |
| information_schema |
| mydb               |
| mysql              |
| performance_schema |
| sys                |
5 rows in set (0.00 sec)

As you can see, in couple steps you have fully ready mysql stack with persistence etc preconfigured with a single line of helm code. It is quite cool!