简体   繁体   中英

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

I have a Helm chart with values.yaml containing:

# Elided
tolerations: []

I'm trying to pass the tolerations via the command line but it always removes the quotes (or adds double quotes inside single quotes) despite all the below attempts. As a result it fails on install saying it expected a string.

# 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

They all end up creating a yaml with value: true or value: '"true"' , neither of which will install.

There appears to be two answers: the exceptionally verbose one that you're trying has a solution, or the more succinct one which doesn't prompt stack overflow questions for future readers to understand:

Helm offers --set-string which is the interpolation-free version of --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

However, as you experienced, that --set syntax is designed for the simplest cases only, for more complex cases --values is the correct mechanism. You can read them from stdin if created a temporary yaml file is too much work

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM