command line, helm, kubernetes

Helm cheat sheet

There is a comprehensive helpful list while using Helm. When command is self-explanatory, there is no description.

Chart repositories

$ helm repo add bitnami https://charts.bitnami.com/bitnami
"bitnami" has been added to your repositories

$ helm search repo apache
NAME                            CHART VERSION   APP VERSION     DESCRIPTION
bitnami/apache                  9.0.1           2.4.52          Chart for Apache HTTP Server
bitnami/airflow                 11.4.1          2.2.3           Apache Airflow is a platform to programmaticall...
bitnami/cassandra               9.1.5           4.0.1           Apache Cassandra is an open source distributed ...
[...]

# get all available versions
$ helm search repo apache --versions
NAME                            CHART VERSION   APP VERSION     DESCRIPTION
bitnami/apache                  9.0.1           2.4.52          Chart for Apache HTTP Server
bitnami/apache                  9.0.0           2.4.52          Chart for Apache HTTP Server
bitnami/apache                  8.12.1          2.4.52          Chart for Apache HTTP Server
bitnami/apache                  8.12.0          2.4.52          Chart for Apache HTTP Server
bitnami/apache                  8.11.1          2.4.52          Chart for Apache HTTP Server
[...]

$ helm repo update
Hang tight while we grab the latest from your chart repositories...
...Successfully got an update from the "bitnami" chart repository
Update Complete. ⎈Happy Helming!⎈


$ helm repo remove bitnami
"bitnami" has been removed from your repositories

Install & upgrade

# uninstall without removing history (keeps secrets in k8s)
$ helm uninstall release-name --keep-history

# create namespace if do not exists
$ helm install release-name bitnami/redis --namespace production --create-namespace

# rollback to #1 release
$ helm rollback release-name 1

# wait for pods to be up & running for 5 minutes
# without --wait flag, helm just sends manifests to api server, without waiting for pods to be ready & healthy
$ helm install release-name bitnami/redis --wait --timeout 5m

# automatically roll to previous deployment if current one failed after 5m
$ helm install release-name bitnami/redis --timeout 5m --atomic

# DELETE & recreate - not RollingUpdate
$ helm upgrade release-name bitnami/redis --force

$ helm upgrade release-name bitnami/redis --cleanup-on-failure

Misc

$ helm get notes release-name

# show all custom values used during installation
$ helm get values release-name
$ helm get values release-name --revision 1

$ helm get values release-name --all

# get manifest files for current release
$ helm get manifest release-name

$ helm history release-name


–dry-run, template & lint

# hence --dry-run does not apply changes to cluster, it needs to connect to k8s api and can be used with install or upgrade commands
$ helm install release-name --dry-run
$ helm upgrade release-name --dry-run

# on the other hand, 'template' command does not need to connect to cluster
$ helm template release-name

$ helm lint chart-folder
==> Linting chart-folder
[INFO] Chart.yaml: icon is recommended

1 chart(s) linted, 0 chart(s) failed

packaging

$ helm create firstchart
Creating firstchart

$ helm package firstchart
Successfully packaged chart and saved it to: /Users/user/Documents/helm-training/firstchart-0.1.0.tgz

templates


dependencies

$ cat Chart.yml
[...]
dependencies:
  - name: redis
    version: 15.5.4
    repository: "https://charts.bitnami.com/bitnami"

# after this step, any dependencies will appear in folder charts/
$ helm dependency update .
Hang tight while we grab the latest from your chart repositories...
...Successfully got an update from the "ingress-nginx" chart repository
...Successfully got an update from the "bitnami" chart repository
Update Complete. ⎈Happy Helming!⎈
Saving 1 charts
Downloading redis from repo https://charts.bitnami.com/bitnami
Deleting outdated charts

# passing custom values to dependent charts - under the same key as name in dependencies array in Chart.yml
$ cat values.yaml
redis:
  service:
    ClusterIP