Helm is a package manager for Kubernetes. This guide covers how you can quickly get started using Helm. Obviously, you must have Kubernetes installed.

Install Helm

The Helm project provides two ways to fetch and install Helm: from the binary releases (in this case you can choose a specific version) or from script. These are the official methods to get Helm releases. In addition to that, the Helm community provides methods to install Helm through different package managers (unfortunately there are no packages for RockyLinux). 

We choose the installation via the script, that will automatically grab the latest version of Helm and install it locally. Let's download the script, change the permissions and launch it

get_helm.sh
$ curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3
$ chmod 700 get_helm.sh
$ ./get_helm.sh

Initialize a Helm Chart Repository

Once you have Helm ready, you can add a chart repository. One popular starting location is the official Helm stable charts

Add, update and list repo
$ helm repo add stable https://charts.helm.sh/stable
# Make sure we get the latest list of charts
$ helm repo update
# List chart repositories
$ helm repo ls
NAME                    URL
stable                  https://charts.helm.sh/stable

Once this is installed, you will be able to list the charts you can install

List available charts
$ helm search repo stable
NAME                                    CHART VERSION   APP VERSION                     DESCRIPTION
stable/acs-engine-autoscaler            2.2.2           2.1.1                           DEPRECATED Scales worker nodes within agent pools
stable/aerospike                        0.2.8           v4.5.0.5                        A Helm chart for Aerospike in Kubernetes
stable/airflow                          4.1.0           1.10.4                          Airflow is a platform to programmatically autho...
stable/ambassador                       4.1.0           0.81.0                          A Helm chart for Datawire Ambassador
# ... and many more

Install an Example Chart

Let's briefly see a couple of basic commands. To install a chart, you can run the helm install command. Helm has several ways to find and install a chart, but the easiest is to use one of the official stable charts

Install chart
$ helm install <chart_name> stable/mysql [-n <namespace>]
WARNING: This chart is deprecated
NAME: mysql-1612351953
LAST DEPLOYED: Wed Feb  3 11:32:36 2021
NAMESPACE: default
STATUS: deployed
REVISION: 1
NOTES:
MySQL can be accessed via port 3306 on the following DNS name from within your cluster:
mysql-1612351953.default.svc.cluster.local

To get your root password run:

    MYSQL_ROOT_PASSWORD=$(kubectl get secret --namespace default mysql-1612351953 -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 mysql-1612351953 -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/mysql-1612351953 3306

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

You get a simple idea of the features of a chart, even before installing it, by running helm show chart <chart_name>

It's easy to see what has been released using the helm list function, that will show you a list of all deployed releases

List deployed charts
$ helm ls [-n <namespace>]
NAME                    NAMESPACE       REVISION        UPDATED                                 STATUS          CHART           APP VERSION
mysql-1612351953        default         1               2021-02-03 11:32:36.136264337 +0000 UTC deployed        mysql-1.6.9     5.7.30

Finally, to uninstall a release, use the helm uninstall command

Unistall chart
$ helm uninstall mysql-1612351953 [-n <namespace>] [--keep-history]
release "mysql-1612351953" uninstalled

This will uninstall the chart from Kubernetes, which will remove all resources associated with the release as well as the release history. If the flag --keep-history is provided, release history will be kept. In this case, you will be able to request information about that release using helm status <chart_name>. Because Helm tracks your releases even after you've uninstalled them, you can audit a cluster's history, and even undelete a release (with helm rollback). 

  • No labels