Reputation: 25830
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.
Upvotes: 4
Views: 4111
Reputation: 33203
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
Upvotes: 8