DEV Community

Maxime Guilbert
Maxime Guilbert

Posted on • Edited on

Helm - Add some dynamism to your K8s deployment

When we begin with Kubernetes, we are writing a lot of commands or yaml files to generate all the elements we need. But, at a time, we have a lot of similar elements to create for each service, and we don't want to spend a lot of time on it.

So to help you on your Kubernetes deployments, you can use Helm.

Based on Jinja2, you can add a lot of dynamism to your deployments.


First, what is Jinja?

Jinja is a templating language for python for web pages.

It can :

  • display variables value dynamically


<li><a href="{{ user.url }}">{{ user.username }}</a></li>


Enter fullscreen mode Exit fullscreen mode
  • repeat a specific pattern for all the elements of the list


{% for user in users %}
  <li><a href="{{ user.url }}">{{ user.username }}</a></li>
{% endfor %}


Enter fullscreen mode Exit fullscreen mode
  • display specific parts based on a variable value


{% if 'priority' in data %}
    <p>Priority: {{ data['priority'] }}</p>
{% endif %}


Enter fullscreen mode Exit fullscreen mode
  • ...

Second, how to use helm?

Setup helm

When helm is installed, you have to create your Chart. It will contain the next files:

  • Chart.yaml: Will contains the chart definition
  • values.yaml: Will contains the default input values
  • .helmignore optional: Contains the file list to ignore when building a project
  • templates: Directory which contains all your yaml files.
    • _internal optional : An optional file to create some values, based on other input values.
    • your yaml files: Your yaml files to generate your secrets, deployments, and more! It's here where you can use the Jinja template!

Install chart

When your chart is ready, you can install it! It will deploy all your yaml files in the chart.

Command to install it

helm install

Then you can add a lot of options to the command

  • -f : Import a yaml file to override your default values
  • -n : Namespace where to deploy the elements
  • --set-string = : Will override a value
  • ...

Go check the documentation to have the list of all the options. (https://helm.sh/docs/helm/helm_install/)

Upgrade chart

Then you can upgrade your chart

helm upgrade

Uninstall chart

And when you want to delete it, you can use the following command

helm uninstall


The power of helm

It's quite cool to be able to add dynamism to your installations. But sometimes, you don't want to rewrite something to install a tool on Kubernetes.

So here is Artifact Hub!

Like Docker and its dockerhub, Helm gets its own public repo where you can find a lot of charts for a lot of tools!

Example with grafana
Alt Text


Links

If you want to go further:


I know it's a quick show of Helm, but I hope it will help you! 😀

Top comments (0)