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.