<p>I have a Pod configuration file very similar to <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/#use-configmap-defined-environment-variables-in-pod-commands" rel="nofollow noreferrer">this example in the docs</a> where I set a few env variables from a configMap file.<br />
Now I need to add another variable but I need to <code>base64</code> encode it. I can easily do it when I take data from <code>values</code> by applying the <code>b64enc</code> function, but I don't know how to do it when getting the value from a <code>configMap</code></p>
<p>This is what I can do</p>
<pre><code>env:
  - name: PLAIN_VALUE
    valueFrom:
      configMapKeyRef:
        name: myconfig
        key: PLAIN_VALUE
  - name: ENCODED_VALUE_FROM_VALUES
    value: {{ .Values.myConfig.plainValue | b64enc | quote }}
</code></pre>
<p>I would like to do something like the following</p>
<pre><code>env:
  - name: ENCODED_VALUE
    valueFrom:
      configMapKeyRef:
        name: myconfig
        key: PLAIN_VALUE
        transformation: b64enc
</code></pre>
<p>How  can I <code>b64enc</code> the <code>valueFrom: configMapKeyRef: myconfig/PLAIN_VALUE</code>?<br />
P.S. <code>configMapRef</code> would also work, I can make a separate config file for that value.</p>

Naigel
<p>In this scenario you should use secrets. It encodes the values in <code>base64</code>.</p>
<p>You can easily create a secret using <a href="https://kubernetes.io/docs/tasks/inject-data-application/distribute-credentials-secure/#create-a-secret-directly-with-kubectl" rel="nofollow noreferrer">kubectl command</a>, for example:</p>
<pre><code>kubectl create secret generic test-secret --from-literal='your_value'
</code></pre>
<p>And it works similarly to configmap when it comes to <a href="https://kubernetes.io/docs/tasks/inject-data-application/distribute-credentials-secure/#define-container-environment-variables-using-secret-data" rel="nofollow noreferrer">passing encoded values to pods</a>.</p>
<pre><code>env:
  - name: ENCODED_VALUE
    valueFrom:
      secretKeyRef:
        name: myconfig
        key: value
    
</code></pre>
