Helm Quick Start — The Package Manager for Kubernetes (K8S)

Shashir
Nerd For Tech
Published in
5 min readSep 26, 2021

--

Let’s start with quick introduction to Kubernetes :

Kubernetes (K8S) is an opensource container orchestration tool which reduce manual process by automating deployments, scaling and managing containerized applications.

Basic Kubernetes components:

- Control plane — Control K8S Nodes and assigns tasks.
- Nodes — Actual machines that perform requested tasks.
- Pod — Smallest unit of K8S in which one or more containers deployed to a K8S node.
- Namespace — It’s like a virtual cluster on the same where we can create K8S objects.
- Service — It’s a logical collection of pods within the cluster which defines an abstract way to load balance and expose an application deployed on pods.
- ReplicaSet — Indicates number of copies of the pod to run within the K8S Cluster.
- Deployment — It runs one or more replicas of the application and replace failed instances automatically.
- Kubectl — Command line tool for K8S.
- Minikube — run local K8S cluster.

Photo by Loik Marras on Unsplash

Helm is a package manager for Kubernetes, which automates most of the repetitive work for creating Kubernetes manifests.

In Helm terms, Charts are nothing but K8s packages. Helm helps us to create new charts and package them into an archive or make use of existing charts in the chart repository (explained below).

Helm-2 Client-Server Architecture

- A Helm client (CLI tool)
- Tiller — Server component

We use above two components to deploy and manage application packages on K8S cluster.

Helm Client will help us to deploy and manage Releases, which communicate with Tiller server — combines Chart and Config into a Release which in-turn creates all K8S resources on Kubernetes cluster by maintaining it’s Release state. Tiller also maintains all the Release information in a config-map on the same namespace which helps Helm during upgrade.

Helm-3 Architecture (Client-only Architecture)

Major change in Helm-3, Tiller(server component) is removed from version 3 due to security reasons

Helm application packages are called Charts — combined with a config, which contains configuration information and merged into a chart to create a Release (running instance of an application).

We can also create our own charts as per the requirement and keep them on our local disk or we can make use of existing Charts already available over github — maintained by the community @ https://github.com/helm/charts/tree/master/stable

Adding Helm package for Kubernetes on windows in 2 steps (presuming Minikube is already installed:

  • Install Chocolatey Package Manager
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))

We can verify Chocolatey installation: ‘choco -v’

Check for outdated packages with Chocolatey: ‘choco outdated’

To upgrade Minikube and Kubernetes-cli outdated packages with choco commands:

choco upgrade minikube
choco upgrade kubernetes-cli
  • Install Helm with Chocolatey

Let’s run choco command on powershell opened in Administrator mode.

choco install kubernetes-helm

Verify Helm version:

Let’s take an example of running MySQL database in K8S cluster, here instead of writing Kubernetes manifest files from the scratch we can search from the list of existing Helm charts. Just we need to clone Git repo (charts) on local machine and run the following command.

Git charts: https://github.com/helm/charts/

Once downloaded, we can run the command from the source directory: “..\charts\stable”

helm install shashir-db mysql

Helm will take care of creating required Kubernetes objects (Deployment, ReplicaSet, Service, Pod) needed to run the MySQL instance properly.

Let’s run kubectl command to get all the K8S objects and verify for what all the Kubernetes objects created automatically with ‘helm install shashir-db mysql command.

To connect MySQL instance we can use steps as below:

PS C:\Users\srs\Desktop\SRS_2021\HELM_Charts\charts\stable> helm install shashir-db mysql
WARNING: This chart is deprecated
NAME: shashir-db
LAST DEPLOYED: Sat Sep 25 17:48:09 2021
NAMESPACE: default
STATUS: deployed
REVISION: 1
NOTES:
MySQL can be accessed via port 3306 on the following DNS name from within your cluster:
shashir-db-mysql.default.svc.cluster.local

To get your root password run:

MYSQL_ROOT_PASSWORD=$(kubectl get secret --namespace default shashir-db-mysql -o jsonpath="{.data.mysql-root-password}" | base64 --decode; echo)

To connect to your database:

1. Run an Ubuntu pod that you can use as a client:

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

2. Install the mysql client:

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

3. Connect using the mysql cli, then provide your password:
$ mysql -h shashir-db-mysql -p

To connect to your database directly from outside the K8s cluster:
MYSQL_HOST=127.0.0.1
MYSQL_PORT=3306

# Execute the following command to route the connection:
kubectl port-forward svc/shashir-db-mysql 3306

mysql -h ${MYSQL_HOST} -P${MYSQL_PORT} -u root -p${MYSQL_ROOT_PASSWORD}

Verify the deployment — “kubectl get deployment”

helm get all shashir-db

I hope you’ve found this article helpful in starting HELM. Here we started with HELM installation with Chocolatey and the HELM components — how it will be used to deploy already existing Helm Charts — eg: MySQL in our case.

References:

https://kubernetes.io/
https://helm.sh/

--

--

Shashir
Nerd For Tech

Middleware Chapter Lead & Java Developer — Java/Python/Spring/Microservices/Kafka/Kubernetes/OCP/Camunda/Splunk/Az Cloud https://www.linkedin.com/in/shashi999