I am currently creating a helm chart for my fullstack application, and I would like to install a nats helm chart to it as a dependency. I know I can add it as a dependency in the Charts.yml file, but how can I provide the nats chart with a Values.yml to overrride the default nats chart values? What I would like is that when I do a helm install for my application, it also installs the nats dependency but with custom values.yml.
chart.yml dependency section
dependencies:
- name: nats
repository: "https://nats-io.github.io/k8s/helm/charts"
version: "0.11.0"
Then I run helm dependency upgrade. This creates a .tgz under my subcharts as follows
I would like to override the default values.yml which are present in the nats chart. I tried by adding the following to the parent values.yml but it did not work (as taken from https://docs.nats.io/running-a-nats-service/introduction/running/nats-kubernetes/helm-charts#clustering)
nats:
cluster:
enabled: true
replicas: 5
tls:
secret:
name: nats-server-tls
ca: "ca.crt"
cert: "tls.crt"
key: "tls.key"
Do I need to unpack the chart for it to work?
CodePudding user response:
This is documented in Helm website
Overriding Values from a Parent Chart
so in your top level chart's values.yaml, use construct like this:
mysubchart: # this is dependent sub-chart
subchart-value-key: .... # this is key in subchart's values.yaml
UPDATE
In your case
nats:
cluster:
enabled: true
replicas: 5
works if I do helm template ., rendered statefullset seems to reflect values correctly:
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: RELEASE-NAME-nats
namespace: "default"
labels:
helm.sh/chart: nats-0.11.0
app.kubernetes.io/name: nats
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/version: "2.6.5"
app.kubernetes.io/managed-by: Helm
spec:
selector:
matchLabels:
app.kubernetes.io/name: nats
app.kubernetes.io/instance: RELEASE-NAME
replicas: 5 # This value has been taken from values.yaml
So what exactly is not working?

