Helm CLI

Why Learn the Helm CLI?

While Helm is most often used as a client within a GitOps framework and not executed directly in production environments, understanding how to test Helm commands locally will significantly speed up the development process for charts.
By testing commands locally before committing changes to your GitOps workflow, you can quickly validate chart configurations, catch errors early, and iterate more efficiently on your Helm charts.

Creating and Deploying Your Chart: A Workflow

Let us walk through the typical workflow of creating a Helm chart, packaging it, pushing it to a registry, and installing it in a cluster.
This narrative will guide you through the commands you will use at each step.

Step 1: Creating Your Chart

First, you create a new Helm chart using the helm create command.
This generates a basic chart structure with sample templates and a values.yaml file:

helm create my-chart

This command creates a directory called my-chart with all the necessary files for a Helm chart.
You can now customize the templates and values to match your application requirements.

Step 2: Testing Your Chart Locally

Before packaging your chart, you should test it to ensure it renders correctly.
Use the helm template command to render your chart templates without installing anything:

helm template my-release ./my-chart

This command shows you exactly what Kubernetes resources will be created when you install the chart.
Review the output to verify that your templates are working as expected.

Step 3: Packaging Your Chart

Once you are satisfied with your chart, package it into a .tgz archive:

helm package ./my-chart

This creates a file named my-chart-0.1.0.tgz (assuming version 0.1.0 in your Chart.yaml).
The packaged chart is now ready to be distributed.

Step 4: Logging In to Your Registry

Before you can push your chart to a container registry, you need to authenticate.
Use the helm registry login command to log in to your registry:

helm registry login <registry-url>

For example, if you are using a container registry:

helm registry login registry.example.com

You will be prompted for your username and password or token.
Once authenticated, Helm can push charts to the registry.

Step 5: Pushing Your Chart

Now you can push your packaged chart to the registry as an OCI artifact:

helm push my-chart-0.1.0.tgz oci://registry.example.com/charts

This uploads your chart to the registry where it can be accessed by others or by your GitOps tools.

Step 6: Fixing and Pushing Again

If you discover an issue with your chart after pushing it, you can make corrections and push again.
After updating your chart files, increment the version in Chart.yaml, then package and push again:

helm package ./my-chart
helm push my-chart-0.2.0.tgz oci://registry.example.com/charts

Each version is stored separately in the registry, allowing you to maintain a history of your chart versions.

Step 7: Installing Your Chart

With your chart now available in the registry, you can install it in your Kubernetes cluster.
First, if needed, add the registry as a repository:

helm repo add my-registry oci://registry.example.com/charts
helm repo update

Then install the chart:

helm install my-release oci://registry.example.com/charts/my-chart --version 0.2.0

This command creates a new Helm release named my-release using your chart from the registry.

Step 8: Verifying Your Running Release

After installation, verify that your release is running correctly.
Check the status of your release:

helm status my-release

This shows detailed information about the release, including the status of all deployed resources.

You can also list all releases in your namespace:

helm list

This displays all Helm releases, their status, and when they were last updated.
Your my-release should appear in this list, confirming that it is installed and running in your cluster.

Next Steps

Now that you have an overview of the Helm CLI workflow, you will use these commands in the exercises section to explore them in greater detail.
The exercises will provide hands-on practice with each command, helping you build confidence and familiarity with the Helm CLI as you work through real-world scenarios.