Introduction: What is Helm, and Why Should You Care?
Hey there! If you’ve been diving into Kubernetes, you’ve probably heard about Helm and wondered what it’s all about. Trust me, I’ve been in your shoes—Kubernetes itself can feel like an ocean, and tools like Helm are supposed to be the lifeboats. But is it really helpful, or just another thing to learn? I’m here to tell you that Helm can seriously make your life easier when managing Kubernetes. By the end of this guide, you’ll understand not only what Helm is but how it can streamline your workload and save you headaches.
Let me ask you—how often do you deploy applications to Kubernetes? Maybe once in a while or almost daily? Either way, doing it manually can get exhausting and messy. That’s where Helm steps in.
What is Helm? The TL;DR Version
If you want a simple answer, here it is: Helm is a package manager for Kubernetes. Think of it like apt
for Debian or yum
for CentOS. It allows you to install, upgrade, and manage applications easily in your Kubernetes cluster. The cool part? Helm makes deploying complex applications as easy as typing a few commands—you don’t have to worry about the intricate details.
In Kubernetes, managing even a simple application involves lots of YAML files: deployments, services, ingress, and more. Helm bundles all of these into something called a chart, which is a reusable package that can be configured and deployed easily. With Helm, you can deploy an entire stack without going into dozens of YAML configurations.
Helm: More Than Just a Package Manager
Helm is often called the “package manager for Kubernetes,” but it’s much more than that. Originally created by DeisLabs and now maintained by the Cloud Native Computing Foundation (CNCF), Helm simplifies managing the many Kubernetes YAML files that developers create. Instead of juggling multiple YAML manifests for deployments, services, and other resources, Helm wraps them into a single package called a chart.
A Helm chart can contain everything from individual components to entire applications, along with their dependencies. Imagine trying to deploy a full-stack application, including frontend, backend, and database services, each with their own configuration requirements. Helm makes it easy to install everything at once, ensuring that all dependencies are handled properly.
With Helm, you only need a single command to install your application. If your chart includes dependencies, Helm will handle the installation order for you. Helm also keeps track of your deployment history, allowing you to rollback to previous versions if something goes wrong.
Why Should You Use Helm?
So why use Helm at all? Good question. Here are some compelling reasons:
- Simplicity and Reusability: Helm charts allow you to define reusable templates that you can deploy over and over again. This saves you time and also reduces the chances of making mistakes.
- Version Control: Ever deployed something and then found yourself in “YAML hell” because you couldn’t roll back? Helm charts come with versioning, so if something goes wrong, you can easily revert to a previous version.
- Collaboration: When working with a team, using Helm charts ensures everyone is on the same page. You can share charts, and everyone uses the same set of configurations, preventing the classic “it works on my machine” syndrome.
- Template Management: Kubernetes itself doesn’t handle application templating well. Helm fills this gap by allowing the use of Go templates. With Helm, you can add variables and functions to your Kubernetes manifests, making them dynamic and easily adjustable.
- Environment Configuration: Helm’s templating capabilities are perfect for applications that need to be deployed to different environments (e.g., dev, staging, production). Using the
values.yaml
file, you can change environment-specific configurations easily without altering the core chart.
Getting Started with Helm: Installation
Alright, let’s get into the practical stuff. First things first: you need to install Helm on your machine. Whether you’re on macOS, Linux, or Windows, installing Helm is pretty straightforward. Here’s how to do it:
- For macOS: Just run
brew install helm
if you use Homebrew. Easy as that! - For Linux: Run the command:
curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash
- For Windows: If you’re on Windows, I recommend using Chocolatey. You can run:
choco install kubernetes-helm
Once installed, you can verify everything is working by running helm version
. If you see the version details, you’re good to go!
Understanding Helm Architecture
Let’s get under the hood for a moment—but don’t worry, I’ll keep it simple. Helm has two main components:
- Helm Client: This is the CLI you interact with. It sends requests to the Kubernetes API.
- Helm Chart: This is the bundle containing the Kubernetes manifest files—essentially a packaged format for your applications.
There’s no more Tiller (as of Helm 3), which was an additional server component that many found complicated. Now, Helm just interacts directly with Kubernetes, making things a lot more secure and simple.
The Basics of Helm Commands
Alright, you’ve got Helm installed—great! Now, let’s learn some of the most important commands, along with how to download and change configurations using the values.yaml
file. You’ll be using these commands a lot, so getting comfortable with them is key.
- helm repo add: This command lets you add a repository of Helm charts. Think of it like adding a software repository to your system. For instance:
helm repo add bitnami https://charts.bitnami.com/bitnami
- helm search repo: This lets you search for a specific chart. If you want to deploy WordPress, for example, you’d search:
helm search repo wordpress
- helm install: Once you find a chart, you can install it. For example:
helm install my-wordpress bitnami/wordpress
By default, Helm will use the values in the values.yaml
file for configuration. If you want to customize any of these settings, you can do so by passing your own values.yaml
file like this:
helm install my-wordpress bitnami/wordpress -f custom-values.yaml
This allows you to override the default settings with your own configurations.
- helm upgrade: Let’s say you want to change some configuration. You’d use:
helm upgrade my-wordpress bitnami/wordpress
You can also use a custom values.yaml
file during an upgrade to modify the configurations:
helm upgrade my-wordpress bitnami/wordpress -f custom-values.yaml
- helm uninstall: If things don’t work out and you want to remove the app, just run:
helm uninstall my-wordpress
Using Helm: An Improved Guide
This guide explains the basics of using Helm to manage packages on your Kubernetes cluster. It assumes that you have already installed the Helm client.
If you are simply interested in running a few quick commands, you may wish to begin with the Quickstart Guide. This chapter covers the particulars of Helm commands, explains the core concepts behind Helm, and guides you step-by-step through using Helm.
Three Big Concepts
A Chart is a Helm package. It contains all the resource definitions necessary to run an application, tool, or service inside of a Kubernetes cluster. Think of it like the Kubernetes equivalent of a Homebrew formula, an Apt dpkg, or a Yum RPM file.
A Repository is the place where charts can be collected and shared. Repositories are like app stores for Kubernetes charts. They can host charts that you can download and use to deploy applications.
A Release is an instance of a chart running in a Kubernetes cluster. You can install the same chart multiple times in your cluster, and each installation is called a release. Consider a MySQL chart: if you want two separate MySQL databases running, you can install the chart twice, and each installation will have its own unique release name and configuration.
With these concepts in mind, we can summarize Helm like this:
- Helm manages Kubernetes charts (packages).
- Charts are collections of files that describe Kubernetes resources.
- Repositories are locations where charts are stored and shared.
- Releases are deployed instances of charts.
‘helm search’: Finding Charts
Helm comes with a powerful search command. It can be used to search two different sources:
helm search hub
: This searches the Artifact Hub, which lists Helm charts from dozens of different repositories.helm search repo
: This searches the repositories that you have added to your local Helm client (usinghelm repo add
). This search is done over local data, and no public network connection is needed.
For example, you can find publicly available charts by running:
$ helm search hub wordpress
URL CHART VERSION APP VERSION DESCRIPTION
https://artifacthub.io/packages/helm/bitnami/word... 10.0.0 5.7.2 Web publishing platform for building blogs and ...
The above searches for all WordPress charts on Artifact Hub. Without filters, helm search hub
shows all available charts related to your query.
You can also use helm search repo
to find charts within repositories you have already added:
$ helm repo add bitnami https://charts.bitnami.com/bitnami
"bitnami" has been added to your repositories
$ helm search repo bitnami
NAME CHART VERSION APP VERSION DESCRIPTION
bitnami/wordpress 10.0.0 5.7.2 Web publishing platform for building blogs and ...
Helm search uses a fuzzy string matching algorithm, so even if you only know part of the chart name, Helm will likely find what you’re looking for.
‘helm install’: Installing a Package
To install a new package, use the helm install
command. It takes two main arguments: a release name that you pick, and the name of the chart you want to install.
$ helm install my-wordpress bitnami/wordpress
This command will install the WordPress chart and create a release named my-wordpress
. During installation, Helm will print useful information about which resources were created, the status of the release, and any additional steps you might need to take.
If you want Helm to generate a random release name for you, simply leave off the release name and use the --generate-name
flag:
$ helm install bitnami/wordpress --generate-name
Customizing Helm Charts: Values and Overrides
Helm charts come with a set of default values that are defined in the values.yaml
file. Sometimes you need to customize these values to suit your specific needs. You can do this by providing your own custom values during the installation or upgrade process.
You have two main options for passing configuration data during install:
- Using a values file (
--values
or-f
): Specify a YAML file containing your overrides.
$ helm install my-wordpress bitnami/wordpress -f custom-values.yaml
This allows you to override the default settings with configurations defined in your custom-values.yaml
file.
- Using the
--set
flag: Specify overrides directly on the command line.
$ helm install my-wordpress bitnami/wordpress --set wordpressUsername=admin --set wordpressPassword=secretpassword
This is convenient for small changes, but using a values file is generally better for maintainability when you have many overrides.
‘helm upgrade’ and ‘helm rollback’: Modifying a Release
When you need to make changes to an existing release, you can use the helm upgrade
command. For example:
$ helm upgrade my-wordpress bitnami/wordpress -f new-values.yaml
This command will apply the new settings from new-values.yaml
to the existing release named my-wordpress
.
If something goes wrong during an upgrade, Helm allows you to roll back to a previous release version using the helm rollback
command:
$ helm rollback my-wordpress 1
This will roll back the my-wordpress
release to its first revision. Each time you perform an upgrade, Helm increments the revision number, making it easy to track and revert changes if needed.
Managing Repositories with ‘helm repo’
Helm uses repositories to store and distribute charts. You can add new repositories, list the existing ones, and keep them up to date with the following commands:
- Adding a repository:
$ helm repo add bitnami https://charts.bitnami.com/bitnami
- Listing repositories:
$ helm repo list
This will show all repositories you have added to your Helm client.
- Updating repositories:
$ helm repo update
This command refreshes the local cache of chart information from all added repositories.
Uninstalling a Release with ‘helm uninstall’
When it’s time to remove an application, use the helm uninstall
command:
$ helm uninstall my-wordpress
This will remove the release named my-wordpress
from the cluster. If you need to keep a record of deleted releases, you can use the --keep-history
flag:
$ helm uninstall my-wordpress --keep-history
Conclusion
Helm is an incredibly powerful tool for managing Kubernetes applications. It streamlines the process of packaging, configuring, deploying, and maintaining applications in a Kubernetes environment. By using Helm charts, you can ensure consistent deployments, easily roll back changes, and reduce the complexity of managing your Kubernetes infrastructure.
Whether you’re deploying simple applications or complex, multi-tiered stacks, Helm can save you time and reduce errors. As you get more comfortable with Helm, you’ll find that it becomes an essential part of your Kubernetes toolkit.
In the next chapter, we’ll dive into developing your own Helm charts, which will give you even greater control and flexibility over your deployments.