Skip to main content

Lab 10.4 - Helmfile and Multi-environments

Lab Objectives​

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

  • Install Helmfile.
  • Understand the structure of a helmfile.yaml.
  • Manage multiple environments (dev, staging, prod).
  • Deploy applications with Helmfile.

Estimated Duration​

45-60 minutes

Prerequisites​

  • Helm installed and configured.
  • Local Kubernetes cluster running.
  • Knowledge of Helm (previous labs).

Part 1: Installing Helmfile​

Step 1.1: Install Helmfile​

On Linux/Mac:

wget https://github.com/helmfile/helmfile/releases/download/v0.153.1/helmfile_0.153.1_linux_amd64.tar.gz
tar -xzf helmfile_0.153.1_linux_amd64.tar.gz
sudo mv helmfile /usr/local/bin/

On Windows (with Chocolatey):

choco install helmfile

Verify:

helmfile version

Part 2: Creating a helmfile.yaml​

Step 2.1: Create a Simple helmfile.yaml​

Create helmfile.yaml:

repositories:
- name: bitnami
url: https://charts.bitnami.com/bitnami

releases:
- name: nginx
namespace: default
chart: bitnami/nginx
values:
- replicaCount: 2
service:
type: ClusterIP

Step 2.2: Deploy with Helmfile​

helmfile sync

Part 3: Multi-environments​

Step 3.1: Create the Structure​

Create folders for environments:

mkdir -p environments/{dev,staging,prod}

Step 3.2: Create helmfile.yaml with Environments​

Create helmfile.yaml:

environments:
default:
values:
- environments/dev/values.yaml
staging:
values:
- environments/staging/values.yaml
prod:
values:
- environments/prod/values.yaml

releases:
- name: my-app
namespace: {{ .Values.namespace }}
chart: bitnami/nginx
values:
- replicaCount: {{ .Values.replicaCount }}

Step 3.3: Create the Values Files​

Create environments/dev/values.yaml:

namespace: dev
replicaCount: 1

Create environments/staging/values.yaml:

namespace: staging
replicaCount: 2

Create environments/prod/values.yaml:

namespace: prod
replicaCount: 3

Step 3.4: Deploy for an Environment​

# Development
helmfile -e dev sync

# Staging
helmfile -e staging sync

# Production
helmfile -e prod sync

Part 4: Managing with Helmfile​

Step 4.1: List Releases​

helmfile list

Step 4.2: Delete​

helmfile destroy

Lab Summary​

In this lab, you used Helmfile to manage multi-environment deployments. You learned how to structure your configurations and deploy to different environments.


Next Steps​

This module on Helm is now complete. You can move on to Module 11 on Monitoring and Observability.

Module 11: Monitoring and Observability


Lab created on: December 2024