Resource: helm_release

A Release is an instance of a chart running in a Kubernetes cluster.

A Chart is a Helm package. It contains all of the resource definitions necessary to run an application, tool, or service inside of a Kubernetes cluster.

helm_release describes the desired status of a chart in a kubernetes cluster.

Example Usage - Chart Repository

resource "helm_release" "example" {
  name       = "my-redis-release"
  repository = "https://charts.bitnami.com/bitnami"
  chart      = "redis"
  version    = "6.0.1"

  values = [
    "${file("values.yaml")}"
  ]

  set {
    name  = "cluster.enabled"
    value = "true"
  }

  set {
    name  = "metrics.enabled"
    value = "true"
  }

  set {
    name  = "service.annotations.prometheus\\.io/port"
    value = "9127"
    type  = "string"
  }
}

Example Usage - Local Chart

In case a Chart is not available from a repository, a path may be used:

resource "helm_release" "example" {
  name       = "my-local-chart"
  chart      = "./charts/example"
}

Example Usage - Chart URL

An absolute URL to the .tgz of the Chart may also be used:

resource "helm_release" "example" {
  name  = "redis"
  chart = "https://charts.bitnami.com/bitnami/redis-10.7.16.tgz"
}

Example Usage - Chart Repository configured from OCI Registry

Provider supports grabbing charts from an OCI repository:

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

  # localhost registry with password protection
  registry {
    url = "oci://localhost:5000"
    username = "username"
    password = "password"
  }
}

resource "helm_release" "example" {
  name        = "testchart"
  namespace   = "helm_registry"
  repository  = "oci://localhost:5000/helm-charts"
  version     = "1.2.3"
  chart       = "test-chart"
}

Example Usage - Chart Repository configured using GCS/S3

The provider also supports helm plugins such as GCS and S3 that add S3/GCS helm repositories by using helm plugin install

# Install GCS plugin
`helm plugin install https://github.com/hayorov/helm-gcs.git`

# Run follow commands to setup GCS repository

# Init a new repository:
#   helm gcs init gs://bucket/path

# Add your repository to Helm:
#   helm repo add repo-name gs://bucket/path

# Push a chart to your repository:
#   helm gcs push chart.tar.gz repo-name

# Update Helm cache:
#   helm repo update

# Get your chart:

resource "helm_release" "GCS" {
  name        = "GCS"
  repository  = "gs://tf-test-helm-repo/charts"
  chart       = "chart"
}
# Install AWS S3 plugin
`helm plugin install https://github.com/hypnoglow/helm-s3.git`

# Run follow commands to setup S3 repository

# Init a new repository:
#   helm s3 init s3://my-helm-charts/stable/myapp

# Add your repository to Helm:
#   helm repo add stable-myapp s3://my-helm-charts/stable/myapp/

# Push a chart to your repository:
#   helm s3 push chart.tar.gz repo-name

# Update Helm cache:
#   helm repo update

# Get your chart:

resource "helm_release" "S3" {
  name        = "S3"
  repository  = "s3://tf-test-helm-repo/charts"
  chart       = "chart"
}

Example Usage - Chart Repository configured outside of Terraform

The provider also supports repositories that are added to the local machine outside of Terraform by running helm repo add

# run this first: `helm repo add bitnami https://charts.bitnami.com/bitnami`

resource "helm_release" "example" {
  name  = "redis"
  chart = "bitnami/redis"
}

Argument Reference

The following arguments are supported:

The set, set_list, and set_sensitive blocks support:

Since Terraform Utilizes HCL as well as Helm using the Helm Template Language, it's necessary to escape the {}, [], ., and , characters twice in order for it to be parsed. name should also be set to the value path, and value is the desired value that will be set.

set {
  name  = "grafana.ingress.annotations.alb\\.ingress\\.kubernetes\\.io/group\\.name"
  value = "shared-ingress"
}
set_list {
  name  = "hashicorp"
  value = ["terraform", "nomad", "vault"]
}
controller:
  pod:
    annotations:
      status.kubernetes.io/restart-on-failure: {"timeout": "30s"}
set {
    name  = "controller.pod.annotations.status\\.kubernetes\\.io/restart-on-failure"
    value = "\\{\"timeout\": \"30s\"\\}"
}

The postrender block supports two attributes:

Attributes Reference

In addition to the arguments listed above, the following computed attributes are exported:

The metadata block supports:

Import

A Helm Release resource can be imported using its namespace and name e.g.

$ terraform import helm_release.example default/example-name