Kubernetes Helm Charts: The Basics and a Quick Tutorial

What Is Helm? 

Helm is a package manager for Kubernetes, providing a way to manage Kubernetes applications through Helm charts. These charts act as templates, which help in defining, installing, and upgrading complex Kubernetes applications. 

Helm helps reduce complexity in Kubernetes environments to a manageable level, enabling configuration, managing dependencies, and deploying applications and services.

By using Helm, developers and system administrators can easily package their Kubernetes applications for dissemination. This makes it easier to share applications and replicate the setup of clusters, streamlining the deployment process across different development and production environments.

This is part of a series of articles about Kubernetes architecture.

In this article:

What Are Helm Charts?

Helm charts are structured files that organize all the files necessary to define and manage a Kubernetes application. Each chart represents a set of instructions specific to a single application, which Helm utilizes to package these instructions into deployable units. This model allows Helm to manage the installation, upgrade, and deletion of a Kubernetes application.

Helm charts contain templates, default values (values.yaml), and dependencies, among other elements, that can facilitate customized deployments for different environments (like staging or production). This allows operators to install the same application in multiple environments, with each instance governed by a set of environment-specific adjustments and configurations.

The Structure of a Helm Chart

Helm charts include the following elements.

Chart Directory

The Chart directory houses all the files related to a specific chart. It acts as a root directory where different configurations and template files are organized. This directory includes the Chart.yaml file, which provides metadata about the chart such as version, name, description. 

The directory typically contains a ‘charts’ folder for dependencies and a ‘templates’ folder for Kubernetes resource definitions.

Learn more in our detailed guide to kubernetes resource management.

Templates Directory

The Templates directory within a Helm chart is where Kubernetes resources are defined through template files. These files end in .yaml and are standard YAML files with embedded Go template language. Helm processes these templates against the provided values to generate Kubernetes manifests specific to an environment.

This structure allows the reuse of the same templates for different deployments by only changing the values injected into them. The Templates directory acts as the customization layer in Helm Charts, which directly manipulates how Kubernetes resources are provisioned and managed.

Values File

The values.yaml file in a Helm chart contains the default configuration values for the chart. This file houses the parametric values that are rendered into the chart’s template files. Users can customize their deployment by overriding these values during Helm chart installation, making the chart broadly adaptable without any modifications to the templates.

The values.yaml organizes data in a hierarchical structure, which Helm uses to incorporate conditionals and loops within the templates. This ensures more control over how resources are configured and deployed.

Chart File

The Chart.yaml file provides metadata about the Helm chart such as the name, version, and description. This file is used by Helm to understand the basic identity and versioning information that is crucial during chart installation, upgrading, or dependency management processes.

Metadata in the Chart.yaml helps in maintaining the chart’s lifecycle and its interactions with different environments and configurations. For example, it records whether a chart version is stable or still under development, aiding in proper version control management.

Why Should You Use Helm Charts in Kubernetes?

There are several reasons to use Helm in Kubernetes. Here are some of the main advantages of these charts for Kubernetes deployments.

Simplified Deployment

Helm charts offer a streamlined approach to deploying applications on Kubernetes, bundling necessary resources and configurations into one cohesive unit. This abstraction allows developers to deploy applications without deeply understanding every Kubernetes resource. 

Helm charts simplify the management lifecycle of applications, enabling quick deployments, updates, and management of lifecycle hooks. Adopting Helm charts can thus decrease the complexity involved in manual Kubernetes application management. This can also help reduce potential human errors associated with manual setups.

Reusability

Helm charts can be shared within an organization or with the broader Kubernetes community, providing a standardized way to install applications. This speeds up the deployment process and ensures consistency across environments. Reusable charts mean that teams can leverage community expertise and practices, focusing more on customization rather than basic setup.

The flexibility of Helm allows charts to be easily adapted for different environments and use cases, promoting a culture of reuse and collaboration. By leveraging established patterns, teams can avoid reinventing solutions, accelerating development cycles.

Templates and Parameters

Helm’s templating engine integrates tightly with Kubernetes, allowing users to parameterize their deployments. Through the use of values.yaml and templates, Helm enables dynamic generation of Kubernetes resource files tailored to specific environments or requirements. This promotes a DRY (Don’t Repeat Yourself) practice, reducing errors and duplications in deployment manifests.

Parameterization allows teams to manage differences in deployments across various environments smoothly, such as differing resource requirements between development and production. This makes Helm charts flexible and reduces the overhead in maintaining multiple versions of manifests for different scenarios.

Version Control and Rollback

Helm supports explicit version control of charts which is critical for maintaining stability across application updates. Each chart version can correspond to a set of configurations, which can be rolled back if an update does not perform as expected. This feature ensures service reliability and quick recovery from issues.

Helm charts also integrate with Kubernetes’ native rollback mechanisms to manage application versions. This feature improves ongoing delivery and continuous deployment strategies by mitigating risk and enhancing stability in application lifecycle management.

Quick Tutorial: Creating Helm Charts in Kubernetes 

To successfully and securely use Helm, you must have a Kubernetes cluster and decide on the security configurations for your installation. It is important to install Kubernetes or have access to a cluster. 

For optimal compatibility with the latest Helm release, it’s recommended to use the latest stable release of Kubernetes, generally the second-latest minor release. Additionally, ensure you have a locally configured copy of kubectl to interact with your cluster.

Installation

Begin by downloading the binary release of the Helm client. Installation can be performed using tools like Homebrew, or by visiting the releases page of Helm’s GitHub repository. This step sets up the Helm client on your local machine, allowing you to interact with Helm charts and your Kubernetes cluster.

Initializing a Helm Chart Repository

After installing Helm, you can add a chart repository to your Helm configuration. For example, you can add the Bitnami chart repository by using the following command:

helm repo add bitnami https://charts.bitnami.com/bitnami

Once the repository is added, you can browse available charts using:

helm search repo bitnami

This will display a list of available Helm charts along with their versions and descriptions.

Installing a Chart

To install a Helm chart, use the helm install command. For example, to install Prometheus, a Kubernetes monitoring tool, you would run:

helm repo update
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts

The output will provide details like the release name and status. This command deploys the Prometheus chart to your Kubernetes cluster and automatically assigns a release name.

Automating Kubernetes Infrastructure with Spot by NetApp

Spot Ocean from Spot by NetApp frees DevOps teams from the tedious management of their cluster’s worker nodes while helping reduce cost by up to 90%. Spot Ocean’s automated optimization delivers the following benefits:

  • Container-driven autoscaling for the fastest matching of pods with appropriate nodes
  • Easy management of workloads with different resource requirements in a single cluster
  • Intelligent bin-packing for highly utilized nodes and greater cost-efficiency
  • Cost allocation by namespaces, resources, annotation and labels
  • Reliable usage of the optimal blend of spot, reserved and on-demand compute pricing models
  • Automated infrastructure headroom ensuring high availability
  • Right-sizing based on actual pod resource consumption  

Related content: Read our guide to kubernetes pod.

Learn more about Spot Ocean today!