close icon
daily.dev platform

Discover more from daily.dev

Personalized news feed, dev communities and search, much better than what’s out there. Maybe ;)

Start reading - Free forever
Start reading - Free forever
Continue reading >

Helm Basics for Kubernetes Newbies

Helm Basics for Kubernetes Newbies
Author
Nimrod Kramer
Related tags on daily.dev
toc
Table of contents
arrow-down

🎯

Learn the basics of Helm for Kubernetes, including key components, installation, managing apps, creating charts, and using repositories. Get started with Helm today!

Helm is a game-changer for managing apps in Kubernetes, simplifying the entire process with something called charts. Here's a quick rundown of what you'll learn about Helm:

  • What Helm Is: A toolbox that bundles everything an app needs into a chart, making it easy to deploy and manage apps on Kubernetes.
  • Key Components: Charts, releases, and repositories are the main parts of Helm, each serving a distinct purpose in app management.
  • Getting Started: How to install Helm and set up your first chart.
  • Managing Apps: Using Helm to install, upgrade, and track your apps on Kubernetes.
  • Repositories: How to find and use pre-made charts from Helm repositories.

By the end of this guide, you'll understand how Helm can make your life easier when working with Kubernetes. Whether you're a beginner or looking to streamline complex setups, Helm is an essential tool for anyone using Kubernetes.

Helm Architecture

Helm

Helm works with a client-server setup:

  • Helm client: This is the tool you use on your computer to work with charts. It helps you install, update, and manage Kubernetes apps.
  • Tiller server: This part runs inside your Kubernetes cluster. It talks to Kubernetes to get your apps running and keep them updated.
  • Kubernetes API: Tiller uses this to communicate with your Kubernetes cluster, setting up apps and keeping tabs on them.

Basically, you use the Helm client to tell Tiller what to do, and Tiller makes it happen in Kubernetes.

Understanding Helm Charts

Helm charts are packages of instructions (in YAML format) for your Kubernetes apps. Inside a chart, you'll find:

  • Chart.yaml: This file has info like the chart’s name and version.
  • values.yaml: Here are the default settings for the chart. You can change these when you install the chart to customize your app.
  • templates/: This folder has the YAML files for setting up your app. The settings from values.yaml get plugged into these files.
  • charts/: If your app needs other services to work, their charts go in this folder.

In short, Helm charts package up everything you need to get an app running on Kubernetes, making it easier to deploy, update, and share your apps.

Installing Helm

Getting Helm set up on your computer is pretty easy, but you'll need a few things first. Here's a step-by-step guide to help you get started with Helm.

Prerequisites

Before you get started with Helm, you need to have:

  • A Kubernetes cluster already running. Helm will use this to manage your apps.
  • Kubectl installed on your computer and set up to talk to your cluster.
  • Decide if you're going to use role-based access control (RBAC) for extra security.

Download the Helm Binary

  • Head over to the Helm releases page and pick the version you'd like.
  • Download the package that matches your operating system and computer's architecture. For instance, helm-v3.10.0-linux-amd64.tar.gz.

Install Helm

  • Open up the package you downloaded:
tar -zxvf helm-v3.10.0-linux-amd64.tar.gz
  • Find the helm file and move it to a place on your computer where it can be easily run. For example:
mv linux-amd64/helm /usr/local/bin/helm

Configure RBAC (Optional)

If your Kubernetes setup uses RBAC, you'll need to set up a Service Account for Tiller:

kubectl create serviceaccount tiller -n kube-system

Then, give that account the right permissions:

kubectl create clusterrolebinding tiller-admin --serviceaccount=kube-system:tiller --clusterrole=cluster-admin

Initialize Helm

To get Helm ready on your cluster, just type helm init.

Verify the Installation

To make sure Helm is ready to go, check its version with:

helm version

You should see details about the version of Helm you're running.

And that's it! You're all set to start using Helm to manage apps on Kubernetes.

Creating Your First Chart

So, you're ready to make your first Helm chart? Great! Think of a chart as a recipe for setting up an app on Kubernetes. We'll start with something simple: a basic setup for an Nginx web server.

First up, type this command:

helm create my-first-chart

This tells Helm to make a new folder called my-first-chart with some files inside:

  • Chart.yaml: This is where the chart's basic info goes, like its name and version.
  • values.yaml: Here are the settings for the chart. You can change these to make your app work the way you want.
  • templates/: These files describe how to set up your app.
  • charts/: If your app needs other apps to work, their charts go here.

In the templates folder, you'll find files for setting up your app. One of these files helps decide how many copies of your app should run at the same time.

For instance, the values.yaml file starts with just one copy. There's a line in the deployment file that looks like this:

replicas: {{ .Values.replicaCount }}

This means when you install your chart, Helm will set up your app to run just one copy, to begin with.

Customizing the Chart

You can change the settings in your chart to fit what you need. Let's say you want more copies of your app and to use a different version of Nginx:

1. Change values.yaml:

replicaCount: 3
image: nginx:1.16

2. Update the deployment file:

spec:
  replicas: {{ .Values.replicaCount }}

  containers:
    - name: {{ .Chart.Name }}
      image: {{ .Values.image }}

Now, when you install your chart, it will set up three copies of your app, all using the Nginx 1.16 image.

You can keep tweaking things in your chart until it's just right. Once you're happy, this chart makes it super easy to get your app running and to update it later.

sbb-itb-bfaad5b

Managing Releases

When you use Helm to put a chart on your Kubernetes cluster, it's called a release. You can have more than one release for the same chart, each set up a bit differently.

For instance, you might start with a release named app-v1 that uses version 1.0 of your app's chart. Later on, you could upgrade to app-v2 which uses version 2.0 of the chart with some changes in settings.

Helm has some handy commands to help you manage these releases:

Installing a Release

To start a new release, you use the helm install command:

helm install my-release my-chart

This command sets up my-chart as a new release called my-release.

Upgrading a Release

If you want to update a release with a newer version of its chart, you use helm upgrade:

helm upgrade my-release my-chart

This updates my-release to use the latest version of the chart. You can also pick a specific version if you want.

Rolling Back a Release

If an upgrade doesn't go well, you can go back to an earlier version with helm rollback:

helm rollback my-release 1

This takes my-release back to its version 1.

Deleting a Release

To remove a release and all its parts from your cluster, use:

helm uninstall my-release

This completely gets rid of my-release.

Using Helm Repositories

Helm repositories, or "chart repos", are places where Helm charts are kept and shared. There are public ones like:

You can also have private ones for your organization.

Adding a Repo

To add a repo, you use helm repo add:

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

This lets you access and use charts from Bitnami.

Searching Charts

To find charts in the repos you've added, use helm search:

helm search repo bitnami

This shows you what's available in the Bitnami repo.

Installing Charts

Once you find a chart you like, you can install it with helm install:

helm install my-release bitnami/wordpress

This sets up the WordPress chart from Bitnami as a new release called my-release.

Conclusion

Helm is a tool that makes working with Kubernetes a lot easier. It does this by grouping everything an app needs into something called a chart. This way, you can set up and manage your apps without getting lost in the details.

Here's what you should remember:

  • Helm helps you set up apps on Kubernetes quickly with something called charts.
  • You can change how an app works by tweaking its chart.
  • Helm lets you keep track of different versions of your apps easily.
  • There are places online where you can find charts made by others, ready to use.

If you want to get better at using Helm:

Helm is great for both beginners and experts in Kubernetes. It makes managing apps simpler, whether you're just starting with containers or you're looking to handle complex setups. Helm is a key tool for anyone using Kubernetes.

Related posts

Why not level up your reading with

Stay up-to-date with the latest developer news every time you open a new tab.

Read more