我有一个带有以下的多级管道
阶段构建:
- 构建docker镜像
- 将图像推送到ACR
- 包装舵图
- 将舵图推送给ACR
阶段部署:
- 头盔升级
将舵图推到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)
将舵图部署到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)
错误:
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"
]
}
我做错了什么?我必须先从ACR中export
掌舵图,然后才能部署它吗?
@sshepel的回答实际上有所帮助,您需要登录到注册表才能提取。但是,只需简单的AzureCLI登录就足够了。
- task: AzureCLI@2
displayName: Login to Azure Container Registry
inputs:
azureSubscription: <Azure Resource Manager service connection to your subscription and resource group>
scriptType: bash
scriptLocation: inlineScript
inlineScript: |
az acr login --name <container registry name>.azurecr.io
之后,它完美地处理了未记录的HelmDeploy任务。
我也遇到过同样的问题,唯一帮助我的选项是在helm升级之前添加注册表登录步骤。
- 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
helm upgrade
的语法应该是:
- task: HelmDeploy@0
displayName: 'helm upgrade'
inputs:
connectionType: 'Kubernetes Service Connection'
kubernetesServiceConnection: connection
command: upgrade
chartName: '$(name)'
chartVersion: '$(Version)'
releaseName: azuredevopsdemo
尝试将chartName
值替换为charts/$(imageRepository)
。