<p>I am started GKE cluster using Terraform (<a href="https://learn.hashicorp.com/terraform/kubernetes/provision-gke-cluster" rel="nofollow noreferrer">link</a>), Now I am trying to release the helm charts on the cluster, and tried for "Nginx Ingress" helm chart which is as follow:</p>

<pre><code>resource "helm_release" "ingress" {
  name       = "ingress"
  repository = "https://kubernetes.github.io/ingress-nginx"
  chart      = "ingress-nginx"
}
</code></pre>

<p>Terraform Plan:</p>

<pre><code>Terraform will perform the following actions:

  # helm_release.ingress will be created
  + resource "helm_release" "ingress" {
      + chart            = "ingress-nginx"
      + disable_webhooks = false
      + force_update     = false
      + id               = (known after apply)
      + metadata         = (known after apply)
      + name             = "ingress"
      + namespace        = "default"
      + recreate_pods    = false
      + repository       = "https://kubernetes.github.io/ingress-nginx"
      + reuse            = false
      + reuse_values     = false
      + status           = "DEPLOYED"
      + timeout          = 300
      + verify           = false
      + version          = "2.3.0"
      + wait             = true
    }
</code></pre>

<p>But I am getting an error</p>

<pre><code>Error: Kubernetes cluster unreachable: Get https://35.232.164.12/version?timeout=32s: dial tcp 35.232.164.12:443: i/o timeout

  on helm.tf line 36, in resource "helm_release" "ingress":
  36: resource "helm_release" "ingress" {
</code></pre>

Ravindra Gupta
<p>Here is an example with Helm3:</p>
<p>Note:</p>
<ul>
<li><code>[cluster endpoint]</code> and <code>[ca certificate]</code> are outputs of the cluster that was created with Terraform</li>
<li>You will need a <code>cluster.admin</code> and <code>iam.serviceAccountTokenCreator</code> roles on the service account</li>
</ul>
<pre>
    data "google_service_account_access_token" "kubernetes_sa" {
      target_service_account = ""
      scopes                 = ["userinfo-email", "cloud-platform"]
      lifetime               = "3600s"
    }
    
    provider "kubernetes" {
      host  = "https://[cluster endpoint]"
      token = data.google_service_account_access_token.kubernetes_sa.access_token
      cluster_ca_certificate = base64decode(
        module.gitlab-gke.cluster_ca_certificate
      )
    }
    
    provider "helm" {
      kubernetes {
        host                   = "https://[cluster endpoint]"
        token                  = data.google_service_account_access_token.kubernetes_sa.access_token
    
        cluster_ca_certificate = base64decode(
          [ca certificate]
        )
      }
    }

</pre>
