How to create a simple helm chart?

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:

[email protected]:~$ helm create helm-codetryout
Creating helm-codetryout
[email protected]:~$

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:

[email protected]:~$ 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:

[email protected]:~/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:

[email protected]:~$ 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 chart – basic helm chart creation steps
  • helm, viewing the Chart.yaml – Chart name and other details
  • viewing the values.yaml – Chart configurration file