Getting Started with Helm: A Beginner's Guide
Posted on September 21, 2024 • 6 min read • 1,108 wordsLearn how to get started with Helm, the Kubernetes package manager, in this beginner's guide. Discover Helm charts, installation, upgrades, rollbacks, and best practices for managing Kubernetes applications efficiently. Perfect for developers new to Helm and Kubernetes
As containerization tools like Docker and orchestration systems like Kubernetes become increasingly popular, managing complex applications within Kubernetes can become challenging. Enter Helm, often referred to as the “Kubernetes package manager.” Helm simplifies the deployment and management of Kubernetes applications by bundling multiple configurations and resources into a single, reusable package called a Helm Chart. Whether you’re a beginner just dipping your toes into Kubernetes or someone looking to streamline their Kubernetes workflows, this guide will help you get started with Helm.
Helm is an open-source project that helps you define, install, and upgrade Kubernetes applications. With Helm, you can package your Kubernetes resources into a chart, making it easier to deploy applications and manage versions. It acts as a package manager for Kubernetes, allowing you to install predefined charts (Kubernetes application packages) or build your own for custom use.
The core benefits of Helm revolve around simplifying Kubernetes deployments:
By using Helm, you make Kubernetes deployments more repeatable, manageable, and scalable, especially as your application grows.
Before diving into the usage of Helm, it’s important to understand its core components:
In Helm v3 (the current version), the Tiller component has been removed, and the Helm client directly communicates with the Kubernetes API.
Before you start, you need to have Kubernetes set up. This guide assumes you already have Kubernetes running either locally (using tools like Minikube or Docker Desktop) or in the cloud (like Google Kubernetes Engine or Amazon EKS).
To install Helm, follow these steps:
The recommended way to install Helm is through your package manager. For macOS:
brew install helm
For Linux or Windows, you can download the Helm binary directly from the official Helm website: https://helm.sh/docs/intro/install/
After installation, confirm Helm is installed by running:
helm version
This command will return the installed Helm version if the installation was successful.
Helm uses repositories to store charts. The most commonly used chart repository is Helm Hub, which hosts charts for many popular applications.
You can add the Helm Hub repository using:
helm repo add stable https://charts.helm.sh/stable
After adding the repository, update it to get the latest list of charts:
helm repo update
Helm makes it easy to search for charts that you can deploy in your Kubernetes cluster. To search for a specific application like nginx, run:
helm search repo nginx
This will return a list of all the available nginx Helm charts, along with their versions.
To deploy an application, simply install its chart. For example, to install nginx, use:
helm install my-nginx stable/nginx-ingress
In this command:
my-nginx
is the name you assign to the release.
stable/nginx-ingress
is the chart to install from the stable repository.
You can verify that your Helm chart was successfully deployed by listing all the releases:
helm list
One of Helm’s core strengths is its ability to upgrade existing releases and rollback if something goes wrong.
To upgrade your release, for instance, updating my-nginx
to a new version:
helm upgrade my-nginx stable/nginx-ingress
If something breaks after the upgrade, you can roll back to the previous version using:
helm rollback my-nginx 1
The 1
represents the release revision you want to revert to.
A Helm chart is a collection of YAML configuration files that define a Kubernetes application. The key files in a Helm chart include:
Here’s a quick structure of a typical Helm chart:
my-chart/
Chart.yaml
values.yaml
templates/
deployment.yaml
service.yaml
Helm charts can be customized to suit your specific application needs. For instance, if you want to modify the default values of a chart, you can override them with your own values file or inline parameters. For example:
helm install my-nginx stable/nginx-ingress --set controller.replicaCount=2
This command sets the replicaCount
to 2, meaning Helm will deploy two nginx replicas.
You can also create your own values.yaml file with custom configurations and pass it to the Helm install command:
helm install my-nginx stable/nginx-ingress -f custom-values.yaml
Helm repositories are where charts are stored and shared. To add additional repositories beyond the default one, use:
helm repo add bitnami https://charts.bitnami.com/bitnami
This allows you to pull in charts from multiple sources, broadening your choices when deploying applications.
Helm is a powerful tool that simplifies managing and deploying Kubernetes applications. Whether you are deploying simple microservices or managing a complex, multi-tier application, Helm’s chart system allows you to create reusable, versioned packages. By following this guide, you’ve taken the first steps toward mastering Helm and deploying scalable Kubernetes applications with ease.
As you continue to explore Helm, you’ll find that its templating, version control, and dependency management features make it an essential part of any Kubernetes toolbox.