Skip to content

A Terraform Module for using the Helm provider. This is used to deploy software packages in Kubernetes. The provider needs to be configured with the proper credentials before it can be used.

Notifications You must be signed in to change notification settings

Callumccr/tf-mod-helm

Repository files navigation

README Header

tf-mod-helm

Module description

A Terraform Module for using the Helm provider. This is used to deploy software packages in Kubernetes. The provider needs to be configured with the proper credentials before it can be used.

Project: %!s() : [%!s()] | [%!s()]

Introduction

The module provisions the following resources:

  • helm_release describes the desired status of a chart in a kubernetes cluster.
    • 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_repository describes a helm repository.
    • A chart repository is a location where packaged charts can be stored and shared.

IMPORTANT:

  • The module has many flags and arugments to pass as variables for the helm_release, and helm_repository. Please check the variables.tf in this repository for more information.

Usage

IMPORTANT: The master branch is used in source just as an example. In your code, do not pin to master because there may be breaking changes between releases. Instead pin to the release tag (e.g. ?ref=tags/x.y.z) of one of our latest releases.

The below values shown in the usage of this module are purely representative, please replace desired values as required.

module "tf-mod-helm" {
  source                      = "git::https://github.com/Callumccr/tf-mod-helm.git?ref=master"
  enabled                     = true
  chart_repository_name       = "stable"
  chart_repository_url        = "https://kubernetes-charts.storage.googleapis.com"
  chart                       = "redis"
  version                     = "6.0.1"
  values                      = [
                                  "${file("values.yaml")}"
                                ]
  set                         = [
                                  {
                                    name  = "cluster.enabled"
                                    value = "true"
                                  },
                                  {
                                    name  = "metrics.enabled"
                                    value = "true"
                                  }
                                ]
  set_string                  = [
                                  {
                                    name  = "service.annotations.prometheus\\.io/port"
                                    value = "9127"
                                  }
                                ]
  set_sensitive               = [
                                  {
                                    name  = "username"
                                    value = "password"
                                  }
                                ]
}

Examples

Advanced Example 1

The following example generates a EKS managed node group and deploys and annotates pods with a helm chart to deploy into those respective workers exclusively.

TO-DO

Providers

Name Version
helm v0.10.4

Inputs

Name Description Type Default Required
chart (Required) Chart name to be installed any n/a yes
kubeconfig_context (Required) The context to use from the kubeconfig file string n/a yes
release_name (Required) Release name any n/a yes
aws_account_id The AWS account id of the provider being deployed to (e.g. 12345678). Autoloaded from account.tfvars string "" no
aws_assume_role_arn ARN of the IAM role when optionally connecting to AWS via assumed role. Autoloaded from account.tfvars. string "" no
aws_region The AWS region (e.g. ap-southeast-2). Autoloaded from region.tfvars. string "" no
ca_file (Optional) Verify certificates of HTTPS-enabled servers using this CA bundle string "" no
cert_file (Optional) Identify HTTPS client using this SSL certificate file string "" no
chart_repository_name (Required) Chart repository name string "" no
chart_repository_url (Required) Chart repository URL. string "" no
chart_version (Optional) Specify the exact chart version to install. If this is not specified, the latest version is installed string "1.8.4" no
devel (Optional) Use chart development versions, too. Equivalent to version '>0.0.0-0'. If version is set, this is ignored bool false no
disable_webhooks (Optional) Prevent hooks from running bool false no
enabled (Optional). A Switch that decides whether to create the module. Default is true bool true no
force_update (Optional) Force resource update through delete/recreate if needed bool true no
key_file (Optional) Identify HTTPS client using this SSL key file string "" no
keyring (Optional) Location of public keys used for verification string "" no
kubeconfig_path The path to kubeconfig file string "~/.kube/config" no
namespace (Optional) Namespace to install the release into string "" no
password (Optional) Password for HTTP basic authentication string "" no
recreate_pods (Optional) On update performs pods restart for the resource if applicable bool false no
repository (Optional) Repository where to locate the requested chart. If is an URL the chart is installed without install the repository string "" no
reuse (Optional) Instructs Tiller to re-use an existing name. Default is true bool true no
reuse_values (Optional) Reuse values from previous revision when upgrading a release. Same as --reuse-values flag in Helm CLI. Default is false bool false no
set (Optional) Value block with custom values to be merged with the values yaml
list(object({
name = string
value = string
}))
[
{
"name": "",
"value": ""
}
]
no
set_sensitive (Optional) Value block with custom sensitive values to be merged with the values yaml that won't be exposed in the plan's diff
list(object({
name = string
value = string
}))
[
{
"name": "",
"value": ""
}
]
no
set_string (Optional) Value block with custom STRING values to be merged with the values yaml
list(object({
name = string
value = string
}))
[
{
"name": "",
"value": ""
}
]
no
tiller_service_account The name of the service account for tiller string "helm-tiller" no
timeout (Optional) Time in seconds to wait for any individual kubernetes operation number 30 no
username (Optional) Username for HTTP basic authentication string "" no
values (Optional) List of values in raw yaml to pass to helm. Values will be merged, in order, as Helm does with multiple -f options list [] no
verify (Optional) Verify the package before installing it bool true no
wait (Optional) Will wait until all Pods, PVCs, Services, and minimum number of Pods of a Deployment are in a ready state before marking the release as successful. It will wait for as long as timeout. Default is true bool false no

Outputs

Name Description
helm_release_metadata Status of the deployed release. This includes the chart name, name of the release, kubernetes namespace, version of the release, status of the release, version of the chart, and compounded values from 'values' and 'set*' attributes
helm_repository_metadata Status of the deployed release. This includes the name and the URL of the repository read from the home

Related Projects

You can find more Terraform Modules by vising the link.

Additionally, check out these other related, and maintained projects.

References

For additional context, refer to some of these links.

Help

Got a question? We got answers.

File a Github issue, or message us on Slack

Contributors

Callum Robertson
Callum Robertson


README Footer

About

A Terraform Module for using the Helm provider. This is used to deploy software packages in Kubernetes. The provider needs to be configured with the proper credentials before it can be used.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published