Configuring your Pods using ConfigMaps
In this section, we will learn how to list, create, delete, and read ConfigMaps. Then, we will learn how to attach them to our Pods so that their values are injected into our Pods in the form of environment variables or volumes.
Listing ConfigMaps
Listing the ConfigMaps that were created in your cluster is fairly straightforward and can be accomplished using kubectl
, just like any other object in Kubernetes. You can do this by using the full resource name, which is configmaps
:
$ kubectl get configmaps
Alternatively, you can use the shorter alias, which is cm
:
$ kubectl get cm
These two commands are equivalent. At this point, kubectl may return a few default ConfigMaps or an error message saying that no configmaps were found
. This is because some cloud services create default ConfigMaps for internal operations while others don't – it depends on where your Kubernetes cluster is running.