kubernetesdeployment.envnats-streaming-server

How to convert an environment variable declared inside a "yaml" file to something inside the ".env" file?


I have an environment variable file that is declared like following inside a deployment.yaml file:

          env:
            - name: NATS_CLIENT_ID
              valueFrom:
                fieldRef:
                  fieldPath: metadata.name

I am just wondering to know if I want to use an .env file instead of the deployment.yaml file, how can I declare the above port within the .env?


Solution

  • Maybe you can create a configmap that contains your .env and use your configmap to inject the environment variables.

    An example here: https://humanitec.com/blog/handling-environment-variables-with-kubernetes