Helm

Page content

What is Helm

https://www.youtube.com/watch?v=fy8SHvNZGeE

Install

https://helm.sh/docs/intro/install/

From built code - I prefer this way personally

curl https://get.helm.sh/helm-v3.8.2-linux-amd64.tar.gz -o helm.tar.gz
tar -xzvf helm.tar.gz
sudo mv ./linux-amd64/helm /usr/local/bin/
rm -rf ./linux-amd64

Via apt

curl https://baltocdn.com/helm/signing.asc | gpg --dearmor | sudo tee /usr/share/keyrings/helm.gpg > /dev/null
sudo apt-get install apt-transport-https --yes
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/helm.gpg] https://baltocdn.com/helm/stable/debian/ all main" | sudo tee /etc/apt/sources.list.d/helm-stable-debian.list
sudo apt-get update
sudo apt-get install helm

Use

Quickstart

https://helm.sh/docs/intro/quickstart/

Added 20.Apr.2022: the stable/mysql is deprecated. Refer to official quickstart (the repository is replaced by bitmani).

  1. Add (Register) a repository called stable on your local machine. helm repo add stable https://charts.helm.sh/stable
  2. Update the repository. helm repo update
  3. Search charts from stable repositroy. helm search repo stable
  4. Create (deploy) a chart. example of MySQL, helm install stable/mysql --generate-name
  5. Check. helm ls or ```.
➜ helm ls
NAME            	NAMESPACE	REVISION	UPDATED                                 	STATUS  	CHART      	APP VERSION
mysql-1650461792	default  	1       	2022-04-20 15:36:34.432169643 +0200 CEST	deployed	mysql-1.6.9	5.7.30

➜ kubectl get deployments
NAME               READY   UP-TO-DATE   AVAILABLE   AGE
mysql-1650461792   1/1     1            1           4m26s
  1. Delete. helm uninstall mysql-1650461792

Create your own chart

helm create my_project

Change my_project/values.yaml

After changing, check the syntax by helm lint and helm package my_project.

Optionally, I recommend to use trivy for production usages: https://aquasecurity.github.io/trivy/v0.30.4/

Appendix

Deploy log of helm

$ helm install stable/mysql --generate-name
WARNING: This chart is deprecated
NAME: mysql-1615723624
LAST DEPLOYED: Sun Mar 14 13:07:07 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-1615723624.default.svc.cluster.local

To get your root password run:

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

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