我有一个包含values.yaml的Helm图表,包含:
# Elided
tolerations: []我试图通过命令行传递公差,但它总是删除引号(或者在单引号中添加双引号),尽管有以下所有尝试。因此,在安装时失败了,说它需要一个字符串。
# Attempt 0
helm install traefik traefik/traefik --set tolerations[0].key=CriticalAddonsOnly --set tolerations[0].value="true" --set tolerations[0].operator=Equal --set tolerations[0].effect=NoExecute
# Attempt 1
helm install traefik traefik/traefik --set tolerations[0].key=CriticalAddonsOnly --set "tolerations[0].value="true"" --set tolerations[0].operator=Equal --set tolerations[0].effect=NoExecute
# Attempt 2
helm install traefik traefik/traefik --set tolerations[0].key=CriticalAddonsOnly --set "tolerations[0].value=\"true\"" --set tolerations[0].operator=Equal --set tolerations[0].effect=NoExecute
# Attempt 3
helm install traefik traefik/traefik --set tolerations[0].key=CriticalAddonsOnly --set tolerations[0].value="\"true\"" --set tolerations[0].operator=Equal --set tolerations[0].effect=NoExecute
# Attempt 4
helm install traefik traefik/traefik --set tolerations[0].key=CriticalAddonsOnly --set tolerations[0].value='"true"' --set tolerations[0].operator=Equal --set tolerations[0].effect=NoExecute最后,他们都用value: true或value: '"true"'创建了一个yaml,两者都不会安装。
发布于 2020-12-19 18:54:54
似乎有两个答案:你正在尝试的非常冗长的答案有一个解决方案,或者一个更简洁的答案,它不会提示将来的读者理解堆栈溢出问题:
Helm提供--set-string,这是--set的无内插版本。
helm install traefik traefik/traefik \
--set tolerations[0].key=CriticalAddonsOnly \
--set-string tolerations[0].value=true \
--set tolerations[0].operator=Equal \
--set tolerations[0].effect=NoExecute但是,正如您所经历的,--set语法仅针对最简单的情况设计,对于更复杂的情况,--values是正确的机制。如果创建临时yaml文件工作量过大,可以从stdin读取它们。
printf 'tolerations: [{key: CriticalAddonsOnly, value: "true", operator: Equal, effect: NoExecute}]\n' | \
helm install traefik traefik/traefik --values /dev/stdinhttps://stackoverflow.com/questions/65372668
复制相似问题