Search code examples
kubernetesazure-pipelineskubernetes-helmacr

Deploy helm chart from Azure Container Registry


I have a multistage pipeline with the following

Stage build:

  1. build docker image
  2. push image to ACR
  3. package helm chart
  4. 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?


Solution

  • I never manage to find a fix for this, so I ended up with a another solution.

    Instead of trying to publish the package to the registry, I published it as an artifact to the pipeline. In the step for deployment, I downloaded the artifact and applied it to kubernetes.

    The benefits about doing it like this is that it is easy to rollback to a specific version, just be rerunning a specific deployment stage in the desired pipeline.

    Sudo pipeline:

    Stage: build
      build
      test
      generate image
      publish image to registry
      generate helm package (setting helm version and image tag)
      publish package as azure artifacts
    Stage: Test deployment
      download artifacts
      apply helm package
    Stage: Prod deployment
      download artifacts
      apply helm package