Kubernetes - ConfigMap
-
ConfigMaps are a Kubernetes resource that allows you to store configuration data in key-value pairs.
-
ConfigMaps allow us to decouple our configurations from our container images, which is important because we don’t want to have to rebuild our images every time we want to change a configuration value.
-
In a Dockerfile we can set environment variables like this:
ENV MY_ENV_VAR=my-valueConfigMap are Insecure
-
ConfigMaps are a great way to manage innocent environment variables in Kubernetes. Things like:
- Ports
- URLs of other services
- Feature flags
- Settings that change between environments, like DEBUG mode
-
However, they are not cryptographically secure. ConfigMaps aren’t encrypted, and anyone RBAC lets read them in that namespace can see them. (Secrets aren’t much better by default: just base64, unless encryption at rest is enabled.)