<p>I want to select different resources limits/requests depending on the environment (which is given as input)</p>
<p>This is my Values.yaml file inside my chart</p>
<pre><code>resources:
 dev:
   limits:
     cpu: 100m
     memory: 100Mi
   requests:
     cpu: 20m
     memory: 10Mi
 prod:
   limits:
     cpu: 1000m
     memory: 1000Mi
   requests:
    cpu: 200m
    memory: 100Mi
</code></pre>
<p>I deploy the chart using this command:</p>
<pre><code>helm upgrade --install --values=global_values.yaml
</code></pre>
<p>and inside global_values.yaml:</p>
<pre><code>global:
  environmentSuffix: prod
</code></pre>
<p>What I want to do is selecting the right resources based on <code>environmentSuffix</code> (dev ... prod. 4 environemnts in total)</p>
<p>Something like this (it is not working of course):</p>
<pre><code>resources:
  limits:
    cpu: {{ .Values.resources[.Values.global.environmentSuffix].limits.cpu }}
    memory: {{ .Values.resources[.Values.global.environmentSuffix].limits.memory}}
  requests:
    cpu: {{ .Values.resources[.Values.global.environmentSuffix].requests.cpu }}
    memory: {{ .Values.resources[.Values.global.environmentSuffix].requests.memory}}
</code></pre>
<p>How can I achieve this?</p>

Fabry
<p>You can use <code>index</code> function from <a href="https://golang.org/pkg/text/template/" rel="nofollow noreferrer">Go text/template</a> to store the environment resources in a variable and then access it's values.</p>
<pre><code>{{ $envResources := index .Values.resources .Values.global.environmentSuffix }}
      resources:
        limits:
          cpu: {{ $envResources.limits.cpu }}
</code></pre>
