簡體   English   中英

Helm 無法從命令行將雙引號傳遞給 values.yaml?

[英]Helm fails to pass double quotes into values.yaml from the command line?

我有一個帶有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

他們最終都創建了一個 yaml ,其value: truevalue: '"true"'都不會安裝。

似乎有兩個答案:您正在嘗試的異常冗長的答案有一個解決方案,或者更簡潔的一個不會提示堆棧溢出問題以供未來讀者理解:

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 文件工作量太大,您可以從標准輸入讀取它們

printf 'tolerations: [{key: CriticalAddonsOnly, value: "true", operator: Equal, effect: NoExecute}]\n' | \
  helm install traefik traefik/traefik --values /dev/stdin

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM