A ConfigMap is a Kubernetes API object that holds configuration as key–value pairs. A value can be a short string or a larger block of text, such as a configuration file. Keeping these values outside the pod manifest lets you reuse the same pod definition in development, staging, and production. section 8.2.1 section 8.2
A pod references a ConfigMap by name and can use selected entries. Multiple pods can share one ConfigMap, and a pod can reference more than one. Applications usually receive the values as environment variables or files rather than reading the Kubernetes API themselves. Small, single-line values suit environment variables; long or multiline values suit files. section 8.2.1 section 9.5.1
Create a ConfigMap
Run `kubectl create configmap kiada-config --from-literal status-message="Ready to start"` to create an entry named `status-message`. For a manifest instead, use `apiVersion: v1`, `kind: ConfigMap`, `metadata.name: kiada-config`, and `data.status-message: Ready to start`, then apply it with `kubectl apply`. You can also create entries from files or an environment file. Inspect the result with `kubectl get cm kiada-config -o yaml`. section 8.2.2
For file-based configuration, define a `configMap` volume in the pod and mount it in a container. Each included entry becomes a file the process can read. A pod can also select particular entries and set their paths. If a required ConfigMap for a volume is missing, none of the pod’s containers can start because volumes must be set up first. section 9.5.1
Listing 9.10 Defining a configMap volume in a pod
apiVersion: v1
kind: Pod
metadata:
name: kiada-ssl
spec:
volumes:
- name: envoy-config #1
configMap: #1
name: kiada-ssl-config #1
...
containers:
...
- name: envoy
image: luksa/kiada-ssl-proxy:0.1
volumeMounts: #2
- name: envoy-config #2
mountPath: /etc/envoy #2
...
The pod manifest connects a named ConfigMap to a volume and mounts that volume at `/etc/envoy` in the container. section 9.5.1
Use a ConfigMap for ordinary configuration, such as a proxy configuration file. Use a Secret for sensitive values such as certificates and private keys. Separating these files from a container image also lets you update them without rebuilding the image. section 9.5 section 8.5







