0

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: b64enc

How 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.

1

1 Answer 1

1

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
    
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.