Helm Provider

The Helm Provider enables Terraform to manage Helm charts in Kubernetes clusters. Helm charts are pre-packaged Kubernetes configurations that simplify deploying complex applications. With the Helm Provider, you can install, upgrade, and manage these charts as part of your Terraform configurations.

Key Features:

  • Deploy Helm charts to Kubernetes clusters.
  • Manage chart versions and values for customization.
  • Seamlessly upgrade, rollback, or uninstall Helm releases.
  • Automate application lifecycle management for Kubernetes.

Example Use Case: Deploying an NGINX Helm Chart
Here’s how to deploy an NGINX application using a Helm chart with the Helm Provider:

provider "helm" {
  kubernetes {
    config_path = "~/.kube/config"
  }
}

resource "helm_release" "nginx" {
  name       = "nginx"
  repository = "https://charts.bitnami.com/bitnami"
  chart      = "nginx"
  namespace  = "example-namespace"

  values = <<EOF
replicaCount: 2
service:
  type: LoadBalancer
EOF
}

What’s Happening Here?

  • The provider block connects Terraform to the Kubernetes cluster via the Helm Provider.
  • The helm_release resource deploys the NGINX chart from the Bitnami Helm repository into the example-namespace.
  • The values block customizes the deployment, setting the replica count to 2 and configuring the Service as a LoadBalancer.

Advanced Tip:
Helm charts often include default values that you may want to override selectively. Use Terraform’s file() function to load a separate YAML file for complex customizations:

resource "helm_release" "nginx_custom" {
  name       = "nginx-custom"
  repository = "https://charts.bitnami.com/bitnami"
  chart      = "nginx"
  namespace  = "example-namespace"

  values = file("${path.module}/custom-values.yaml")
}

This approach is ideal for managing multiple environments, as you can maintain separate value files for development, staging, and production.