Thursday, December 3, 2026 | London 10°C · Drizzle
DailyGlimpse

AI

Kubernetes ConfigMaps vs Secrets: Inject Configuration Without Rebuilding Containers

The Automation Stack 1 min read

Hardcoding database URLs and passwords into container images is a recipe for disaster. Any configuration embedded inside an image requires a full rebuild and redeploy to change a single value, and sensitive data like passwords remain exposed in image layers. Kubernetes solves this with two runtime objects that inject configuration without rebuilding—ConfigMaps and Secrets.

A ConfigMap stores non-sensitive configuration such as database URLs, feature flags, or entire config files as plain key-value pairs. A Secret works similarly but holds sensitive values like passwords, API keys, and TLS certificates, keeping them separate from normal config. Both can be consumed as environment variables or mounted as files into Pods, allowing the same container image to run across dev, staging, and production environments by simply swapping the configuration.

A critical caveat: by default, Secrets are only base64-encoded, not encrypted—anyone with access can decode them. Always enable encryption at rest and restrict access using Role-Based Access Control (RBAC).

Bottom line: Use ConfigMaps for non-sensitive configuration and Secrets for sensitive data. Both keep credentials and settings out of the image, enabling flexible, secure configuration management.

React