I use the following deployment in common chart:
{{- define "common.deployment" -}}
{{- $common := dict "Values" .Values.common -}}
{{- $noCommon := omit .Values "common" -}}
{{- $overrides := dict "Values" $noCommon -}}
{{- $noValues := omit . "Values" -}}
{{- with merge $noValues $overrides $common -}}
...
{{- if .Values.resources }}
resources:
{{ toYaml .Values.resources | indent 12 }}
...
{{- end -}}
It supposed to merge values of the chart using it, and overwrite if the values exists. So far it works ok, except the case, when common/values.yaml
has :
resources:
requests:
cpu: 20m
memory: 120Mi
And the chart using it values.yaml
has :
resources: {}
So specifying empty object, I expect to remove resources block, but looks like merge don't work that way and still prioritize common values. Why so and how to fix it?
I found that merge function using mergo/merge under the hood and it don't merge empty values. What workaround could be here?