Deploy helm chart from Azure Container Registry

2/2/2021

I have a multistage pipeline with the following

Stage build: 1. build docker image 1. push image to ACR 1. package helm chart 1. push helm chart to ACR

Stage deployment: 1. helm upgrade

Push helm chart to AKS:

 task: HelmDeploy@0
 displayName: 'helm publish'
 inputs:
   azureSubscriptionForACR: '$(azureSubscription)'
   azureResourceGroupForACR: '$(resourceGroup)'
   azureContainerRegistry: '$(containerRegistry)'
   command: 'save'
   arguments: '--app-version $(Version)'
   chartNameForACR: 'charts/$(imageRepository):$(Version)'
   chartPathForACR: $(chartPath)

Deploy helm chart to AKS:

  task: HelmDeploy@0
  inputs:
    connectionType: 'Kubernetes Service Connection'
    kubernetesServiceConnection: '$(kubernetesServiceConnection)'
    command: 'upgrade'
    chartType: 'Name'
    chartName: '$(containerRegistry)/charts/$(imageRepository):$(Version)'
    chartVersion: '$(Version)'
    azureSubscriptionForACR: '$(azureSubscription)'
    azureResourceGroupForACR: '$(resourceGroup)'
    azureContainerRegistry: '$(containerRegistry)'
    install: true
    releaseName: $(Version)

Error:

failed to download "<ACR>/charts/<repository>:0.9.26" at version "0.9.26" (hint: running `helm repo update` may help)

ACR: az acr repository show-manifests --name <org> --repository helm/charts/<repository> --detail

  {
    "changeableAttributes": {
      "deleteEnabled": true,
      "listEnabled": true,
      "readEnabled": true,
      "writeEnabled": true
    },
    "configMediaType": "application/vnd.cncf.helm.config.v1+json",
    "createdTime": "2021-02-02T11:54:54.1623765Z",
    "digest": "sha256:fe7924415c4e76df370630bbb0248c9296f27186742e9272eeb87b2322095c83",
    "imageSize": 3296,
    "lastUpdateTime": "2021-02-02T11:54:54.1623765Z",
    "mediaType": "application/vnd.oci.image.manifest.v1+json",
    "tags": [
      "0.9.26"
    ]
  }

What am I doing wrong? Do I have to export the helm chart from ACR before I can deploy it?

-- Michael
acr
azure-pipelines
kubernetes
kubernetes-helm

2 Answers

12/21/2021

I have faced with the same issue, and only option that helped me is to add registry login step before helm upgrade.

- task: Bash@3
  name: registryLogin
  displayName: Login registry
  env:
   SERVICE_PRINCIPAL_APPLICATION_ID: <SPN_APP_ID>
   SERVICE_PRINCIPAL_APPLICATION_KEY: <SPN_APP_KEY>
   HELM_EXPERIMENTAL_OCI: 1 # just in case...
  input:
   targetType: inline
   script:
     echo $SERVICE_PRINCIPAL_APPLICATION_KEY | helm registry login <acr_name>.azurecr.io --username $SERVICE_PRINCIPAL_APPLICATION_ID --password-stdin
-- sshepel
Source: StackOverflow

2/3/2021

The syntax of helm upgrade should be like:

- task: HelmDeploy@0
  displayName: 'helm upgrade'
  inputs:
    connectionType: 'Kubernetes Service Connection'
    kubernetesServiceConnection: connection
    command: upgrade
    chartName: '$(name)'
    chartVersion: '$(Version)'
    releaseName: azuredevopsdemo

Try to replace the chartName value to charts/$(imageRepository).

-- Cece Dong - MSFT
Source: StackOverflow