多行 overrideValues Helm 安装 Azure DevOps
Multiline overrideValues Helm install Azure DevOps
是否可以在 Azure devOps 管道的 HelmDeploy 任务中指定要覆盖的值?例如,类似于下面的任务(显然不能完全按原样工作):
- task: HelmDeploy@0
displayName: 'helm install'
inputs:
connectionType: 'Azure Resource Manager'
azureSubscription: '$(RM_SERVICE_CONNECTION_NAME)'
azureResourceGroup: '$(AKS_RESOURCE_GROUP)'
kubernetesCluster: '$(AKS_NAME)'
namespace: '$(AKS_NAMESPACE)'
command: 'install'
chartType: 'FilePath'
chartPath: '$(deploymentChartName)'
releaseName: test-release
overrideValues: |
value1='value_1'
value2='value_2'
是否有任何类似于上述示例的格式可用?
恐怕overrideValues
字段不能接受多行覆盖变量。正如 document 所说,多个值应该用逗号分隔值 key1=val1,key2=val2
.
不过,您可以尝试使用 arguments
字段并传递变量。
见下文:
- task: HelmDeploy@0
displayName: 'helm install'
inputs:
connectionType: 'Azure Resource Manager'
azureSubscription: '$(RM_SERVICE_CONNECTION_NAME)'
...
...
arguments: >
--set foo=bar
--set foo1=bar1
--set foo2=bar2
事实上,这个问题中的语法就是这样。新行以逗号连接。
中也有说明
(Optional) Set values on the command line. You can specify multiple values by separating values with commas. For example, key1=val1,key2=val2. You can also specify multiple values by delimiting them with newline as so:
key1=val1
key2=val2
Please note that if you have a value which itself contains newlines, use the valueFile option, else the task will treat the newline as a delimiter. The task will construct the helm command by using these set values. For example, helm install --set key1=val1 ./redis
我在我的所有管道中都使用了这种语法,并且它按预期运行。
overrideValues: |
value1='value_1'
value2='value_2'
我们在这里使用管道的原因是我们想保留新行。此标准 yaml 语法记录在案 here.
Block Style Indicator: The block style indicates how newlines inside the block should behave. If you would like them to be kept as newlines, use the literal style, indicated by a pipe (|). If instead you want them to be replaced by spaces, use the folded style, indicated by a right angle bracket (>). (To get a newline using the folded style, leave a blank line by putting two newlines in. Lines with extra indentation are also not folded.)
回到值,如果单个值包含文档中所述的新行或根据我自己的经验包含空格,那么事情就会出现问题。这里建议的方法是使用值文件。
是否可以在 Azure devOps 管道的 HelmDeploy 任务中指定要覆盖的值?例如,类似于下面的任务(显然不能完全按原样工作):
- task: HelmDeploy@0
displayName: 'helm install'
inputs:
connectionType: 'Azure Resource Manager'
azureSubscription: '$(RM_SERVICE_CONNECTION_NAME)'
azureResourceGroup: '$(AKS_RESOURCE_GROUP)'
kubernetesCluster: '$(AKS_NAME)'
namespace: '$(AKS_NAMESPACE)'
command: 'install'
chartType: 'FilePath'
chartPath: '$(deploymentChartName)'
releaseName: test-release
overrideValues: |
value1='value_1'
value2='value_2'
是否有任何类似于上述示例的格式可用?
恐怕overrideValues
字段不能接受多行覆盖变量。正如 document 所说,多个值应该用逗号分隔值 key1=val1,key2=val2
.
不过,您可以尝试使用 arguments
字段并传递变量。
见下文:
- task: HelmDeploy@0
displayName: 'helm install'
inputs:
connectionType: 'Azure Resource Manager'
azureSubscription: '$(RM_SERVICE_CONNECTION_NAME)'
...
...
arguments: >
--set foo=bar
--set foo1=bar1
--set foo2=bar2
事实上,这个问题中的语法就是这样。新行以逗号连接。
中也有说明(Optional) Set values on the command line. You can specify multiple values by separating values with commas. For example, key1=val1,key2=val2. You can also specify multiple values by delimiting them with newline as so:
key1=val1
key2=val2
Please note that if you have a value which itself contains newlines, use the valueFile option, else the task will treat the newline as a delimiter. The task will construct the helm command by using these set values. For example, helm install --set key1=val1 ./redis
我在我的所有管道中都使用了这种语法,并且它按预期运行。
overrideValues: |
value1='value_1'
value2='value_2'
我们在这里使用管道的原因是我们想保留新行。此标准 yaml 语法记录在案 here.
Block Style Indicator: The block style indicates how newlines inside the block should behave. If you would like them to be kept as newlines, use the literal style, indicated by a pipe (|). If instead you want them to be replaced by spaces, use the folded style, indicated by a right angle bracket (>). (To get a newline using the folded style, leave a blank line by putting two newlines in. Lines with extra indentation are also not folded.)
回到值,如果单个值包含文档中所述的新行或根据我自己的经验包含空格,那么事情就会出现问题。这里建议的方法是使用值文件。