Reputation: 119
I am using helm environment variables to override some of my spring boot application.yaml config and its working perfectly fine.
helm install deploy-name-1 mychartname --values=.helm/deployment/values.yaml
values.yaml
env:
- name: WORD
value: hello
On executing helm install command, I can see the right WORD being picked up during helm deployment that's all good.
However I would like to override the value of this environment variable "WORD" through helm install command on CLI. On trying I am facing the following error...
Command (taking from here):
helm install deployment2 mychartname --values=.helm/deployment/values.yaml --set env.WORD=tree
Error
panic: interface conversion: interface {} is []interface {}, not map[string]interface {}
goroutine 1 [running]:
helm.sh/helm/v3/pkg/strvals.(*parser).key(0xc0004eff60, 0xc000538840, 0x1592d34, 0x1838b20)
/home/circleci/helm.sh/helm/pkg/strvals/parser.go:211 +0xdf1
helm.sh/helm/v3/pkg/strvals.(*parser).parse(0xc0004eff60, 0xc000538840, 0x0)
/home/circleci/helm.sh/helm/pkg/strvals/parser.go:133 +0x3f
helm.sh/helm/v3/pkg/strvals.ParseInto(0xc0000b60c0, 0x23, 0xc000538840, 0x0, 0x0)
/home/circleci/helm.sh/helm/pkg/strvals/parser.go:70 +0xc5
helm.sh/helm/v3/pkg/cli/values.(*Options).MergeValues(0xc000080c60, 0xc0004efb40, 0x1, 0x1, 0x0, 0x0, 0x0)
/home/circleci/helm.sh/helm/pkg/cli/values/options.go:62 +0x232
main.newUpgradeCmd.func1(0xc0001e0500, 0xc0004ffd80, 0x2, 0x8, 0x0, 0x0)
/home/circleci/helm.sh/helm/cmd/helm/upgrade.go:82 +0x1fe
github.com/spf13/cobra.(*Command).execute(0xc0001e0500, 0xc0004ffc80, 0x8, 0x8, 0xc0001e0500, 0xc0004ffc80)
/go/pkg/mod/github.com/spf13/[email protected]/command.go:826 +0x467
github.com/spf13/cobra.(*Command).ExecuteC(0xc00069d180, 0x1c2f380, 0xc000676160, 0xc0004586d0)
/go/pkg/mod/github.com/spf13/[email protected]/command.go:914 +0x302
github.com/spf13/cobra.(*Command).Execute(...)
/go/pkg/mod/github.com/spf13/[email protected]/command.go:864
main.main()
/home/circleci/helm.sh/helm/cmd/helm/helm.go:74 +0x1e9
deployment.yaml
...
spec:
containers:
- name: {{ .Release.Name }}
env:
{{- range .Values.env }}
- name: {{ .name }}
value: {{ .value }}
{{ end }}
Upvotes: 4
Views: 17149
Reputation: 158917
The helm install --set
option allows only basic path-based navigation and no more advanced query operations. You can't look for the env:
value with name: WORD
and set the corresponding value:
; all you can do is blindly set the first env:
value.
helm install ... --set 'env[0].value=tree'
Rather than provide whole chunks of Kubernetes YAML through Helm values, it's more common to provide very specific settings; provide "the word" as configuration, rather than "a set of environment variables, which should include WORD
". Then you can straightforwardly override this specific thing.
# templates/deployment.yaml
env:
- name: WORD
value: {{ .Values.word }}
# values.yaml
word: hello
helm install ... --set word=tree
Upvotes: 8