A ConfigMap is an API object used to store non-confidential data in key-value pairs. Pods can consume ConfigMaps as environment variables, command-line arguments, or as configuration files in a volume.

A ConfigMap allows you to decouple environment-specific configuration from your container images so that your applications are easily portable. The size of the individual configmap is limited to 1mb, according to

Creating config map using command

kubectl create cm cm1 --from-literal=database_ip="x.x.x.x"

we can describe the config map using

kubectl describe cm cm1

we also can pass multiple values for the command as well

kubectl create cm cm1 --from-literal=database_ip="x.x.x.x" --from-literal=user="user1" --from-literal=paaword="xxxxx"

Creating config map using yaml file

mkdir configmap
kubectl create cm cm3
kubectl describe cm cm3

Note - Here we can see the values in key value format

We also can we can specify multiple config files for one config map, and it will add two data into a single config map

Let's create one more file


now, we can use the below command to create one config map with multiple application properties file values, for this example, we are using the above two file

kubectl create cm cm4

what if we have multiple, like 40 file into one single folder. Then in that case we can use below command to create config map using multiple files

kubectl create cm cm5 --from-file=foldername/

in the above example we have a specified folder of in which we have multiple file. So now the newly created cm5 config map will have all the config values which are presented in the folder