<p>I have two helm charts, the second one is nested to the first
tree output:</p>
<pre><code>.
└── outerChart
    ├── charts
    │   └── innerChart
    │       ├── charts
    │       ├── Chart.yaml
    │       ├── templates
    │       │   ├── deployment.yaml
    │       │   ├── _helpers.tpl
    │       │   ├── ingress.yaml
    │       │   ├── NOTES.txt
    │       │   ├── serviceaccount.yaml
    │       │   └── service.yaml
    │       └── values.yaml
    ├── Chart.yaml
    ├── templates
    └── values.yaml
</code></pre>
<p>I have a global variable in the outer <code>values.yaml</code>:</p>
<pre><code>global:
 myreplicacount: 4
</code></pre>
<p>In the nested chart there is a values file with</p>
<pre><code>replicaCount: 1
</code></pre>
<p>and a deployment that uses it:</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ include &quot;foo.fullname&quot; . }}
  labels:
{{ include &quot;foo.labels&quot; . | indent 4 }}
spec:
  replicas: {{ .Values.replicaCount }}
</code></pre>
<p>The straight forward way in order to use the global var is to replace:</p>
<pre><code>replicas: {{ .Values.replicaCount }}
</code></pre>
<p>with:</p>
<pre><code>replicas: {{ .Values.global.myreplicacount }}
</code></pre>
<p>in the <code>deployment.yaml</code>.</p>
<p>But it possible to use that in the nested <code>values.yaml</code>? I would like to keep the inner chart intact. I am stuck in a situation where one software team provides me the inner chart and another one provides needed configuration through global variables. <code>replicaCount</code> is just an example, they have many variables that need to change and if I edit the inner chart that will make inner chart updates difficult.</p>
<p>Just adding:</p>
<pre><code>replicaCount: {{ .Values.global.myreplicacount }}
</code></pre>
<p>in outerChart/charts/innerChart/values.yaml
returns</p>
<pre><code>): error converting YAML to JSON: yaml: invalid map key: map[interface {}]interface {}{&quot;.Values.global.myreplicacount&quot;:interface {}(nil)}
</code></pre>

sotiris
<p>Inside the nested chart, <code>.Values</code> is seen as the contents of <code>.Values.nested</code> (using whatever name for the dependency is in <code>requirements.yaml</code> or <code>Chart.yaml</code>), merged with the top-level <code>global:</code> key.</p>
<pre class="lang-yaml prettyprint-override"><code># requirements.yaml
- name: nested   # &lt;-- this name will be used in values.yaml
  version: &quot;^1&quot;
  repository: ...
</code></pre>
<p>You can provide specific settings for that dependency using its name as a key in <code>values.yaml</code>.  This doesn't require <code>global:</code> or any changes to the dependency chart.</p>
<pre class="lang-yaml prettyprint-override"><code># outer chart values.yaml, or `helm install -f` YAML file
nested:          # &lt;-- matches name: in requirements.yaml above
  replicaCount: 1
</code></pre>
<p>For a Deployment replica count in particular, I'd prefer this option over possible alternatives.  It's likely that each Deployment and StatefulSet will need a different replica count, especially across multiple charts, and it doesn't make sense to globally say &quot;absolutely everything will have exactly 4 replicas&quot;.</p>
<p>If you can edit the nested chart, and you want it to optionally accept a <code>global:</code> value, you could honor that if a local value isn't set</p>
<pre class="lang-yaml prettyprint-override"><code># charts/nested/deployment.yaml
replicas: {{ .Values.replicaCount | default .Values.global.replicaCount | default 1 }}
</code></pre>
