Skip to content
Related Articles
Open in App
Not now

Related Articles

Kubernetes – ConfigMap

Improve Article
Save Article
  • Last Updated : 12 Dec, 2022
Improve Article
Save Article

Pre-requisite:- Kubernetes

An open-source container orchestration system called Kubernetes is primarily used for automated software deployment, scaling, and management. Another name for Kubernetes is K8s. Originally developed by Google, Kubernetes is now managed by the Cloud Native Computing Foundation. Although it now supports both containers and CRI-O alongside the Docker runtime, it was originally intended to interact. Automating container-managed operational tasks is the primary goal of Kubernetes. There are built-in commands for deploying the application and rolling out the desired changes to the application. It is currently used by companies such as Google, Spotify, and Capital One.


In Kubernetes, Configmap is an API object which is mainly used to store non-confidential data. The data that is stored in ConfigMap is stored as key-value pairs. ConfigMaps are configuration files that may be used by pods as command-line arguments, environment variables, or even as configuration files on a disc. This feature allows us to decouple environment-specific configuration from our container images, after this is done our applications are easily portable. The thing to be noted here is that ConfigMap does not provide any sort of secrecy or encryption, so it is advised to store non-confidential data only we can use secrets to store confidential data. 

A ConfigMap may be used to set configuration data independently of the application code. Imagine that we are developing an application that you can run on your own computer and in the cloud. We create the code to check the DATABASE HOST environment variable. We can set the variable to localhost locally but in the cloud, we set it to a Kubernetes Service. A configMap is not designed to store large data in it. The data that is stored in ConfigMap can not be more than 1MiB. If we need to store more data than that then we can use volume instead of ConfigMaps.

ConfigMap Object

We know that Config map is an API object which is mainly used to store non-confidential data or configuration for other objects to use. Most of the Kubernetes objects have spec but ConfigMap has data and binaryData fields. Key value pair is accepted by these fields as values. The Data field is used to store UTF-8 strings while the binary data field is used to store binary data as base64-encoded strings. A valid DNS subdomain name should be given to ConfigMap. The key value that is recorded in the data field and the key value in the binaryData field cannot both be the same.

configmap object


Working of  ConfigMap

Without being available to Pods this way directly, it may be used by other components of the system. Data that is utilized for configuration by other system components may be stored in COnfigMap. ConfigMaps are most commonly used to config settings for containers running in a Pod present in the same namespace. We can even use ConfigMap separately. 

Uses of ConfigMap

  1. It can be used to consume ConfigMap in various environment variables.
  2. It set command line arguments with configMap.
  3. It consumes ConfigMap via the volume plugin.
  4. It is used to project keys to specific paths and file permissions. 


My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!