I have a Pod configuration file very similar to this example in the docs where I set a few env variables from a configMap file.
Now I need to add another variable but I need to base64 encode it. I can easily do it when I take data from values by applying the b64enc function, but I don't know how to do it when getting the value from a configMap
This is what I can do
env:
- name: PLAIN_VALUE
valueFrom:
configMapKeyRef:
name: myconfig
key: PLAIN_VALUE
- name: ENCODED_VALUE_FROM_VALUES
value: {{ .Values.myConfig.plainValue | b64enc | quote }}I would like to do something like the following
env:
- name: ENCODED_VALUE
valueFrom:
configMapKeyRef:
name: myconfig
key: PLAIN_VALUE
transformation: b64encHow can I b64enc the valueFrom: configMapKeyRef: myconfig/PLAIN_VALUE?
P.S. configMapRef would also work, I can make a separate config file for that value.
In this scenario you should use secrets. It encodes the values in base64.
You can easily create a secret using kubectl command, for example:
kubectl create secret generic test-secret --from-literal='your_value'And it works similarly to configmap when it comes to passing encoded values to pods.
env:
- name: ENCODED_VALUE
valueFrom:
secretKeyRef:
name: myconfig
key: value