Helm: How to override helm value that is an array/dict

Viewed 1035

Is it possible to redefine an array in helm values.yaml?

In the values.yaml I have among other top level values one of like this:

attribute:
  component1:
    type: Type1
  component2:
    type: Type2

In the templates it is used this way:

{{- $key := "component1" }}
{{- if .Values.attribute }}
  {{- $profile := .Values.attribute }}
  {{- if hasKey .Values.attribute $key }}
    {{- $profile = index .Values.attribute $key }}
  {{- end -}}
  {{ if $profile.type }}
    ...

I would like to achive by helm template --set (or any other means) that I set the "type" on the common level and remove all of the component level ones together with the components themselves. So the rest of the values should remain the same, but the result regarding the "attribute" should be:

attribute:
  type: MyType

I've tried:

helm template --set attribute.type=MyType

But this would just add this new element to the "attribute" array beside the components.

helm templates --set "attribute={type: MyType}"

But this fails as the attribute is now a list instead of the expected map[string].

1 Answers

I need to update than data in running release:

 resources:
    limits:
        cpu: 200m
        memory: 450Mi
    requests:
        cpu: 50m
        memory: 300Mi

And next command worsk for me:

linux@0:~$ helm -n testns upgrade test-release repo/testchart --version 0.2.4 --set resources.limits.cpu=200m --set resources.limits.memory=750Mi --set resources.requests.cpu=50m --set resources.requests.memory=700Mi --reuse-values --debug

Related