kubernetes

Kubernetes -env and -envFrom environment variables setting


Can Kubernetes deployment manifest file have both -env and -envFrom keys?

I have set a secrets.yaml file to set the environment variables and also have environment variables that are hard coded.

Can I have both of them set using both -env and -envFrom in the YAML files?


Solution

  • Can kubernetes deployment manifest file have both -env and -envFrom keys?

    Yes.

    ...
    envFrom:
    - secretRef:
        name: <name of your secret>
    env:
    - name: <variable name>
      value: <hardcoded value>
    
    - name: <variable name>
      valueFrom:
        secretKeyRef:
          name: <name of your secret>
          key: <If I only want this and not all the keys in the secret>