首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Helm未能将双引号从命令行传递到values.yaml?

Helm未能将双引号从命令行传递到values.yaml?
EN

Stack Overflow用户
提问于 2020-12-19 17:39:05
回答 1查看 2K关注 0票数 2

我有一个包含values.yaml的Helm图表,包含:

代码语言:javascript
复制
# Elided
tolerations: []

我试图通过命令行传递公差,但它总是删除引号(或者在单引号中添加双引号),尽管有以下所有尝试。因此,在安装时失败了,说它需要一个字符串。

代码语言:javascript
复制
# 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: truevalue: '"true"'创建了一个yaml,两者都不会安装。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-12-19 18:54:54

似乎有两个答案:你正在尝试的非常冗长的答案有一个解决方案,或者一个更简洁的答案,它不会提示将来的读者理解堆栈溢出问题:

Helm提供--set-string,这是--set的无内插版本。

代码语言:javascript
复制
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读取它们。

代码语言:javascript
复制
printf 'tolerations: [{key: CriticalAddonsOnly, value: "true", operator: Equal, effect: NoExecute}]\n' | \
  helm install traefik traefik/traefik --values /dev/stdin
票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65372668

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档