Short-hand syntax for fetching multiple keys from secret map in kubernetes yaml config

12/26/2019

In my kubernetes deployment config, I want to fetch two environment variables from a secret map called "my-environment-config". Currently the way I do that is as follows:

    env:
      - name: INFLUXDB_DATA_ENGINE
        valueFrom:
          secretKeyRef:
            name: my-environment-config
            key: INFLUXDB_DATA_ENGINE
      - name: INFLUXDB_DATA_QUERY_LOG_ENABLED
        valueFrom:
          secretKeyRef:
            name: my-environment-config
            key: INFLUXDB_DATA_QUERY_LOG_ENABLED

This syntax seems to me to be overly verbose. Is there no shorthand for specifying this more elegantly?

PS: It is important to note that I don't want to expose ALL the secrets of my-environment-config, just a select few.

-- Lennart Rolland
google-kubernetes-engine
kubernetes-secrets
yaml

0 Answers