ConfigMap Fundamentals and Use Cases
What you'll learn: What ConfigMaps are, why Kubernetes provides them, and when to use them for application configuration.
What Is a ConfigMap?
A ConfigMap is a Kubernetes resource that stores non-confidential configuration data as key-value pairs. Think of it like a settings file that lives inside your cluster—instead of hardcoding configuration into container images or application code, you externalize it into a ConfigMap.
Imagine you have a coffee shop app that needs different settings for each location: menu prices, store hours, Wi-Fi passwords. Rather than rebuilding your app for each shop, you'd read those settings from a config file. ConfigMaps work the same way for containerized applications.
Why ConfigMaps Exist
Before ConfigMaps, developers had limited options:
- Bake config into images (inflexible, requires rebuilds)
- Use environment variables directly in Pod specs (cluttered, hard to manage)
- Mount external volumes (complex for simple config)
ConfigMaps decouple configuration from Pod definitions, making your applications portable and easier to manage across environments (dev, staging, production).
Common Use Cases
- Application settings: database connection strings, API endpoints, feature flags
- Configuration files: entire config files (nginx.conf, app.properties) consumed by applications
- Environment-specific values: different settings per namespace without changing code
- Command-line arguments: injecting parameters into container commands
ConfigMaps can be consumed by Pods as environment variables or mounted as files in volumes—flexibility you'll explore in upcoming lessons.
When NOT to Use ConfigMaps
ConfigMaps are not encrypted. Never store passwords, API keys, or certificates here—that's what Secrets are for (coming soon in this phase).
Key Takeaway: ConfigMaps externalize non-sensitive application configuration in Kubernetes, enabling environment-agnostic container images and simpler configuration management across your cluster.