DEV Community

Ophélie
Ophélie

Posted on

Explore Helm: The Kubernetes Package Manager

As you dive deeper into Kubernetes, managing the deployment of complex applications can become a challenge. That’s where Helm, Kubernetes’ package manager, comes in. Helm simplifies deploying, managing, and scaling your applications by packaging them into reusable, shareable, and versioned charts. Whether you’re running simple microservices or complex, multi-service applications, Helm makes it easier to manage Kubernetes resources.

In this article, we’ll explore Helm, guide you through its setup, and show you how to use it to manage applications on Kubernetes.

What is Helm?

Helm is a tool that allows you to define, install, and upgrade Kubernetes applications. Just like package managers in traditional OS environments (e.g., apt for Ubuntu, or yum for CentOS), Helm packages Kubernetes applications as charts, which are then installed and managed through Helm commands.

Key Benefits of Helm

- Simplified Deployment: Deploy complex applications with a single command.

- Versioning: Easily manage different versions of your application.

- Reusability: Share your charts across teams or organizations.

- Rollback: Rollback to a previous version of your application if something goes wrong.

Setting Up Helm

To get started with Helm, you’ll need to install it and configure it with your Kubernetes cluster.

Step 1: Install Helm

On most systems, you can install Helm with the following commands:

- For macOS:

brew install helmb
Enter fullscreen mode Exit fullscreen mode

- For Linux:

curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
Enter fullscreen mode Exit fullscreen mode

Step 2: Configuring Helm with Kubernetes

Helm connects to your Kubernetes cluster using the same **kubectl**\ configuration. Once installed, verify the connection by running:

helm version
Enter fullscreen mode Exit fullscreen mode

You should see the Helm version information and confirmation that it is communicating with your cluster.

Understanding Helm Charts

Helm charts are packages that define, configure, and deploy Kubernetes resources. A chart contains all the YAML files required to run an application, such as Deployments, Services, ConfigMaps, etc.

Exploring the Structure of a Helm Chart

A basic Helm chart typically includes the following files and directories:

- **Chart.yaml**\: Contains metadata about the chart (name, version, description).

- **values.yaml**\: The default configuration values for the chart.

- **templates/**\: This directory contains Kubernetes manifest templates.

Using Public Helm Repositories

You don’t have to start from scratch. Helm has many official repositories with pre-built charts. To search for charts:

helm repo add bitnami https://charts.bitnami.com/bitnami
helm search repo bitnami
Enter fullscreen mode Exit fullscreen mode

This command will list popular Bitnami charts you can use in your Kubernetes cluster.

Deploying Applications with Helm

Once you have a chart, deploying it to your Kubernetes cluster is straightforward.

Step 1: Create a Helm Release

A release is a deployed instance of a chart in your Kubernetes cluster. To create one, use the following command:

helm install my-release bitnami/nginx
Enter fullscreen mode Exit fullscreen mode

This command installs the Nginx application from the Bitnami repository as a Helm release called my-release\.

Step 2: Managing Releases

You can manage your releases with simple Helm commands:

- List releases: *helm list*\

- Upgrade a release: *helm upgrade my-release bitnami/nginx*\

- Rollback a release: *helm rollback my-release 1*\

Creating Your Own Helm Charts

As you become more familiar with Helm, you’ll want to create your own charts to manage custom applications.

Step 1: Create a New Helm Chart

You can create a new chart using the Helm CLI:

helm create my-chart
Enter fullscreen mode Exit fullscreen mode

This command creates a directory called my-chart\ with the basic structure discussed earlier.

Step 2: Customize the Chart

Edit the **values.yaml**\ file to customize configuration settings. Update the templates to reflect the Kubernetes resources required for your application.

Best Practices for Managing Helm Charts

- Version Control: Always version your charts and follow semantic versioning.

- Reusable Templates: Make use of template functions and helpers to reuse code.

- Test Before Deploying: Use Helm’s built-in testing framework to validate your charts before deploying them.

Advanced Helm Features

Helm provides several advanced features that make it even more powerful in managing Kubernetes resources.

Helm Templating

Helm uses Go templates to generate Kubernetes manifests dynamically. This allows you to inject values into your manifests and create flexible configurations. For example, you can use a values.yaml\ file to define the image version and inject it into your deployment template.

Managing Dependencies

Helm allows you to define dependencies between charts using the **Chart.yaml**\ file. This is useful when your application consists of multiple microservices that need to be deployed together.

To add a dependency, edit the Chart.yaml\ file and list the charts that your chart depends on. Then, run:

helm dependency update
Enter fullscreen mode Exit fullscreen mode

Conclusion

Helm is an essential tool for managing Kubernetes applications, simplifying the deployment process, and reducing complexity. With Helm, you can deploy, upgrade, and manage your applications with ease. After mastering the basics of Helm, explore creating more advanced charts, managing dependencies, and using Helm in CI/CD pipelines.

Next Steps with Helm

- Explore Helm plugins to extend its functionality.

- Use Helm in conjunction with continuous integration tools like Jenkins, GitLab CI, or GitHub Actions to automate deployments.

- Learn how to create Helm charts for more complex multi-tier applications.

Ready to go further? In the next article, we’ll take a deep dive into Kubernetes networking, focusing on how traffic flows within and outside of your cluster.

Top comments (0)