[WIP] Helm

[WIP] Helm

Tags
Published

What is Helm?

Helm is a package manager for Kubernetes, designs to allow users to define, install and even upgrade Kubernetes applications.

But why Helm?

  1. Simplifies Kubernetes Deployments – Instead of writing multiple YAML files manually, Helm allows you to manage them in a structured and reusable way.
  1. Version Control for Deployments – Helm tracks installed versions of applications, making it easy to upgrade, rollback, or uninstall them.
  1. Customization with Values – You can define values.yaml files to modify application configurations without modifying the templates directly.
  1. Dependency Management – Helm allows you to package multiple applications and services together.
 

Common Helm Terms

1. Charts

This is the packaging format of Helm. It is a collection of files that define a set of Kubernetes resources.
A single chart might be used to deploy something simple, like a memcached pod, or something complex, like a full web app stack with HTTP servers, databases, caches, and so on.
 

2.Repository

Just like Github for code, a Helm repository  is a server or storage location that hosts packaged Helm charts (.tgz files) along with an index.yaml file, allowing users to discover, download, and install charts using Helm CLI commands.
 
 

Helm Commands

Let us go through a common list of Helm commands before we dive deeper into the subject.
 

Adding Chart repository

helm repo add <chart_repo_url> helm repo update

Searching for charts

helm search repo mysql

Installing a Helm Chart

helm install <release-name> <chart-name>
If you want to override the default values provided by a chart, usually necessary when setting secrets, we use a values file
helm install <release-name> -f values.yaml <chart-name>
If you want to see the manifest, that is what the template is rendering without installing; a very useful step for checking and debugging, use the --dry-run flag
helm install --dry-run <release-name> <chart-name?

Check the status

helm status <chart-name>

List all installed releases

helm list

Upgrading a Release

To upgrade a Helm release, modify the values file and use the helm upgrade command.
helm upgrade <release-name> -f values.yaml <chart-name>

Get the Kubernetes manifest of what you installed

The helm get manifest command takes a release name and prints out all of the Kubernetes resources that were uploaded to the server.
helm get manifest <release-name>

Uninstalling a Release

helm uninstall <chart-name>

Creating a Helm Chart

helm create <chart-name>

Packing the Helm chart

helm package <chart-name>
 

Architecture and creating Charts

Following the guide in the site

Structure of charts

mychart/ Chart.yaml values.yaml charts/ templates/ ...
 
The templates/ directory is where we store the template files. These templates use Go templating to dynamically generate K8 manifests based on user-defined values. So basically it is like a fill-in-the-blank sentence, you provide the blank and it creates that K8 manigest
 
The values.yaml is the default values of the chart, so this is used if you dont provide any values during helm install or helm upgrade
 
The Chart.yaml file contains a description of the chart. You can access it from within a template. It is basically the metadata for the chart
 
The charts/ directory inside a Helm chart is used to store chart dependencies. These are other Helm charts that your application requires, such as a database (e.g., PostgreSQL, Redis) or an external service.
 

Breakdown of charts/templates Directory

Some of the files are :
  • NOTES.txt: The "help text" for your chart. This will be displayed to your users when they run helm install.
  • deployment.yaml: A basic manifest for creating a Kubernetes deployment (that thing that runs pods)
  • service.yaml: A basic manifest for creating a service endpoint for your deployment
  • _helpers.tpl: A place to put template helpers that you can re-use throughout the chart
  • configmap.yaml: In Kubernetes, a ConfigMap is simply an object for storing configuration data. Pods can access the data in configMap
 
TIP: Template names do not follow a rigid naming pattern. However, we recommend using the extension .yaml for YAML files and .tpl for helpers.
 

Template Calls

To generate Kubernetes manifests dynamically, we use Go templating. A template directive is enclosed in {{ and }} blocks.
apiVersion: v1 kind: ConfigMap metadata: name: {{ .Release.Name }}-configmap data: myvalue: "Hello World"
 
So for example here, we use the templating for the name section of the metadata. This dot notation is basically like how we read elements in an object. The Release object is one of the built-in objects for Helm and the dot before indicates it the the top-most namespace
 

Built-in Objects

notion image
notion image
notion image
 

Values Files

As previously stated, these store the default values of the chart. The way I see it, the YAML file needs to be referred as an object in the templates, using the dot notation
These can be overidden either using the —-set flag for individual variables or --values for the YAML file
If we want to simple delete a default value, you must set that element of object to null
 

Template Functions and Pipelines

 
 
9896 helm repo add https://opensource.ncsa.illinois.edu/charts/ 9897 helm repo add ncsacharts https://opensource.ncsa.illinois.edu/charts/ 9898 helm search clowder2 ncsacharts 9899 helm search repo ncsacharts 9903 helm pull ncsacharts/clowder2 --untar 9908 helm install ncsacharts/clowder2 9909 helm install myclowder ncsacharts/clowder2 9910 helm uninstall myclowder 9913 helm delete myclowder 9914 helm --help 10015 helm install --dry-run --namespace ibm-hpc clowder2 . --values ibm-hpc.yaml 10016 helm dependency build 10017 helm repo add bitnami https://charts.bitnami.com/bitnami 10018 helm install --dry-run --namespace ibm-hpc clowder2 . --values ibm-hpc.yaml 10019 helm dependency build 10020 helm install --dry-run --namespace ibm-hpc clowder2 . --values ibm-hpc.yaml 10022 helm install --dry-run --namespace ibm-hpc clowder2 . --values ibm-hpc.yaml > test.txt 10026 helm install --dry-run --namespace ibm-hpc clowder2 . --values ibm-hpc.yaml > test.txt 10029 helm install --namespace ibm-hpc clowder2 . --values ibm-hpc.yaml 10047 helm install --dry-run --namespace ibm-hpc clowder2 . --values ibm-hpc.yaml > test.yaml