<ol>
<li>you can use terraform to install helm charts, you dont have to obviously</li>
<li>something is probably wrong with your kubernetes connection, check if its actually working</li>
</ol>

CC BY-SA 4.0
2019-03-12T09:08:34.393Z
2019-03-12T09:08:34.393Z
4c74356b41
<p>I have been trying to install Helm charts using Terraform in a cluster which operates in GKE. </p>

<p>My question is in two parts:</p>

<ol>
<li>Is it a good practice to use Terraform for installing Helm charts?</li>
<li>I have been getting this error when Terraform tries to install a Helm chart:</li>
</ol>

<blockquote>
  <p>helm_release.release_name: Get
  <a href="https://XX.XXX.XX.X/apis/extensions/v1beta1/namespaces/kube-system/deployments/tiller-deploy" rel="nofollow noreferrer">https://XX.XXX.XX.X/apis/extensions/v1beta1/namespaces/kube-system/deployments/tiller-deploy</a>:
  dial tcp XX.XXX.XX.X:443: connect: connection refused</p>
</blockquote>

<p>Here is how I am configuring the Helm chart:</p>

<pre><code>provider "kubernetes" {


  host     = "${var.cluster-host}"
  username = "${var.cluster-username}"
  password = "${var.cluster-password}"

  client_certificate     = "${base64decode(var.cluster-client-cert)}"
  client_key             = "${base64decode(var.cluster-client-key)}"
  cluster_ca_certificate = "${base64decode(var.cluster-ca-certificate)}"
}

resource "kubernetes_service_account" "tiller" {
  metadata {
    name      = "tiller"
    namespace = "kube-system"
  }
}

resource "kubernetes_cluster_role_binding" "tiller" {
  metadata {
    name = "tiller"
  }

  role_ref {
    api_group = "rbac.authorization.k8s.io"
    kind      = "ClusterRole"
    name      = "cluster-admin"
  }

  # api_group has to be empty because of a bug:
  # https://github.com/terraform-providers/terraform-provider-kubernetes/issues/204
  subject {
    api_group = ""
    kind      = "ServiceAccount"
    name      = "tiller"
    namespace = "kube-system"
  }
}

provider "helm" {
  install_tiller  = true
  service_account = "tiller"
  namespace       = "kube-system"
  kubernetes {
      host     = "${var.cluster-host}"
      username = "${var.cluster-username}"
      password = "${var.cluster-password}"

      client_certificate     = "${base64decode(var.cluster-client-cert)}"
      client_key             = "${base64decode(var.cluster-client-key)}"
      cluster_ca_certificate = "${base64decode(var.cluster-ca-certificate)}"
  }
}
</code></pre>

CC BY-SA 4.0
2019-03-13T14:54:22.337Z
I suggest you check from where you are executing terraform trying to connect your k8s cluster with a kubeconfig you have defined in terraform.  Once you are sure you can connect to your k8s cluster, try to install/init helm manually. Doing these steps manually gives you any error?
RuBiCK
CC BY-SA 4.0
2019-05-06T19:31:31.517Z
I suspect the helm provider is running before the Tiller is ready.
tvon
<terraform><helm><gcp>
Installing Helm charts using Terraform
Harith
# Installing Helm charts using Terraform

(Asked by: username_0 on 2019-03-08)

I have been trying to install Helm charts using Terraform in a cluster which operates in GKE. 
My question is in two parts:

Is it a good practice to use Terraform for installing Helm charts?
I have been getting this error when Terraform tries to install a Helm chart:


helm_release.release_name: Get
  https://XX.XXX.XX.X/apis/extensions/v1beta1/namespaces/kube-system/deployments/tiller-deploy:
  dial tcp XX.XXX.XX.X:443: connect: connection refused

Here is how I am configuring the Helm chart:
provider "kubernetes" {


  host     = "${var.cluster-host}"
  username = "${var.cluster-username}"
  password = "${var.cluster-password}"

  client_certificate     = "${base64decode(var.cluster-client-cert)}"
  client_key             = "${base64decode(var.cluster-client-key)}"
  cluster_ca_certificate = "${base64decode(var.cluster-ca-certificate)}"
}

resource "kubernetes_service_account" "tiller" {
  metadata {
    name      = "tiller"
    namespace = "kube-system"
  }
}

resource "kubernetes_cluster_role_binding" "tiller" {
  metadata {
    name = "tiller"
  }

  role_ref {
    api_group = "rbac.authorization.k8s.io"
    kind      = "ClusterRole"
    name      = "cluster-admin"
  }

  # api_group has to be empty because of a bug:
  # https://github.com/terraform-providers/terraform-provider-kubernetes/issues/204
  subject {
    api_group = ""
    kind      = "ServiceAccount"
    name      = "tiller"
    namespace = "kube-system"
  }
}

provider "helm" {
  install_tiller  = true
  service_account = "tiller"
  namespace       = "kube-system"
  kubernetes {
      host     = "${var.cluster-host}"
      username = "${var.cluster-username}"
      password = "${var.cluster-password}"

      client_certificate     = "${base64decode(var.cluster-client-cert)}"
      client_key             = "${base64decode(var.cluster-client-key)}"
      cluster_ca_certificate = "${base64decode(var.cluster-ca-certificate)}"
  }
}

**Tags:** terraform, helm, gcp

> **Comments:**
> **username_1**: I suggest you check from where you are executing terraform trying to connect your k8s cluster with a kubeconfig you have defined in terraform.  Once you are sure you can connect to your k8s cluster, try to install/init helm manually. Doing these steps manually gives you any error?  
> **username_2**: I suspect the helm provider is running before the Tiller is ready.  

---

## 1 answers

### Answer by username_3 on 2019-03-12. Score: 1

1. you can use terraform to install helm charts, you dont have to obviously
2. something is probably wrong with your kubernetes connection, check if its actually working


---

