Home > Back-end >  Referencing secrets in Kubernetes
Referencing secrets in Kubernetes

Time:07-19

What is the difference between env and envFrom fields in kubernetes when referencing secrets? Thank you!

CodePudding user response:

Below is the "env:" sample which will load variables into container environment as environment variables which can referenced using "$DEMO_GREETING" then you will get "Hello from the environment"

    env:
    - name: DEMO_GREETING
      value: "Hello from the environment"
    - name: DEMO_FAREWELL
      value: "Such a sweet sorrow"

Similarly you can load secret as environment variable as below

  envFrom:
  - secretRef:
      name: mysecret

Here the secret will be loaded as environment variable and this can be referenced as $mysecret inside the container.

  • Related