Basics and Fundamentals

Helm is a packager for Kubernetes that bundles related manifest files and packages them into a single logical deployment unit: Chart. Simplified, for many engineers Helm makes it easy to start using Kubernetes with real applications.

Helm Charts are useful for addressing the installation complexities and simple upgrades of particularly stateless applications like web apps. Say goodbye to the many, long, hard-coded yaml files and embrace an easier way to manage your deployed applications!

Initialize a Helm Chart Repository

You can find a chart with the desired software in the Artifact Hub, parameterize its resources through Helm to deploy to Kubernetes and this eventually brings up said software.

Sometimes, your microservice will persist its data into a database and in this section we will use Helm to install a PostgreSQL database instance from a chart repository. A chart repository is an HTTP server that houses an index.yaml file and optionally some packaged charts.

First check if the Helm repo https://charts.bitnami.com/bitnami is already present:

helm repo list

If the repo is not there, please run the following commands to add it:

helm repo add bitnami https://charts.bitnami.com/bitnami
Make sure we get the latest list of charts by running a periodical update of the repos using helm repo update

Install a Helm Chart

Create a new Kubernetes namespace or project. Alternatively, you can use an existing one:

  • Minikube

  • OpenShift

kubectl create ns dev

#permanently save the namespace for all subsequent kubectl commands
kubectl config set-context --current --namespace=dev
oc create project dev

Deploy a database instance in your namespace with Helm, using the following command:

  • Minikube

  • OpenShift

helm install faq-db --set global.postgresql.auth.username=faq-default,global.postgresql.auth.password=postgres,global.postgresql.auth.database=faq,primary.persistence.enabled=false \
--version 12.1.2  bitnami/postgresql
helm install faq-db --set global.postgresql.auth.username=faq-default,global.postgresql.auth.password=postgres,global.postgresql.auth.database=faq,primary.persistence.enabled=false,\
primary.podSecurityContext.enabled=false,primary.containerSecurityContext.enabled=false \
--version 12.1.2  bitnami/postgresql
For OpenShift, you can define the runAsUser and fsGroup accordingly, based on the security context constraints enabled by administrators.

Validate your installation

When a chart is installed, the Helm library creates a release to track that installation. You can validate the installation via the list command to see the releases that are deployed or failed.

helm list

You should see something similar to:

NAME  	NAMESPACE     	REVISION	UPDATED                              	STATUS  	CHART             	APP VERSION
faq-db	dev	1       	2021-09-20 09:30:55.615499 +0200 CEST	deployed	            postgresql-12.1.2	15.1.0

If you wish to see information about the notes, hooks, supplied values, and generated manifest file of the given release, please use the following command:

helm get all faq-db

The output will be verbose and similar to:

NAME: faq-db
LAST DEPLOYED: Mon Nov 28 11:43:48 2022
NAMESPACE: asotobue-dev
STATUS: deployed
REVISION: 1
TEST SUITE: None
USER-SUPPLIED VALUES:
global:
  postgresql:
    auth:
      database: faq
      password: postgres
      username: faq-default
primary:
  containerSecurityContext:
    enabled: false
  persistence:
    enabled: false
  podSecurityContext:
    enabled: false

COMPUTED VALUES:
.....

You can use the following label selector to find resources managed by Helm in a given namespace:

kubectl get all -l='app.kubernetes.io/managed-by=Helm'
To uninstall a release, use the helm uninstall command. Don’t do that yet as you’ll need this PostgreSQL instance in the following section.