Devolution Blog

Helmfile – Managing Environments and Services

In this blog post, we are talking about Helmfile – our go-to for managing deployments in Kubernetes. We’ll cover how we use it with multiple environments to enhance efficiency and accelerate the delivery and management of deploying services in new environments.

Helm proves to be an excellent tool for templating and sharing Kubernetes manifests in application deployment, but it can present challenges when deploying larger multi-tier applications or managing groups of applications across multiple Kubernetes clusters. 

Helmfile is useful to manage and maintain Helm releases, especially in scenarios involving multiple environments and complex configurations. It streamlines the deployment process, enhances reusability, and contributes to a more organized and maintainable Kubernetes infrastructure.

We implemented Helmfile’s environments functionality in our Helmfile setup to achieve the following:

  1. One central place for defining services per environment
  2. Easy version upgrade – since all of the services are defined in e.g. `bases/environments/development.yaml` we can easily see which version is running where and upgrade in one place 
  3. When adding a new environment, it is enough just to create a new environment file and copy/paste a list of services which should run there
|── bases
│   ├── environments
│   │   ├── devops.yaml
│   │   ├── production.yaml
│   │   ├── staging.yaml
│   │   ├── development.yaml
│   └── environments.yaml - file used to load all environments
├── helmfile.d
│   ├── cert-manager.yaml
│   ├── cluster-autoscaler.yaml
│   ├── external-dns.yaml
│   ├── ingress-controller.yaml
│   ├── monitoring.yaml
│   ├── logging.yaml

To sum up, the environment file defines which services will be installed, which version should be used and to which namespace the service will be deployed. The following picture shows the structure used for Prometheus.

posts visuals (4).jpg

Toggling the `installed` property we control whether we want to install some service in a specific environment, e.g. Prometheus

production.yaml

prometheus:
    namespace: monitoring
    version: 23.1.0
    installed: true


helmfile.d/prometheus.yaml

---
bases:
  - ../bases/environments.yaml
---
repositories:
  - name: prometheus
    url: https://prometheus-community.github.io/helm-charts
releases:
  - name: prometheus
    chart: prometheus/prometheus
    namespace: monitoring
    version: {{ .Values | getOrNil "prometheus.version" | default "23.1.0" }}
    installed: {{ .Values | getOrNil "prometheus.installed" | default "false" }}
    values:
        - ../values/{{ .Values.environmentName }}/monitoring/prometheus.yaml.gotmpl
...

Let's break down the components of the provided Helmfile:

1. bases:

  • It includes a reference to another YAML file (environments.yaml) located at ../bases/. Bases contain shared configuration or settings that can be reused across multiple environments.

2. repositories:

  • Specifies a Helm chart repository. In this case, it's the official cluster-autoscaler Helm chart repository.

3. releases:

  • Defines Helm releases, this represents all of the services which some specific service consists of (Helm charts)
  • name: The name of the release (in this case, "prometheus").
  • chart: Specifies the Helm chart to use, in this case, "prometheus/prometheus."
  • version: Uses Helm templating ({{ ... }}) to dynamically fetch the version from the specified values environment file or defaults to "23.1.0"
  • namespace: Specifies the Kubernetes namespace where the release should be installed.
  • installed: Specifies whether the release is already installed. It uses Helm templating for dynamic configuration, defaulting to "false."
  • values: Specifies the path to the values file (prometheus.yaml.gotmpl) for customizing the Helm chart parameters. The path includes Helm templating for dynamic configuration based on the environment name.

Here you go, this is just a glimpse into our approach to deployment and configuration management. Through the implementation of Helm templating, we ensure dynamic and adaptable configurations, reflecting our commitment to flexibility and efficiency.

Say hi to hello@devolut.io if you want to find out more about how we work!

Read it on Linkedin