Video Thumbnail for Lesson
12.3: Helm

Helm

Helm is a package manager and templating engine for Kubernetes. This section shows how a simple chart can be used to deploy the api-golang service to different environments.

Chart Overview

The sample chart lives in the course repository under 12-deploying-to-multiple-environments/helm. Its structure looks like:

api-golang-helm-chart/
  Chart.yaml
  values.yaml
  values.production.yaml
  templates/

Chart.yaml defines metadata for the chart. The default values.yaml exposes a few settings:

environmentPostfix: ""
replicas: 1
version: DEFAULT_VERSION

The templates use these values. For example Deployment.yaml injects the image tag and replica count:

spec:
  replicas: {{ .Values.replicas }}
  containers:
    - name: api-golang
      image: sidpalas/devops-directive-docker-course-api-golang:{{ .Values.version }}

IngressRoute.yaml appends environmentPostfix to the hostname so each environment can have a unique URL.

Rendering Manifests

Preview the generated manifests with helm template:

helm template ./api-golang-helm-chart | yq
helm template ./api-golang-helm-chart --values values.production.yaml | yq

The accompanying Taskfile.yaml provides tasks such as task template-production to make this easier.

Installing the Chart

Deploy the service by running:

helm upgrade --install api-golang ./api-golang-helm-chart \
  -f values.production.yaml -n demo-app

Passing different values files lets the same chart configure multiple environments.

Packaging and Publishing

Charts can be packaged and pushed to a registry:

helm package ./api-golang-helm-chart
helm push api-golang-helm-chart-0.1.0.tgz oci://registry-1.docker.io/sidpalas

These commands (also available via task package and task push) produce a .tgz artifact and upload it for others to consume.