<p>I have the following deployment definition:</p>
<pre><code>...
containers:
        - name: {{ .Release.Name }}
          image: &quot;{{ .Values.image.repository }}:{{ .Values.image.tag }}&quot;
          imagePullPolicy: {{ .Values.image.pullPolicy }}
          {{ if .Values.env.enabled }}
          env:
          {{- range .Values.env.vars }}
             ?????What comes here?????
          {{- end }}
          {{ end }}
          ports:
            - name: http
              containerPort: 8080
              protocol: TCP
          livenessProbe:
            httpGet:
              path: /
              port: http
          readinessProbe:
            httpGet:
              path: /
              port: http
          resources:
            {{- toYaml .Values.resources | nindent 12 }}
...
</code></pre>
<p>in the <code>values.yaml</code>, I have defined:</p>
<pre><code>env:
  enabled: false
  vars: [] 
</code></pre>
<p>What I would like to do is, to set environment dynamically via <code>--set</code>, for instance:</p>
<pre><code>helm template user-svc \
  --set image.tag=0.1.0 \
  --set image.repository=user-svc \
  --set env.enabled=true \
  --set env.vars.POSTGRES_URL=&quot;jdbc:postgresql://localhost:5432/users&quot; \
  --set env.vars.POSTGRES_USER=&quot;dbuser&quot; \
  ./svc
</code></pre>
<p>after rendering, it should show:</p>
<pre><code>...
containers:
- name: demo
  image: game.example/demo-game
  env:
    - name: POSTGRES_URL
      value: jdbc:postgresql://localhost:5432/users
...
</code></pre>
<p>and how to set the following option via <code>--set</code>:</p>
<pre><code>- name: UI_PROPERTIES_FILE_NAME
  valueFrom:
    configMapKeyRef:
      name: game-demo
      key: ui_properties_file_name 
</code></pre>

softshipper
<p>You can access the --set option using .Values.</p>
<pre><code>{{- if eq .Values.env.enabled &quot;true&quot; -}}
 env:
   - name: {{ .Values.env.vars.POSTGRES_USER }}
     value: {{ .Values.env.vars.env.vars.POSTGRES_URL}}
{{- end }}
</code></pre>
<p>Try the above.</p>
