Kubectl: Get ConfigMap – Kubernetes

In programming, we use .env or separate config files to store settings, configurations or variables separately from the application code.

This permits to run the application in different environments.

A ConfigMap in a Kubernetes is used to achieve the same functionality – it allows to make applications portable by decoupling environment-specific configurations from the containers.

The ConfigMap is a dictionary of configuration settings that consists of key-value pairs.

This note shows how to get the ConfigMap using the kubectl command.

Cool Tip: Create a Deployment in K8s using the kubectl command! Read more →

Kubectl – Get ConfigMap

Get ConfigMaps using the kubectl command:

$ kubectl get configmap
$ kubectl get configmap --namespace <namespace_name>

Describe the ConfigMap:

$ kubectl describe configmap <configmap_name>

Get the ConfigMap in YAML:

$ kubectl get configmap <configmap_name> -o yaml

Get the ConfigMap and save it to a file:

$ kubectl get configmap <configmap_name> -o yaml > my-configmap.yaml

Cool Tip: How to set a default Namespace in a Kubernetes! Read more →

Leave a Reply