...

/

Converting ConfigMap Output to Environment Variables

Converting ConfigMap Output to Environment Variables

Explore the conversion of ConfigMaps to environment variables.

Altering the perpetual process

All the examples we’ve seen so far differ only in the source. The destination is always the same. Whether ConfigMap is created from a file, a directory, literal values, or an environment file, it perpetually results in one or more files being injected into a container.

This time we’ll try something different. We’ll see how we can convert a ConfigMap to environment variables.

Looking into the first definition

Let’s look at a sample definition of alpine-env.yml file:

Press + to interact
apiVersion: v1
kind: Pod
metadata:
name: alpine-env
spec:
containers:
- name: alpine
image: alpine
command: ["sleep"]
args: ["100000"]
env:
- name: something
valueFrom:
configMapKeyRef:
name: my-config
key: something
- name: weather
valueFrom:
configMapKeyRef:
name: my-config
key: weather

Note: ...

Access this course and 1400+ top-rated courses and projects.