How to create a simple helm chart?

A Helm chart is a package format Helm uses, a package manager for Kubernetes applications. Helm charts provide a convenient way to define, install, and manage applications on a Kubernetes cluster. A Helm chart contains a collection of files that describe the resources and configuration necessary to deploy and run an application.

This article will go through practical steps for creating a helm chart from scratch (the helm chart in Kubernetes). Let us try creating a basic helm chart today.

Creating a new helm chart by using – helm create – command

helm create <CHART-NAME>

Example for helm create command output:

devops@codetryout:~$ helm create helm-codetryout
Creating helm-codetryout
devops@codetryout:~$

Here, the example chart name is “helm-codetryout”

Make sure you have helm installed on your computer, if you are looking for the steps, please refer to this page: How-to-install-helm?

Exploring your newly created helm Chart

A new directory with the chart name specified will be created, as shown below:

devops@codetryout:~$ tree helm-codetryout
helm-codetryout
├── charts
├── Chart.yaml
├── templates
│   ├── deployment.yaml
│   ├── _helpers.tpl
│   ├── hpa.yaml
│   ├── ingress.yaml
│   ├── NOTES.txt
│   ├── serviceaccount.yaml
│   ├── service.yaml
│   └── tests
│       └── test-connection.yaml
└── values.yaml

We have used the tree command to explore the Chart contents (tree command alternative Linux)

Step #3: Helm Chart Details, exploring Chart.yaml

Helm chart’s basic details, such as name, description, and version are stored in Chart.yaml.

Here is an example of a basic helm chart’s Chart.yaml file:

devops@codetryout:~/helm-codetryout$ cat Chart.yaml
apiVersion: v2
name: helm-codetryout
description: A Helm chart for Kubernetes

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.16.0"

Step #4: Exploring your helm chart values.yaml

Helm Chart values can be viewed or modified by editing the values.yaml file, which is available in the Chart directory,

<Your-Chart-Name>/values.yaml

Example:

devops@codetryout:~$ cat helm-codetryout/values.yaml
# Default values for helm-codetryout.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

replicaCount: 1

image:
  repository: nginx
  pullPolicy: IfNotPresent
  # Overrides the image tag whose default is the chart appVersion.
  tag: ""

imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""
...
...

Here is a screenshot of the new simple helm chart

helm sample chart

We have explored the following:

  • helm create a chart – basic helm chart creation steps
  • helm, viewing the Chart.yaml – Chart name and other details
  • viewing the values.yaml – Chart configuration file

Helm charts simplify deploying complex applications on Kubernetes by encapsulating the application’s configuration and dependencies. With Helm, you can package, version, and share applications as reusable charts, enabling easy installation, upgrading, and rollback operations.

You can find a wide range of pre-built Helm charts in public repositories like Helm Hub or create your custom charts tailored to your specific application requirements.