<p>I am using helm 3, and would like to concatenate 3 secretRefKeys into a single value of Env Var.</p>
<p>This is my cronjob.yaml file:</p>
<pre><code>apiVersion: batch/v1
kind: CronJob 
metadata:
  name: my-cronjob
spec:
  schedule: {{ .Values.cron }}
  jobTemplate:
    spec:
      template:
        spec:
          initContainers:
                - name: PREFIX
                  valueFrom:
                    secretKeyRef:
                      name: {{ .Values.secretName }}
                      key: prefix
                - name: ENV
                  valueFrom:
                    secretKeyRef:
                      name: {{ .Values.secretName }}
                      key: env
                - name: SUFFIX
                  valueFrom:
                    secretKeyRef:
                      name: {{ .Values.secretName }}
                      key: suffix
                - name: URL_FULL
                  value: $(PREFIX)$(ENV)$(SUFFIX)
          containers:
           .
           .
           .
           .
           .
</code></pre>
<p>I expect the value of <code>URL_FULL</code> to be the actual values of <code>prefix</code> <code>env</code> <code>suffix</code> concatenated.</p>
<p>But what I get with <code>helm template</code> command is literally what I write in the value:</p>
<pre><code>            - name: URL_FULL
              value: $(PREFIX)$(ENV)$(SUFFIX)
</code></pre>
<p>Thanks in advance.</p>

jrz
<p><code>helm template</code> is not going to resolve those environment variables, it is just going to render the template, as the documentation states.</p>
<p>You will need to deploy the chart. I've made a simple example:</p>
<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: nginx
  labels:
    app: nginx
spec:

  volumes:
    - name: shared-volume
      emptyDir: {}
  initContainers:
    - name: busybox
      image: busybox
      volumeMounts:
        - name: shared-volume
          mountPath: /nginx-data
      command: [&quot;/bin/sh&quot;]
      # sleep so that we could exec into it
      args: [&quot;-c&quot;, &quot;sleep 6000&quot;]

      env:
        - name: PROP_ONE
          valueFrom:
            secretKeyRef:
              key: one
              name: secret-sample
        - name: PROP_TWO
          valueFrom:
            secretKeyRef:
              key: two
              name: secret-sample
        - name: PROP_THREE
          value: $(PROP_ONE)
  containers:
    - name: nginx
      image: nginx
      volumeMounts:
        - name: shared-volume
          mountPath: /usr/share/nginx/html
</code></pre>
<p>You can then issue :</p>
<pre><code>helm install foo  .
</code></pre>
<p>Then issue a <code>helm ls</code> to see that it's there in the cluster.</p>
<p>Even if you now do a :</p>
<pre><code>kubectl describe pod nginx | grep PROP_THREE
</code></pre>
<p>you will see that the reference is:</p>
<pre><code>PROP_THREE:  $(PROP_ONE)
</code></pre>
<p>If you really want to see that env variable, you will have to exec into the container (I do not know of another way):</p>
<pre><code>kubectl exec -it nginx -c busybox -- /bin/sh
</code></pre>
<p>And then:</p>
<pre><code>   env | grep PROP_THREE
   PROP_THREE=bar
</code></pre>
<p>to see that it is resolved correctly.</p>
