April 2018
Intermediate to advanced
468 pages
14h 34m
English
When you are creating a pod, you can specify a ConfigMap and consume its values in several ways. Here is how to consume our configuration map as an environment variable:
apiVersion: v1
kind: Pod
metadata:
name: some-pod
spec:
containers:
- name: some-container
image: busybox
command: [ "/bin/sh", "-c", "env" ]
env:
- name: DB_IP_ADDRESSES
valueFrom:
configMapKeyRef:
name: db-config
key: db-ip-addresses
restartPolicy: Never
This pod runs the busybox minimal container and executes an env bash command and immediately exists. The db-ip-addresses key from the db-config map is mapped to the DB_IP_ADDRESSES environment variable, and is reflected in the output:
> kubectl logs some-pod HUE_REMINDERS_SERVICE_PORT=80 ...
Read now
Unlock full access