0

Goal: Deploy a helm chart Terraform targeting a Azure kubernetes cluster. The chart has to be pulled from Azure Container registry.

Steps followed to push the helm chart to ACR:

helm registry login command: echo $spPassword | helm registry login .azurecr.io --username --password-stdin

helm save chart to local From within the directory that has the helm chart.yml, values.yaml and other dirs: helm chart save . .azurecr.io/:

helm push chart to Azure container Repository helm push .azurecr.io/:

I was able to pull the chart from registry, export in local again and could successfully install manually.

Following which proceeded with Terraform based deployment approach. Below is the code snippet used:

provider "azurerm" {
  version = "~>2.0"
  features {}
}

data "azurerm_kubernetes_cluster" "credentials" {
  name                = "k8stest"
  resource_group_name = "azure-k8stest"
}

provider "helm" {
  kubernetes {
    host                   = data.azurerm_kubernetes_cluster.credentials.kube_config.0.host
    client_certificate     = base64decode(data.azurerm_kubernetes_cluster.credentials.kube_config.0.client_certificate)
    client_key             = base64decode(data.azurerm_kubernetes_cluster.credentials.kube_config.0.client_key)
    cluster_ca_certificate = base64decode(data.azurerm_kubernetes_cluster.credentials.kube_config.0.cluster_ca_certificate)

  }
}

resource "helm_release" "test-tf" {
  name       = "test-twinkle"
  repository  = "https://<myacrname>.azurecr.io/helm/v1/repo"
  repository_username = <serviceprincipal appid>
  repository_password = <serviceprincipal password>
  chart      = <chart name with which it was pushed to ACR>
  version    = <chart version with which it was pushed to ACR>
  namespace  = "test-dev"
  create_namespace  = "true"
}

Error: Chart version not found in repository.

1 Answer 1

0

I've had the same issue and the documentation isn't helpful at all currently. I did find another answer on stack which somewhat sorts the issue out in a hacky sort of way by using a null_resource. I think the OCI for ACR might not be supported properly yet so you have to choose between using the deprecated API or helm3 which is currently experimental for ACR. I have not found another way to add the Repo URL :(

Sign up to request clarification or add additional context in comments.

1 Comment

Thankyou for pointing out the alternate URL. I am facing minor issues relating cntrl +\K character while using the exec module. While for the Original approach using repo path I have a requested for a clarification from Terraform as well: - github.com/hashicorp/terraform-provider-helm/issues/765

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.