ConfigMap & Secrets
The Kubernetes ConfigMap is a Kubernetes API resource that lets you store non-confidential configuration data for your applications. It allows you to decouple configuration from your application code, allowing you to change configuration settings without having to edit and relaunch your program.
ConfigMaps stores data in a key-value format, making it an excellent choice for environmental setups, endpoint URLs, and various application configuration parameters.
When a ConfigMap is utilized, files mounted directly into the container or environment variables can be used by the program to access the stored configurations.
Secret
A Kubernetes Secret is an object that stores and manages sensitive information like passwords, API keys, tokens, or any other secret data. Secrets, like ConfigMaps, enable you to segregate sensitive information from your application code.
Conversely, secrets are built explicitly for storing secret data and offer additional security safeguards.
Similar to ConfigMaps, secrets are key-value pairs with base64 encoding added for an extra degree of protection.
Applications retrieve sensitive data through file mounts or environment variables when accessing Secrets, just like they do with ConfigMaps.
What are the differences between ConfigMaps and Secrets?
ConfigMaps are typically used for non-sensitive configuration data, while Secrets are used for storing sensitive information.
ConfigMaps stores data as key-value pairs, whereas Secrets stores data as base64-encoded data, thereby ensuring an additional layer of security.
ConfigMaps are typically used to store configuration data, such as environment variables, while Secrets store sensitive data, such as passwords and API key.
Working with ConfigMaps
Create ConfigMap
Using environment variables with ConfigMaps
Mounting ConfigMaps as volumes
Managing Secrets
Create Secret
Using Secrets as environment variables
Mounting Secrets as volumes
Sample Deployment File with CM and Secrets
Last updated