Understanding ConfigMaps in Kubernetes
What is ConfigMap?
ConfigMaps allow you to decouple configuration artifacts from image content to keep containerized applications portable. This article demonstrates how to create ConfigMaps.
Prerequisite:
Kubernetes clusters must be configured on the system, and the kubectl command must be configured to communicate with your cluster.
Create a ConfigMap using configuration file:
Create a local directory:
mkdir configmaps && cd $_
Create a configuration file:
vim configMap.yaml
Get the configMap.yaml file content from here.
The following table includes short description all the keys present in the YAML file.
Deploy the ConfigMap from the above YAML file:
kubectl apply -f configMap.yaml
To get all the configMaps:
kubectl get configmap
The above command will show an entry with NAME as kubenotes.
To get the details of the ConfigMap we created:
kubectl describe configmap kubenotes
‘describe’ operation shows the detailed state of one or more resources. Also, we can use cm instead of configmap.
For example:
kubectl describe cm kubenotes
That’s all folks! To understand how we can use configMaps as Environment Variables, please go through this article.