Skip to main content
In this guide, you’ll learn how to build a simple Helm chart from scratch. We will demonstrate how Helm templates work to create unique and configurable Kubernetes resource names. Helm charts are extremely versatile—they not only automate the installation of Kubernetes packages but also perform additional tasks (like backing up a database before upgrades) much like installation wizards on traditional operating systems. For example, consider an upgrade command such as:
While this may seem complex at first, we will begin with a basic example and progressively introduce more advanced concepts.

Creating a Simple “Hello World” Chart

In this section, we will create a Helm chart for a simple “Hello World” application. The application will use an Nginx deployment with two replicas and expose the service through a NodePort. Below are the Kubernetes manifest files for our Hello World application:
Helm charts adhere to a specific directory structure that typically includes the templates/ folder along with files such as Chart.yaml, values.yaml, LICENSE, and README.md.

Using Helm to Scaffold the Chart

You do not need to manually create this structure. The Helm CLI can generate a skeleton chart for you:
Now, you can replace or add your own Kubernetes manifest files (for example, the deployment and service files shown above) into the templates/ directory. Initially, the generated Chart.yaml file contains default data based on the provided chart name.

Examining and Modifying Chart Metadata

At this stage, you might want to update the Chart.yaml file to include more detailed metadata. For instance, if your company is developing this chart for internal use, you can update the file with a more descriptive summary and add maintainer contacts. To open and edit the file:
The original content may resemble this:
Modify it to add details and contact information:
Once you have updated the metadata, remove any unnecessary sample template files from the templates/ directory:
For your simple application, add your custom deployment and service YAML files to this folder, and your chart will be ready for installation.

Static vs. Templated Names

When you install a Helm chart, the objects in the templates are created exactly as defined. For example:
Since the deployment name is hardcoded as hello-world, installing another release of the same chart leads to name conflicts:
To avoid conflicts, leverage Helm’s templating language to create dynamic names based on the release name. For instance, update your service and deployment definitions as follows:
Now, when you install the chart using different release names, Helm replaces the template directives (e.g., {{ .Release.Name }}) with your specified release name:
Basing resource names on the Helm release name ensures that multiple installations in the same namespace do not conflict.

Exposing Configurable Values

Customization is key for production-ready charts. Often, you might want to configure deployment attributes—such as the number of replicas or the container image—to suit different environments. The values.yaml file serves this purpose by storing default configurations that your templates can reference. Consider the following simple values.yaml:
Your deployment template then references these values:
This setup allows users to override default settings during installation, for example:
For more intricate configurations, you can structure the values file as a dictionary. For example, separate the image details:
And update your deployment template accordingly:
This approach constructs the complete container image string dynamically and allows you to adjust the image pull policy as needed.

Summary

When you install a Helm chart, Helm processes the templates in your templates/ directory together with several sources of configuration: • Release-specific details (such as release name, namespace, and revision)
• Default values defined in values.yaml
• Metadata from Chart.yaml
• Information from your Kubernetes cluster
The resulting manifest files are then used by Kubernetes to deploy your resources. By designing templates with dynamic naming (using {{ .Release.Name }}) and configurable values (via values.yaml), you guarantee that each chart installation creates uniquely named objects and can be tailored easily by users. Happy templating, and see you in the next lesson!
For more information on Helm, visit the Helm Documentation.

Watch Video