Discovering the Helm Package Manager for Deployments

Objectives
After completing this lesson, you will be able to:

After completing this lesson, you will be able to:

  • Describe the Helm package manager, including its benefits
  • Identify different Helm components
  • Use Helm to package and deploy your application

Helm Overview

Introduction

As your microservice-based application grows, you need to create, update, and maintain a huge variety of Kubernetes objects required to run your application. Your new application needs a deployment object and services to load balance traffic. Fortunately, you can package all manifests tied to your application into one unit and deploy, update, and delete them all at once.

What is Helm?

Helm is a package manager for Kubernetes. It is also an open-source project, that is part of the Cloud Native Computing Foundation (CNCF). Helm is a tool that simplifies the installation and management of Kubernetes applications.

Think of Helm like apt or brew for Kubernetes. These packages are called Helm charts.

You already encountered deployments as a way to deploy your application and manage its release lifecycle. But with Helm charts you can package all the Kubernetes objects that are required to run your application into one unit, such as deployments, services, and so on. You can then deploy, update, and delete them all at once.

Many Helm charts are already available in the Helm Hub. You can also create Helm charts and publish them in the Helm Hub. Or you use own Helm charts only in your environment.

Helm Components

Click on the buttons below to discover more details about each component.

To work with Helm, you must install the Helm CLI on your machine. Follow the instructions in the Helm documentation.

Helm Charts

Helm charts are packages of pre-configured Kubernetes resources. A chart contains all the resource definitions (manifests) necessary to run an application. Each Helm Chart comes with a standard project layout or file structure.

Click on each blue component of a typical Helm Chart to discover more:

Package and Deployment of an Application with Helm

Helm CLI

With the Helm CLI, you can install and manage Helm charts.

The Helm CLI has three main subcommands:

  • helm install - use this command to install a chart.
  • helm upgrade - use this command to upgrade an existing release to a new version of a chart.
  • helm delete - use this command to delete a release.

Helm in Kyma

Project "Kyma" uses Helm. With Helm, you can create and install charts in a Kyma cluster, like in any other Kubernetes environment.

Templates in Helm

Unlike the deployment manifest that you have used in the previous lesson, Helm charts use templates. These templates are the same as the manifests themselves. The only difference is that the templates are not static. They can be parameterized. This means that you can use variables in the templates. These variables can be defined in the values.yaml file. The usage of variables makes it possible to reuse the same templates for different scenarios, such as development, testing, and production, or to change the application's configuration without the need to change the template itself.

To see a complete Guide on how to use Helm and to explore all its features, go to the Helm documentation.

Example Helm chart

Let's take a look at an example Helm chart. We want to use Helm to create the hello-kyma application we created in the previous lesson. You can also access the chart in your GitHub Repository.

You can create a Helm chart for your application by running the following command:helm create hello-kyma-chart

This command creates a directory called hello-kyma-chart with sample files as a starting point for your chart. However, a straightforward chart for our application would look like this:

The Chart.yaml file contains information about the chart, such as the name, version, description, etc.

Code snippet
apiVersion: v2
name: hello-kyma-chart
description: A Helm chart for the Hello Kyma example application

# A chart can be either an 'application' or a 'library' chart.
type: application

# This is the chart version.
version: 0.1.0

# This is the version number of the application being deployed.
appVersion: "1.0.0"
Copy code

The values.yaml file contains the default configuration values for the chart. These values can be used in the templates.

Code snippet
replicaCount: 1

image:
  tag: "1.0.0"
Copy code

The templates/deployment.yaml file contains the definition of the Kubernetes deployment.

Code snippet
apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ .Release.Name }}
spec:
  replicas: {{ .Values.replicaCount }}
  selector:
    matchLabels:
      app: {{ .Release.Name }}
  template:
    metadata:
      labels:
        app: {{ .Release.Name }}
    spec:
      containers:
        - name: hello-kyma
          image: ghcr.io/sap-samples/kyma-runtime-learning-journey/hello-kyma:{{ .Chart.AppVersion }}
          ports:
            - containerPort: 8080
Copy code

You could dry run this chart before sending it to the cluster by running the following command inside the helm chart folder. This would allow you to see the output of the chart without actually sending it to the cluster.

Code snippet
helm template hello-kyma .
Copy code

If you run this, you will notice that the name hello-kyma will be used for the variables {{ .Release.Name }}.

Summary

In this lesson, you learned about Helm and how to use it to create custom charts. You also learned about the structure of a Helm chart and how to use templates in Helm charts.

Further Reading about Helm Package Manager for Deployments

Read more about the Helm Package Manager for deployments:

Save progress to your learning plan by logging in or creating an account

Login or Register