Score:0

Terraform running Helm deploy against AKS fails with "failed to find any PEM data in key input"

ph flag

I'm setting up a one-click deploy of an environment for some webservices, in which Terraform is used to deploy the infrastructure and then run Helm to populate it. The Terraform step is working fine and I can see the Kubernetes cluster created in Azure, but the Helm deploy is failing.

I'm using the Hashicorp Helm provider, and the config in providers.tf looks like this:

provider "helm" {
  repository_config_path = "${path.module}/helm/repositories.yaml" 
  repository_cache       = "${path.module}/helm"
  kubernetes {
    host                     = azurerm_kubernetes_cluster.k8s.kube_config[0].host
    username                 = azurerm_kubernetes_cluster.k8s.kube_config[0].username
    password                 = azurerm_kubernetes_cluster.k8s.kube_config[0].password
    cluster_ca_certificate   = base64decode(azurerm_kubernetes_cluster.k8s.kube_config[0].cluster_ca_certificate)
    client_certificate       = base64decode(azurerm_kubernetes_cluster.k8s.kube_config[0].client_certificate)
    client_key               = azurerm_kubernetes_cluster.k8s.kube_config[0].client_key
  }
  debug = true
}

The listed /helm/repositories.yaml file just lets it access our own repositories of in-house Helm charts.

The actual deployment step is super basic, and looks like this:

resource "helm_release" "company-service" {
  name       = "company-service"
  repository = "oci://company.azurecr.io/helm"
  chart      = "company-service"
}

where obviously company is the name of our company and service is the name of the webservice I want to deploy.

The precise error message is:

│ Error: Kubernetes cluster unreachable: tls: failed to find any PEM data in key input
│ 
│   with helm_release.company-service,
│   on main.tf line 29, in resource "helm_release" "company-service":
│   29: resource "helm_release" "company-service" {

where line 29 is the line kubernetes { from the providers.tf block above.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.