OpenShift - List Config Maps using REST API

This assumes you have used the curl REST API to obtain an OAuth bearer token. Let's say the bearer token is sha256~0Rs__hPuXmBD3TJTXNDisC7wRBN-nrFnYTxgdBrFT-U.

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.

For example, a config map named log-level could contain the variable log_level: INFO, and then one or more pods could use the log-level config map to set their log level to INFO.

 

Here is how you would list the config maps in the openshift-kube-apiserver-operator namespace using the curl REST API. The oc config view or oc get apiserver commands can be used to display the API Server URL (api.openshift.example.com in this example).

curl
--insecure
--request GET
--header "Accept: application/json"
--header "Authorization: Bearer sha256~0Rs__hPuXmBD3TJTXNDisC7wRBN-nrFnYTxgdBrFT-U"
--url "https://api.openshift.example.com:6443/api/v1/namespaces/openshift-kube-apiserver-operator/configmaps"

 

If something like this is returned, this means that there are no config maps in the namespace.

{
  "kind": "ConfigMapList",
  "apiVersion": "v1",
  "metadata": {
    "selfLink": "/api/v1/namespaces/openshift-kube-apiserver-operator/configmaps",
    "resourceVersion": "96466432"
  },
  "items": []
}

 

On the other hand, if the items array contains key value pairs, this means the namespace contains one or more config maps.

{
  "kind": "ConfigMapList",
  "apiVersion": "v1",
  "metadata": {
    "selfLink": "/api/v1/namespaces/openshift-kube-apiserver-operator/configmaps",
    "resourceVersion": "96464581"
  },
  "items": [
    {
      "metadata": {
        "name": "kube-apiserver-to-kubelet-client-ca",
        "namespace": "openshift-kube-apiserver-operator",
        "selfLink": "/api/v1/namespaces/openshift-kube-apiserver-operator/configmaps/kube-apiserver-to-kubelet-client-ca",
        "uid": "9103397e-9e0c-44f6-bcb4-852cbbc07ed8"

 

Or to return a specific config map, such as kube-control-plane-signer-ca.

curl
--insecure
--request GET
--header "Accept: application/json"
--header "Authorization: Bearer sha256~0Rs__hPuXmBD3TJTXNDisC7wRBN-nrFnYTxgdBrFT-U"
--url "https://api.openshift.example.com:6443/api/v1/namespaces/openshift-kube-apiserver-operator/configmaps/kube-control-plane-signer-ca"

 




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 27e19 in the box below so that we can be sure you are a human.




Comments

Web design by yours truely - me, myself, and I   |   jeremy.canfield@freekb.net   |