OpenShift - List Config Maps using the oc get configmaps command

If you are not familiar with the oc command, refer to OpenShift - Getting Started with the oc command.

There are different ways to configure a container with environment variables.

A config map contains files, variables, and command line options that can be used by one or more applications, as a way to create separation between applications and the files, variables, and command line options being used by the applications.

Or, a secret can be used, so that the data is encoded (not encrypted).

For example, a config map could contain the variable foo=Hello or a secret could contain foo=V29ybGQ= (which is Hello base 64 encoded), and then one or more pods could use the config map or secret to return Hello from the foo key.


The oc get configmaps command will display the config maps in the currently selected project / namespace.


The -A or --all-namespaces flag can be used to list the config maps in every project / namespace.

The -n or --namespace flag can be used to list the config maps in a certain project / namespace.

~]$ oc get configmaps
NAME             DATA      AGE
my-config-map    1         44d


The oc describe configmap command can be used to show the files, variables, and command line options that are defined in the config map.

~]$ oc describe configmap my-config-map
Name:         my-config-map
Namespace:    default
Labels:       <none>
Annotations:  <none>

Events:  <none>


Or, the oc get configmap command with the --output json‚Äč or --output yaml option can be used.

~]$ oc get configmap my-config-map --output yaml
apiVersion: v1
  foo: hello
  bar: world
kind: ConfigMap
  creationTimestamp: "2021-10-20T10:25:10Z"
  - apiVersion: v1
    fieldsType: FieldsV1
        .: {}
        f:key1: {}
        f:key2: {}
    manager: kubectl-create
    operation: Update
    time: "2021-10-20T10:25:10Z"
  name: my-config-map
  namespace: default
  resourceVersion: "104538499"
  selfLink: /api/v1/namespaces/default/configmaps/my-config-map
  uid: 75469a11-949a-4b0d-90f6-adda92cdad49


The --output jsonpath option can be used to print the value of a specific JSON key.

~]$ oc get configmap my-config-map --output jsonpath={}


Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee

Add a Comment

We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.

Please enter 698e2 in the box below so that we can be sure you are a human.


Web design by yours truely - me, myself, and I   |   |