Skip to content

Update terraform module to use helm3 #20

gulsenjm edited this page Jun 14, 2021 · 2 revisions

This wiki page prepared for ticket #20

Since we want to work with helm v3 we need to install helm3

To install helm3 follow next steps:

  1. Under your $home directory create bin directory and install helm3:
mkdir bin

cd bin/

wget https://get.helm.sh/helm-v3.3.2-linux-amd64.tar.gz

tar -xvf helm-v3.3.2-linux-amd64.tar.gz

mv linux-amd64/helm /home/gulsenjm/bin/helm3
  1. Check you helm version:
[gulsenjm@bastion-fuchicorp-com ~]$ helm3 version
version.BuildInfo{Version:"v3.3.2", GitCommit:"e5077257b6ca106d1f65652b4ca994736d221ab1", GitTreeState:"clean", GoVersion:"go1.14.9"}

Steps to update our terraform module to support helm3:

  1. Go to the terraform-helm-chart repository and create your branch from the master branch to have the latest updates.

  2. Go to your terminal and clone the terraform-helm-chart repository:

git clone git@github.com:fuchicorp/terraform-helm-chart.git

  1. Checkout to your branch:

git checkout YOUR_BRANCH

  1. Before starting to work on files read properly README.md file, you will find which files you need to create to work and test.

  2. Create a directory to create inside helm chart to test. If you would like to quickly create helm chart then run:

cd terraform-helm-chart

mkdir module-test

cd module-test/
  1. If you would like to quickly create helm chart then run:
helm3 create charts/example
  1. After you created your helm chart you can go ahead and do modifications inside (modify ingress part):
ingress:
  enabled: true
  annotations:
    kubernetes.io/ingress.class: nginx
    kubernetes.io/tls-acme: "true"
  hosts:
    - host: ${deployment_endpoint}
      paths:
      - /
  tls:
   - secretName: chart-example-tls
     hosts:
       - ${deployment_endpoint}
  1. When modifications are done for values.yaml you will need to create module.tf to call the module. Make sure you created you module.tf file under module-test directory.

module.tf:

module "helm_deploy" {
  source                 = "../"
  deployment_name        = "example-deployment"
  deployment_environment = "dev"
  deployment_endpoint    = "example.your_domain.com"
  deployment_path        = "example"                 
}
  1. Try to run the terraform init command to make sure your current module supports helm3 or not. If you get red output complaining about the version you have to do the next steps.

  2. Now go to versions.tf open the file which is under the terraform-helm-chart directory.

  3. On your browser open terraform registry and find the official helm module On top of the page, you will see the Version bar, click on it and you will see list of versions.

  4. Check which version you have on your versions.tf file under provider "helm". As you see, your helm provider version is old. Now you have to try versions to find out which one is supports helm3.

You are going to try one by one version and run terraform init until you will see the green output, successfully initialized. Then run terraform apply to deploy your example chart. Then check your ingress and pods:

kubectl get pods -n dev
kubectl get ingress -n dev