Introduction to Kubernetes Helm Charts
In this article, we explain the basics about Kubernetes Helm Charts.
1. Kubernetes Helm Charts
Kubernetes Helm Chart is a single package that contains the definition of Kubernetes resources and is used to deploy the containerized application with a single helm install or helm upgrade command. In this article, I will explain the basic information that you need to know about the Kubernetes helm charts.
2. Helm Chart Folder Structure
Helm chart has the following folder structure:
mychart/ Chart.yaml values.yaml charts/ templates/
Name | Description |
Chart.yaml | Define the chart’s name, type, version, etc. |
values.yaml | Define variables used in the templates along with the default value. |
charts | Include the sub-charts definition. |
templates | Includes helm related files: _helpers.tpl and NOTES.txt and Kubernetes definition files: deployment.yaml, service.yaml, ingress.yaml, etc. |
3. Helm Chart Templates Folder
The templates folder includes the manifest files for the containerized application. Here are the common ones:
Name | Description |
_helpers.tpl | Define the common template helpers which can be used in the entire chart. |
NOTES.txt | Define the text message displayed at the end of the “helm install” and “helm upgrade” commands. |
deployment.yaml | The deployment.yaml for the Kubernetes cluster utilized variables defined in values.yaml. |
service.yaml | The service.yaml for the Kubernetes cluster utilized variables defined in values.yaml. |
ingress.yaml | The ingress.yaml for the Kubernetes cluster utilized variables defined in values.yaml. |
In this step, I will define the replicaCount variable with the default value of 1 in the values.yaml file.
values.yaml
replicaCount: 1
I then can reference the replicaCount variable in the deployment.yaml as {{ .Values.replicaCount }}.
deployment.yaml
spec: replicas: {{ .Values.replicaCount }}
When helm install command is executed, it will replace the {{ .Values.replicaCount }} with 1.
4. Helm Commands
Helm is the package manager for Kubernetes. The most recently 3.7.1 version is released in October 2021.
4.1 Helm install
Here is the syntax of the helm install command.
helm install [NAME] [CHART] [flags]
It will deploy the packaged application in Kubernetes after replacing the variables defined in the manifest files in the templates folder.
4.2 Helm upgrade
Here is the syntax for the helm upgrade command.
helm upgrade [RELEASE] [CHART] [flags]
According to the best practice article, it’s better to use the helm upgrade –install than the helm install command.
5. Helm Hub & Versions
Most corporates host their internal chart repositories. Artifact Hub lists thousands of Helm charts from numerous public repositories. Please also reference this site to find the matching Helm and Kubernetes version.
6. References
Here are a few easy to follow introduction resources:
- https://docs.bitnami.com/tutorials/create-your-first-helm-chart/
- https://codersociety.com/blog/articles/helm-best-practices
- https://pkg.go.dev/text/template#hdr-Arguments
- https://helm.sh/docs/chart_template_guide/function_list