我将使用 for 循环扫描文件夹中的文件(value-f1.yaml、values-f2.yaml...),每次使用文件名作为变量并在 Azure 管道作业中运行该作业根据该值文件部署 helmchart。该文件夹位于 GitHub 存储库中。所以我在想这样的事情:
管道.yaml
stages:
- stage: Deploy
variables:
azureResourceGroup: ''
kubernetesCluster: ''
subdomain: ''
jobs:
${{ each filename in /myfolder/*.yaml}}:
valueFile: $filename
- template: Templates/deploy-helmchart.yaml@pipelinetemplates
Run Code Online (Sandbox Code Playgroud)
部署-helmchart.yaml
jobs:
- job: Deploy
pool:
vmImage: 'ubuntu-latest'
steps:
- task: HelmInstaller@1
displayName: 'Installing Helm'
inputs:
helmVersionToInstall: '2.15.1'
condition: and(succeeded(), startsWith(variables['build.sourceBranch'], 'refs/tags/v'))
- task: HelmDeploy@0
displayName: 'Initializing Helm'
inputs:
connectionType: 'Azure Resource Manager'
azureSubscription: $(azureSubscription)
azureResourceGroup: $(azureResourceGroup)
kubernetesCluster: $(kubernetesCluster)
command: 'init'
condition: and(succeeded(), startsWith(variables['build.sourceBranch'], 'refs/tags/v'))
- task: PowerShell@2
displayName: …Run Code Online (Sandbox Code Playgroud)