Helm Basics: Package and Deploy Kubernetes Applications
Introduction
Kubernetes applications often need many YAML files that differ slightly between environments. Helm is the package manager for Kubernetes: a chart bundles templates and default settings, and a release is one installed instance of it. This final lesson of the Kubernetes set shows how to use existing charts and how to create your own.
Prerequisites
- A running local cluster
- kubectl working
Step-by-Step Guide
Step 1: Install Helm
Install Helm with your package manager. The Helm project's own documentation also provides an install script, and the package-manager methods are community maintained. Current documentation covers Helm 4, and Helm 3 remains supported, so check which major version you have with helm version.
# macOS
brew install helm
# Windows
winget install Helm.Helm
helm versionStep 2: Install a chart as a release
A chart can come from an OCI registry or from a chart repository. This installs a small sample application as a release named my-podinfo. Use the chart version shown in the current Helm quickstart, since versions change. Use helm list to see releases and uninstall to remove one.
helm install my-podinfo oci://ghcr.io/stefanprodan/charts/podinfo --version 6.11.2
helm list
kubectl port-forward svc/my-podinfo 9898:9898
helm uninstall my-podinfoStep 3: Use chart repositories
Traditional charts live in repositories that you add, refresh, and search. Check a chart's documentation before installing, because repository locations and chart options change over time.
helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo update
helm search repo bitnami
helm repo listStep 4: Customize with values and manage the release
Every chart has default values, which you override with your own file or flags. Upgrading applies a new version or new values, history lists revisions, and rollback returns to an earlier revision. Keep your values files in version control.
# my-values.yaml
replicaCount: 2
helm install my-podinfo oci://ghcr.io/stefanprodan/charts/podinfo \
--version 6.11.2 -f my-values.yaml
helm upgrade my-podinfo oci://ghcr.io/stefanprodan/charts/podinfo \
--version 6.11.2 --set replicaCount=3
helm history my-podinfo
helm rollback my-podinfo 1Step 5: Create your own chart
helm create scaffolds a chart with a standard layout: Chart.yaml with the chart's name and version, values.yaml with defaults, and a templates folder. Lint it, package it, and install it. Required Chart.yaml fields are apiVersion (v2 for Helm 3 and later), name, and version.
helm create mychart
# mychart/
# Chart.yaml
# values.yaml
# charts/
# templates/
helm lint mychart
helm package mychart
helm install my-release ./mychart-0.1.0.tgzFAQs
- What is the difference between a chart and a release?
- A chart is the package of templates and defaults. A release is one installed instance of a chart in a cluster, so you can install the same chart several times with different release names and values.
- Does helm uninstall keep any history?
- By default it removes the release history too. Use the keep-history option if you may want to inspect or roll back after uninstalling.
Summary
Helm installs applications as releases from charts, lets you customize them with values, and provides upgrade, history, and rollback. Use existing charts to save time, and create your own with helm create when you need to package your application.
Comments
Log in or create a free account to join the discussion.