DEV Community

Cover image for K8s QuickBites: Helm Basics
Kaye Alvarado for Developers @ Asurion

Posted on • Updated on

K8s QuickBites: Helm Basics

Hey there! Welcome to another quick bites blog on Kubernetes. Read time, 2 minutes! I like to keep it short and serve as quick references only when doing common tasks as a K8s administrator.

The focus of this discussion is on Helm.

What is Helm?

Think about bringing up an end-to-end application in Kubernetes with multiple yaml files that includes various resources such as deployments, service accounts, secrets, and others. A simple application would have some complexity in management, but as it becomes larger, it would be very difficult to manage. This is what helm is trying to solve.

Helm is nothing but a package manager for Kubernetes. Helm is used to manage Charts, which are packages of pre-configured Kubernetes resources making application management in Kubernetes way easier.

Image description

Installation of helm is pretty straightforward and options can be viewed here.

Basic Helm Commands

First, search and download from a helm repository to your local machine. You can also update it if it already exists.

$helm search repo <repository>
$helm repo update <repository>
Enter fullscreen mode Exit fullscreen mode

To view the existing repositories on your local machine, you can use the list command

$helm ls 
NAME         CHART VERSION   APP VERSION.  DESCRIPTION                                       
chart/name   1.0.0           1.0.0         App Description
Enter fullscreen mode Exit fullscreen mode

Install Helm Charts

You can install a helm chart overriding the default values with a values.yaml file.

$helm install <chart> <repo> -n <namespace> -f <path to values.yaml file>
Enter fullscreen mode Exit fullscreen mode

Once installed, you can then verify the deployments, daemonsets, or other resources that was installed

$kubectl get deploy -n <namespace>
$kubectl get ds -n <namespace>
$kubectl get pods -n <namespace>
Enter fullscreen mode Exit fullscreen mode

You can also use the values used in the helm installation and modify this for a later update

$helm get values <release-name> -n <namespace>
Enter fullscreen mode Exit fullscreen mode

Upgrade Helm Charts

Everytime you upgrade a helm chart, a revision is added and this allows you to easily rollback to a previous version if an upgrade becomes problematic. List the versions with the list command (for the current deployed chart), or the history command.

$helm list -n <namespace>
NAME   NAMESPACE  REVISION  UPDATED     STATUS   CHART  
chart  namespace  2         <datetime>  deployed chart-1.0.0
$helm history <chart> -n <namespace>
REVISION    UPDATED                     STATUS      CHART                   APP VERSION DESCRIPTION     
1           Thu May 23 18:53:23 2024    superseded  chart-0.9.9 0.9.9       Install complete
2           Mon Jun  3 19:52:28 2024    superseded  chart-1.0.0 1.0.0       Upgrade complete
Enter fullscreen mode Exit fullscreen mode

To rollback to a previous version, you can use the rollback command

$helm rollback <chart> <version> -n <namespace>
Enter fullscreen mode Exit fullscreen mode

There may be times when a simple upgrade will fail due to a major change in the helm package. An option here is to do an uninstall and install.

$helm uninstall <chart> -n <namespace>
$helm install <chart> <repo> -n <namespace> -f <path to values.yaml file>
Enter fullscreen mode Exit fullscreen mode

...and that's it! Happy helming! 😄

Top comments (0)