Environment variables

When defining a Pod specification, in addition to the mandatory name and image key, you can specify an env key. The environment key requires a name, and you can add a key that makes a reference using valueFrom: to get data from a ConfigMap.

For example, to expose our example configuration as an environment variable, you could add the following stanza to a Pod specification:

env:  - name: LOG_LEVEL_KEY    valueFrom:      configMapKeyRef:        name: example-config        Key: log.level

You can include multiple environment variables in the Pod specification, and each can reference a different ConfigMap if you have your configuration split up into multiple pieces to make it easier (or more sensible) to administer.

You can also map the entirety ...

Get Kubernetes for Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.