1
votes

I have setup my Azure Kubernetes Cluster using Terraform and it working good.

I trying to deploy packages using Helm but not able to deploy getting below error.

Error: chart "stable/nginx-ingress" not found in https://kubernetes-charts.storage.googleapis.com repository

Note: I tried other packages as well my not able to deploy using "Terraform Resource" below is Terraform code. I tried local helm package using helm command and it works. I think the issue with Terraform helm resources. "nginx" is a sample package not able to deploy any package using Terraform.

resource "azurerm_kubernetes_cluster" "k8s" {
  name                = var.aks_cluster_name
  location            = var.location
  resource_group_name = var.resource_group_name
  dns_prefix          = var.aks_dns_prefix
  kubernetes_version  = "1.19.0"
  # private_cluster_enabled = true
  linux_profile {
    admin_username = var.aks_admin_username
    ssh_key {
      key_data = var.aks_ssh_public_key
    }
  }
  default_node_pool {
    name                = var.aks_node_pool_name
    enable_auto_scaling = true
    node_count          = var.aks_agent_count
    min_count           = var.aks_min_agent_count
    max_count           = var.aks_max_agent_count
    vm_size             = var.aks_node_pool_vm_size
  }
  service_principal {
    client_id     = var.client_id
    client_secret = var.client_secret
  }

#   tags = data.azurerm_resource_group.rg.tags
}

provider "helm" {
  version = "1.3.2"
  kubernetes {
    host = azurerm_kubernetes_cluster.k8s.kube_config[0].host
    client_key             = base64decode(azurerm_kubernetes_cluster.k8s.kube_config[0].client_key)
    client_certificate     = base64decode(azurerm_kubernetes_cluster.k8s.kube_config[0].client_certificate)
    cluster_ca_certificate = base64decode(azurerm_kubernetes_cluster.k8s.kube_config[0].cluster_ca_certificate)
    load_config_file       = false
  }
}

resource "helm_release" "nginx-ingress" {
  name        = "nginx-ingress-internal"
  repository  = "https://kubernetes-charts.storage.googleapis.com"
  chart       = "stable/nginx-ingress"
  set {
        name  = "rbac.create"
        value = "true"
    }
}
1

1 Answers

1
votes

You should skip stable in the chart name: it is a repository name but you have no helm repositories defined. Your resource should look like:

resource "helm_release" "nginx-ingress" {
  name        = "nginx-ingress-internal"
  repository  = "https://kubernetes-charts.storage.googleapis.com"
  chart       = "nginx-ingress"
  ...
}

which is an equivalent to the helm command:

helm install nginx-ingress-internal nginx-ingress --repo https://kubernetes-charts.storage.googleapis.com 

Alternatively you can define repositories with the repository_config_path.