0

First of all, I have read the documentation and i see this text, which is pretty self explanatory, To use a secret, a pod needs to reference the secret. But I want to see if its possible to get all secrets from a secret definition without defining each one of them in a pod, what i mean is this.

This is what I have

        env:
            - name: MY_FRST_SECRET
              valueFrom:
                secretKeyRef:
                  name: secret
                  key: MY_FRST_SECRET
            - name: MY_SECOND_SECRET
              valueFrom:
                secretKeyRef:
                  name: secret
                  key: MY_SECOND_SECRET

This is what I want

        env:
            - name: *
              valueFrom:
                secretKeyRef:
                  name: secret
                  key: *

I know this seems silly, but what i mean is that i want to see if there is a way to grab all the variables inside the secret, and import them with the same name as the variable is defined. so it will be

VarName = SecretName
VarValue = SecretValue

Thanks in Advance!

1

I turns out i can achieve this but with config maps, here is the documentation link on how to do it https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/#configure-all-key-value-pairs-in-a-configmap-as-container-environment-variables

if the URL changes in the future, here is the code for reference

apiVersion: v1
   kind: Pod
   metadata:
     name: dapi-test-pod
   spec:
     containers:
       - name: test-container
         image: k8s.gcr.io/busybox
         command: [ "/bin/sh", "-c", "env" ]
         envFrom:
         - configMapRef:
             name: special-config
     restartPolicy: Never

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.