ConfigMaps
Let me store your KV data
Template
danger
Instead of a .spec section. ConfigMaps have a .data section in yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: ${RESOURCE_NAME}
labels:
name: ${RESOURCE_NAME}
data:
key: value
coffee: "yes"
---
# Load just one field as an ENV var:
# env:
# - name: SPECIAL_LEVEL_KEY
# valueFrom:
# configMapKeyRef:
# name: special-config
# key: special.how
# Load the entire configmap as ENV vars:
# envFrom:
# - configMapRef:
# name: app-config
Quickly create configmaps
kubectl create configmap {name} --from-literal=key=value --from-literal=key2=value2
# Create from properties file, but watch out for data.file_name!
kubectl craete configmap {name} --from-file=app_config.properties
# Create from env file
kubectl create configmap {name} --from-env-file=.env
# Create an env file from envchain
env -i /opt/homebrew/bin/envchain k8shard env
Using ConfigMaps
Load the entire configmap as ENV vars
envFrom:
- configMapRef:
name: app-config
Load just one field as an ENV var
env:
- name: SPECIAL_LEVEL_KEY
valueFrom:
configMapKeyRef:
name: special-config
key: special.how