How to reference a custom value file for sub-charts in helm?

7/14/2019

I have been implementing helm sub-chart by referring helm sub chart documentation. According to the documentation it worked for me. This works fine with default value files. But when I try to refer my own value file, the values are not there in the configmap. My value file is values.staging.yaml.

eg :-

config.yaml in mysubchart

apiVersion: v1
kind: ConfigMap
metadata:
    name: {{ .Release.Name }}-configmap
data:
    salad: {{ .Values.dessert }}

values.staging.yaml in mysubchart

dessert: banana

values.yaml in mysubchart

dessert: cake

Only 'cake' is referenced as the value. I need to reference banana as the value.

I have tried following commands.

  1. helm install --dry-run --debug mychart --values mychart/charts/mysubchart/values.staging.yaml
  2. helm install --dry-run --debug --name mychart mychart -f mychart/charts/mysubchart/values.staging.yaml
  3. helm install --name mychart mychart -f mychart/charts/mysubchart/values.staging.yaml

In each instance the configmap does not refer the value in the values.staging.yaml.

Is there a way to do this?

Thank you .!

-- Tharindu
kubernetes
kubernetes-deployment
kubernetes-helm

1 Answer

7/14/2019

As described in Overriding Values of a Child Chart in your link, you need to wrap the subchart values in a key matching the name of the subchart.

Any values file you pass with helm install -f is always interpreted at the top level, even if it's physically located in a subchart's directory. A typical values file could look like

mysubchart:
  dessert: banana
-- David Maze
Source: StackOverflow