generate dynamic secret name inside kubernetes deployment file

4/28/2020

I have 2 secrets i.e. production and staging. I want to dynamically load this secret in deployment file using the environment variable being set in same file

env:
          - name: NODE_ENV
            value: "production"


 - name: general-secret
          secret:
            secretName: general-production-secret    

I want to load environment specific secrets like using

        secretName: general-{{env. NODE_ENV}}-secret    

Is it possible?

-- Hacker
kubernetes
kubernetes-secrets

1 Answer

4/28/2020

As far as I know, this is not possible unless you have Helm chart for your applications, then you can make this possible

this is a solution in helm chart close to what you need Dynamically accessing values depending on variable values in a Helm chart

-- Hamed
Source: StackOverflow