Managing Helm Releases and Rollbacks

Tutorial 4 of 5

1. Introduction

1.1 Goal of the Tutorial

In this tutorial, we aim to understand how to manage Helm releases and perform rollbacks. Helm is a package manager for Kubernetes that allows developers and operators to more easily package, configure, and deploy applications and services onto Kubernetes clusters.

1.2 Learning Outcomes

By the end of this tutorial, you will be able to:

  • Update Helm releases
  • Delete Helm releases
  • Perform rollbacks in Helm

1.3 Prerequisites

Before you start with this tutorial, you should have the following:

  • Basic understanding of Kubernetes
  • Helm installed on your machine
  • Access to a Kubernetes cluster

2. Step-by-Step Guide

2.1 Concepts

  • Helm Release: A release is an instance of a chart running in a Kubernetes cluster. One chart can often be installed many times into the same cluster. Each time it is installed, a new release is created.
  • Rollbacks: Helm provides the ability to rollback a release to a previous revision if needed, making it a lot easier to recover from any configuration errors.

2.2 Examples

To manage Helm releases, we use the helm upgrade and helm delete commands.

2.2.1 Updating a Release

To update a release, we use the helm upgrade command followed by the release name and the chart name.

helm upgrade [RELEASE] [CHART]

2.2.2 Deleting a Release

To delete a release, we use the helm delete command followed by the release name.

helm delete [RELEASE]

3. Code Examples

3.1 Updating a Release

Let's say you have a release named myapp of the chart mychart. To upgrade this release, you would use the following command:

helm upgrade myapp mychart

This command upgrades the myapp release to the latest version of the mychart chart.

3.2 Deleting a Release

If you want to delete the myapp release, you would use the following command:

helm delete myapp

This command removes the myapp release from your Kubernetes cluster.

3.3 Rollback a Release

To rollback a release, we use the helm rollback command followed by the release name and the revision number.

helm rollback [RELEASE] [REVISION]

For example, to rollback the myapp release to its first revision, you would use the following command:

helm rollback myapp 1

This command rolls back the myapp release to its first revision.

4. Summary

In this tutorial, we have covered how to manage Helm releases and perform rollbacks. Specifically, we've learned how to update, delete, and rollback releases using Helm.

For further learning, you might want to look into how to create your own Helm charts and how to use Helm in combination with continuous integration/continuous delivery (CI/CD) systems.

5. Practice Exercises

5.1 Exercise 1

You have a release named myapp2 of the chart mychart2. Update this release using the appropriate Helm command.

Solution

To update the myapp2 release, we use the helm upgrade command as follows:

helm upgrade myapp2 mychart2

This command updates the myapp2 release to the latest version of the mychart2 chart.

5.2 Exercise 2

You have a release named myapp2 that you want to delete. Delete this release using the appropriate Helm command.

Solution

To delete the myapp2 release, we use the helm delete command as follows:

helm delete myapp2

This command deletes the myapp2 release from your Kubernetes cluster.

5.3 Exercise 3

You have a release named myapp3 that you want to rollback to its second revision. Rollback this release using the appropriate Helm command.

Solution

To rollback the myapp3 release to its second revision, we use the helm rollback command as follows:

helm rollback myapp3 2

This command rolls back the myapp3 release to its second revision.