2

We are using helm provider in Terraform to provision istio ingress gateway which in backend use this chart

Below is the terraform code snippet to provision the same. Please help to override the default chart value to create an internal load balancer instead of the default external one. We are aware that it can be done by updating the annotation in the manifest file. But not sure how to do the same in the terraform code snippet?

terraform {
  required_providers {
    helm = {
      source = "hashicorp/helm"
      version = ">= 1.0.0"
    }
  }
}

provider "helm" {
  kubernetes {
    config_path = "${var.kubeconfig_file}"
  }
}

resource "helm_release" "istio-ingress" {
  repository        = local.istio_charts_url
  chart             = "gateway"
  name              = "istio-ingress-gateway"
  namespace         = kubernetes_namespace.istio_system.metadata.0.name
  version           = ">= 1.12.1"
  timeout           = 500
  cleanup_on_fail   = true
  force_update      = false
  depends_on        = [helm_release.istiod]
}
Nitin G
  • 714
  • 7
  • 31

1 Answers1

4

You can either use the set argument block (https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release#set) or the values argument (https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release#values) of the resource helm_release to override the default settings from the original values.yaml

Should look something like:

resource "helm_release" "istio-ingress" {
  repository        = local.istio_charts_url
  chart             = "gateway"
  name              = "istio-ingress-gateway"
  namespace         = kubernetes_namespace.istio_system.metadata.0.name
  version           = ">= 1.12.1"
  timeout           = 500
  cleanup_on_fail   = true
  force_update      = false
  depends_on        = [helm_release.istiod]

  set {
    name  = "serviceAnnotations.cloud.google.com/load-balancer-type"
    value = "internal"
  }
}

or

resource "helm_release" "istio-ingress" {
  repository        = local.istio_charts_url
  chart             = "gateway"
  name              = "istio-ingress-gateway"
  namespace         = kubernetes_namespace.istio_system.metadata.0.name
  version           = ">= 1.12.1"
  timeout           = 500
  cleanup_on_fail   = true
  force_update      = false
  depends_on        = [helm_release.istiod]

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

and place a custom-values.yaml file in your code.

This article explains it pretty nicely: https://getbetterdevops.io/terraform-with-helm/

Hope this helps!

rock'n rolla
  • 1,883
  • 1
  • 13
  • 19
  • Hey @rock'n thank you so much for the prompt response. Really appreciate this. Also, please share where did you get the term serviceAnnotations? Because I cannot see this property in the chart default values but I can see podAnnotations though – Nitin G Jul 04 '22 at 08:56
  • There you go: https://github.com/istio/istio/blob/master/manifests/charts/gateways/istio-ingress/values.yaml#L51 I haven't used this helm chart myself, so can't vouch what each value does. I'm afraid you'll have to figure that one out. Also, please mark the answer as accepted if it did solve your problem :) – rock'n rolla Jul 04 '22 at 08:58
  • Thanks for the reference. It does appear in the GitHub chart but it is not there in the artifacthub file https://artifacthub.io/packages/helm/istio-official/gateway?modal=values – Nitin G Jul 04 '22 at 09:04