Only registred users can make comments

The Helm CheatSheet: Maximizing Kubernetes Deployments

Introduction

Helm is a package manager designed for Kubernetes. It simplifies the deployment and management of applications within Kubernetes clusters. Similar to apt or yum for Linux, or npm for Node.js, Helm helps in managing applications aimed to run in Kubernetes.

Key Concepts of Helm

Charts: Helm packages are called charts. A chart is essentially a collection of files that define Kubernetes resources such as deployments, services, config maps, and secrets. Think of it as a template or blueprint for running your application on Kubernetes.

Repositories: Charts are stored in repositories, which act as centralized storage locations. You can pull charts from public repositories like ArtifactHub, or from private repositories managed by your organization, like AWS ECR or Jfrog Artifactory.

Releases: When you deploy a Helm chart, it creates a release. This release is a specific instance of the chart running on your Kubernetes cluster. You can have multiple releases of the same chart, each with its own configuration.

How Helm Works

1. Installation: To deploy an application using Helm, you install a chart. Helm processes the chart’s templates and deploys the required Kubernetes resources to your cluster.

2. Templating: Helm charts often include templates, enabling dynamic configurations. By passing in custom values, Helm generates tailored Kubernetes manifests specific to your deployment.

3. Upgrade and Rollback: You can upgrade a release to a new version of the chart, and if issues arise, you have the option to roll back to a previous version.

4. Helm Values: Helm allows for extensive customization via values.yaml files. These files define default configurations for the chart, but you can override them during installation, allowing flexibility for each deployment.

Commands

The following mindmap diagram shows the most common Helm commands:

Helm Cheat Sheet

 

 

  • helm install: Deploy a chart.
  • helm upgrade: Upgrade a release.
  • helm rollback: Roll back a release to a previous version.
  • helm list: List releases.
  • helm uninstall: Remove a release.
  • helm create: Create a new chart.
  • helm package: Package a chart directory into a chart archive.
  • helm repo add: Add a chart repository.
  • helm search repo: Search for charts in a repository.
  • helm pull: Download a chart to your local directory.
  • helm status: Display the status of a release.
  • helm history: View a release's history.
  • helm get: Download a release.
  • helm template: Locally render templates.
  • helm test: Run tests for a release.
  • helm lint: Examine a chart for possible issues.
  • helm plugin: Add or remove Helm plugins.
  • helm repo update: Update information of available charts.
  • helm repo remove: Remove repository from the local machine

Content

More formal things about Helm

Helm is streamlining the deployment and management of applications on Kubernetes.

It is a tool that simplifies the complexities of managing Kubernetes applications, making it more accessible and manageable for users of varied expertise levels. Helm is often referred to as a package manager for Kubernetes, analogous to apt in Ubuntu or yum in CentOS.

 It was developed to address the need for an efficient and structured way of packaging, configuring, and deploying applications to Kubernetes clusters. 

How Helm Works in Kubernetes

Helm operates as a client-side tool when you’re deploying applications to Kubernetes. It doesn’t need to run continuously in the cluster like some other tools. Instead, Helm connects to Kubernetes’ API server, takes your Helm charts, processes the templates inside, and deploys the necessary resources. Essentially, Helm is like a local tool that pushes resources to Kubernetes without needing anything extra running in the cluster.

In older Helm version (v2) there was a component called Tiller, which acted as a middleman between Helm and Kubernetes. But Tiller is not used in Helm 3, it has been removedto make the whole process simpler and more secure. Now, Helm interacts directly with Kubernetes without needing a server-side component.

One of the best parts about Helm is that it doesn’t require any special operator or controller to be installed in your cluster. You just run Helm commands, and Kubernetes takes care of the rest using its native system for managing resources. Helm submits your app’s resources, and Kubernetes ensures they run as expected.

 

Helm's Functionality

Helm operates by leveraging a packaging format known as Helm charts. A Helm chart is a collection of pre-configured Kubernetes resources. These charts describe a set of resources and configurations needed to deploy an application or a service on Kubernetes. Users can create their own charts or use and modify existing charts from public or private repositories.

By using Helm, developers and system administrators can easily package, configure, and deploy applications on Kubernetes clusters. This streamlined approach saves time and reduces the potential for human error, especially in complex deployments.

Why Use Helm?

Managing Kubernetes applications without the help of tools like Helm can introduce considerable complexity and challenges. Without Helm, users must manually handle each component of their Kubernetes applications, leading to a cumbersome and error-prone process. This manual management includes writing and maintaining extensive YAML files for each Kubernetes resource, such as deployments, services, and pods, which can quickly become overwhelming as the scale and complexity of the application grows

Helm's significance in Kubernetes environments is largely attributed to its ability to simplify and enhance application management. Below are key reasons why Helm is highly regarded in the management of Kubernetes applications.

Simplification of Deployment Processes

Helm reduces the complexity involved in deploying applications to Kubernetes. By using Helm charts, users can define, install, and upgrade even the most complex Kubernetes applications. Charts can be versioned, shared, and reused, making the deployment process more efficient and less error-prone.

Consistency and Standardization

Helm promotes consistency in application deployment. The use of charts ensures that all deployments follow a standardized format. This consistency is important, especially in large teams and organizations, as it facilitates easier understanding and management of deployments across different environments.

Efficient Management of Kubernetes Resources

With Helm, managing Kubernetes resources becomes more manageable. It allows for the bundling of Kubernetes resources and their dependencies into a single package, which can be easily managed as a unit. This bundling enables more efficient updates and rollbacks, ensuring that applications remain stable and deployable throughout their lifecycle.

Community and Ecosystem Support

Helm benefits from strong community support and a rich ecosystem. There are thousands of publicly available charts for popular software packages and services, which users can leverage to deploy applications quickly. This community-driven approach accelerates development and fosters collaboration, as users can contribute to and benefit from the collective knowledge and resources.

A popular repository for helm charts is https://artifacthub.io/

Customization and Flexibility

Helm charts are highly customizable, allowing users to tweak configurations to suit their specific requirements. This flexibility makes Helm an ideal tool for a wide range of applications and environments, from small-scale projects to large, complex enterprise systems.

Core Components of Helm

Helm is built upon a set of core components that work together to provide its functionality. Understanding these components is crucial for effectively using Helm in Kubernetes environments.

 

Helm Components

 

Helm Charts

The most fundamental element of Helm is the Helm Chart. A chart is a package containing all the resource definitions needed to run an application, tool, or service inside a Kubernetes cluster. These charts are created following a specific format and can be shared and used across different Kubernetes environments. Charts eliminate the need to manually create and manage a series of interdependent Kubernetes resources, making the deployment process more straightforward and repeatable.

Chart Structure

A typical Helm chart consists of:

  • Chart.yaml: The chart's metadata, including version, description, and dependencies.
  • values.yaml: Configurable values that can be set at the time of deployment to customize the chart.
  • Templates: These are Kubernetes manifest files written in a templating language, which are rendered into Kubernetes manifests with the values provided.
  • Other optional files like README.md for documentation and a charts/ directory for chart dependencies.

Helm Repository

Helm repositories are locations where charts can be stored and shared. These can be public or private. Popular public repositories like artifucthub provide a wide array of charts for common applications and services. Users can also create and maintain their own private repositories for internal use.

Helm CLI

The Helm Command Line Interface (CLI) is the primary way users interact with Helm. It allows users to search for and install charts from repositories, manage chart versions, and handle the lifecycle of Helm releases in a Kubernetes cluster.

Tiller (Helm v2)

In Helm version 2, Tiller played a key role as the server-side component that interacted with the Kubernetes API. However, with Helm v3, Tiller was removed to enhance security and simplify the Helm architecture.

Installing and Setting Up Helm

The following is a brief process of installing Helm:

Installation

The first step is to install the Helm CLI, which is the interface for interacting with Helm and managing charts. Helm can be installed on a variety of operating systems including Linux, macOS, and Windows.

  1. Download Helm: Visit the official Helm releases page and download the appropriate version for your operating system.
  2. Unpack the Helm binary: Extract the downloaded file to retrieve the Helm binary.
  3. Move the binary to a desired location: Place the Helm binary in a directory included in your system's PATH to ensure it can be executed from any location.

Initialization and Configuration

With Helm v3, the initialization step that was required in Helm v2 is no longer necessary, as Tiller (the server-side component) has been removed. This simplifies the setup process significantly.

  1. Verify the Installation: Run helm version to confirm that Helm is properly installed. This command should display the version of Helm installed on your system.
  2. Set up Repositories: Add chart repositories to Helm for accessing charts.  Use the command helm repo add [repo name] [repo URL] to add more repositories.
  3. Update Repositories: To ensure you have the latest list of charts, run helm repo update.

Basic Usage

Once Helm is installed and configured, you can start using it to manage applications in your Kubernetes cluster.

  • Searching for Charts: Use helm search repo [keyword] to find charts in the repositories.
  • Installing Charts: To install a chart, use helm install [release name] [chart name].
  • Listing Releases: View all deployed releases with helm list.

This setup process equips users with the tools necessary to start deploying and managing applications with Helm in a Kubernetes environment.

Working with Helm Charts

This section covers the creation, customization, and management of Helm charts.

Creating a Helm Chart

To create a new Helm chart:

  1. Initialize a New Chart: Use the command helm create [chart name] to generate a new chart directory along with the necessary files and directories for the chart.
  2. Structure of the Chart: The generated chart directory contains several files and directories, including Chart.yaml (the chart's metadata), values.yaml (default configuration values), and a templates/ directory (for template files).

Customizing a Chart

Customization is done primarily through modifying the values.yaml file and the templates in the templates/ directory.

  1. Edit values.yaml: This file contains the default values for your chart. You can customize these values to suit your specific deployment needs.
  2. Modify Templates: The templates/ directory contains the template files that will be rendered into Kubernetes manifest files. You can edit these templates to change how resources are defined.

Chart Dependencies

Helm charts can depend on other charts. This is useful for complex applications that require several components.

  • Adding Dependencies: Dependencies are defined in the Chart.yaml file and stored in the charts/ directory.
  • Managing Dependencies: Use helm dependency update [chart name] to download and manage the required dependencies.

Best Practices

  • Versioning: Properly version your charts for better management.
  • Documentation: Include a README.md in your chart for usage instructions.
  • Testing: Regularly test your charts to ensure they work as expected.

Helm Commands Cheat Sheet with Examples

In this section, we will take one step further and provide some examples how you can use the commands we listed in the introduction of this post.

❗Note on Defining a Helm Release: A Helm release is a single deployment of a chart with a specific configuration. The [release-name] is a unique name you give to your deployment instance. Replace [release-name] with your chosen name for the deployment, such as my-release in the examples provided.

In the following table we'll use kubescape as the example, just because that was the last chart I worked on 😊

But remember, that is just for the illustration purposes.

Command Example Description
helm install [release-name] [chart-name] helm install my-release kubescape/kubescape-cloud-operator Deploy a chart.
helm upgrade [release-name] [chart-name] helm upgrade my-release kubescape/kubescape-cloud-operator Upgrade a release.

helm upgrade --install  [release-name] [chart-name] --reuse-values -n <namespace>

helm upgrade --install my-release kubescape/kubescape-cloud-operator --reuse-values -n kubescape

Upgrade a release  ,

--reuse-values tells Helm to merge any new default values with the values that were previously used.

helm rollback [release-name] [revision] helm rollback my-release 2 Roll back a release to a previous version.
helm list helm list List releases.
helm uninstall [release-name] helm uninstall my-release Remove a release.
helm create [chart-name] helm create my-new-chart Create a new chart.
helm package [chart-path] helm package ./my-new-chart Package a chart directory into a chart archive.
helm repo add [repo-name] [repo-url] helm repo add kubescape https://charts.kubescape.cloud Add a chart repository.
helm search repo [chart-name] helm search repo kubescape Search for charts in a repository.
helm pull [chart-name] helm pull kubescape/kubescape-cloud-operator Download a chart to your local directory.
helm status [release-name] helm status my-release Display the status of a release.
helm history [release-name] helm history my-release View a release's history.
helm get all [release-name] helm get all my-release Download a release.
helm template [release-name] [chart-name] helm template my-release kubescape/kubescape-cloud-operator Locally render templates.
helm test [release-name] helm test my-release Run tests for a release.
helm lint [chart-path] helm lint ./my-new-chart Examine a chart for possible issues.
helm plugin [add|remove] [plugin] helm plugin add https://github.com/databus23/helm-diff Add or remove Helm plugins.
helm repo update helm repo update Update information of available charts.
helm repo remove [repo-name] helm repo remove bitnami Removes local repository
helm search repo [chart-name] --versions | head helm search repo kubescape --versions | head Show top versions of a chart.
helm show values [chart-name] helm show values kubescape/kubescape-cloud-operator Show values of a chart.
helm show values [chart-name] > custom-values.yaml helm show values kubescape/kubescape-cloud-operator > custom-values.yaml Create custom values file from original.
helm install [release-name] [chart-name] -f custom-values.yaml helm install my-release kubescape/kubescape-cloud-operator -f custom-values.yaml Install Helm chart with custom values file.
helm install [release-name] [chart-name] --set key=value[,key2=value2] helm install my-release kubescape/kubescape-cloud-operator --set image.tag=1.14.5,service.type=NodePort Install a Helm chart with custom parameters.
helm pull [chart-name] --untar helm pull kubescape/kubescape-cloud-operator --untar Download and untar a Helm chart into the current directory.

 

Advanced Helm Features

Helm is not just a tool for basic application deployment; it also offers a range of advanced features that provide more control and flexibility in managing Kubernetes applications. Understanding these features is crucial for maximizing the effectiveness of Helm in complex scenarios.

Managing Dependencies

Helm allows you to specify and manage dependencies for your charts. These dependencies can be other charts that your application needs to function correctly. By declaring these dependencies in the Chart.yaml or requirements.yaml files, Helm can automatically download and install them along with your chart.

  • Dynamic Dependency Management: Helm's dependency management system makes it easier to maintain and update the components your application relies on.

Helm Hooks

Helm hooks are a powerful feature that allows you to control the lifecycle of your charts and releases. Hooks can be used to perform actions at certain points in a release's lifecycle, such as:

  • Pre-install: Actions to perform before the chart is installed.

  • Post-install: Actions after the chart is installed.

  • Pre-delete: Actions before a chart is deleted.

  • Post-delete: Actions after a chart is deleted.

  • Customization of Deployment Workflow: With hooks, you can customize your deployment workflow to include steps like database migrations, backups, or any other job that needs to run at a specific point in the release process.

Helm Tests

Helm includes a testing framework that allows you to verify that your Kubernetes application is running as expected. Helm tests are defined within your chart and can be run after deployment to ensure everything is functioning correctly.

  • Ensuring Application Reliability: By incorporating tests into your Helm charts, you can automate the process of verifying deployments, thereby enhancing the reliability of your applications.

Rollbacks and Upgrades

Helm simplifies the process of upgrading and rolling back releases, providing easy ways to manage different versions of your applications.

  • Efficient Version Management: With Helm, upgrading to new versions or rolling back to previous states is streamlined, minimizing downtime and risks associated with these processes.

These advanced features of Helm are what make it an invaluable tool for IT professionals and technology enthusiasts dealing with complex Kubernetes environments. They provide the means to manage applications with greater precision and control.

Conclusion

In conclusion, Helm emerges as an important tool in the Kubernetes ecosystem, enhancing the efficiency and manageability of application deployments. Its ability to simplify complex deployment processes, ensure consistency and standardization, and efficiently manage Kubernetes resources highlights its essential role in modern cloud infrastructure management. The stron

Moreover, the advanced features of Helm, such as dependency management, hooks, tests, and the streamlined process of upgrades and rollbacks, helps platform and devops engineers with the capabilities to manage Kubernetes applications in a structured and controlled way. 

Also, if you work with GitOps tools, such as ArgoCD, deploying applications packaged in Helm charts is really nice, but that will be a topic for another blog post or video.

About the Author

Aleksandro Matejic, a Cloud Architect, began working in the IT industry over 21 years ago as a technical specialist, right after his studies. Since then, he has worked in various companies and industries in various system engineer and IT architect roles. He currently works on designing Cloud solutions, Kubernetes, and other DevOps technologies.

You can contact Aleksandro by visiting his LinkedIn Profile

Comments