Using Terraform to Deploy a Helm Chart With Helm Test Execution

Pre-Requisites

Creating main.tf

We will start by creating a main.tf file to define our Terraform code. This file will contain all of our terraform code except our variables and outputs. You can skip down to the bottom of this section if you just want to see the full main.tf file.

Creating variables.tf

Now we will define a variables.tf file. This file will contain all of our variables used to configure the resources within main.tf. Not much to explain here.

Creating kubeconfig.tf

We will now define a template which will be used for generating a kubeconfig file. This template contains the basic structure of a kubeconfig file with a few values that can be specified using variables.

Running Terraform

With all of this defined all that is left to do is execute it. You will need to execute ‘terraform init’ to initialize all of the providers and the backend. Then you will execute ‘terraform apply’ to run the deploy of the defined resources.

Conclusion

The goal of this short article is to describe how to deploy a helm chart using terraform and how to automatically execute the tests defined within that helm chart after the chart has been deployed. Hopefully at some future point the execution of ‘helm test’ can be integrated directly into the helm provider, but for now this will have to do.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store