Bootstrap FreeKB - OpenShift - List Persistent Volume Claims using the REST API
OpenShift - List Persistent Volume Claims using the REST API

Updated:   |  OpenShift articles

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

Here is how you would list the Persistent Volume Claims using curl.

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/persistentvolumeclaims"

 

Something like this should be returned.

{
    "apiVersion": "v1",
    "items": [
        {
            "metadata": {
                "annotations": {
                    "pv.kubernetes.io/bind-completed": "yes",
                    "pv.kubernetes.io/bound-by-controller": "yes",
                    "volume.beta.kubernetes.io/storage-provisioner": "csi.trident.netapp.io",
                    "volume.kubernetes.io/storage-provisioner": "csi.trident.netapp.io"
                },
                "creationTimestamp": "2023-07-12T13:57:34Z",
                "finalizers": [
                    "kubernetes.io/pvc-protection"
                ],
                "managedFields": [
                    {
                        "apiVersion": "v1",
                        "fieldsType": "FieldsV1",
                        "fieldsV1": {
                            "f:spec": {
                                "f:accessModes": {},
                                "f:resources": {
                                    "f:requests": {
                                        ".": {},
                                        "f:storage": {}
                                    }
                                },
                                "f:storageClassName": {},
                                "f:volumeMode": {}
                            }
                        },
                        "manager": "Mozilla",
                        "operation": "Update",
                        "time": "2023-07-12T13:57:34Z"
                    },
                    {
                        "apiVersion": "v1",
                        "fieldsType": "FieldsV1",
                        "fieldsV1": {
                            "f:metadata": {
                                "f:annotations": {
                                    ".": {},
                                    "f:pv.kubernetes.io/bind-completed": {},
                                    "f:pv.kubernetes.io/bound-by-controller": {},
                                    "f:volume.beta.kubernetes.io/storage-provisioner": {},
                                    "f:volume.kubernetes.io/storage-provisioner": {}
                                }
                            },
                            "f:spec": {
                                "f:volumeName": {}
                            }
                        },
                        "manager": "kube-controller-manager",
                        "operation": "Update",
                        "time": "2023-07-12T13:57:36Z"
                    },
                    {
                        "apiVersion": "v1",
                        "fieldsType": "FieldsV1",
                        "fieldsV1": {
                            "f:status": {
                                "f:accessModes": {},
                                "f:capacity": {
                                    ".": {},
                                    "f:storage": {}
                                },
                                "f:phase": {}
                            }
                        },
                        "manager": "kube-controller-manager",
                        "operation": "Update",
                        "subresource": "status",
                        "time": "2023-07-12T13:57:36Z"
                    }
                ],
                "name": "foo",
                "namespace": "default",
                "resourceVersion": "2983410",
                "uid": "c81aa888-2a1d-43e6-b0a3-a387dc225fe8"
            },
            "spec": {
                "accessModes": [
                    "ReadWriteOnce"
                ],
                "resources": {
                    "requests": {
                        "storage": "1Gi"
                    }
                },
                "storageClassName": "file-storage",
                "volumeMode": "Filesystem",
                "volumeName": "pvc-c81aa888-2a1d-43e6-b0a3-a387dc225fe8"
            },
            "status": {
                "accessModes": [
                    "ReadWriteOnce"
                ],
                "capacity": {
                    "storage": "1Gi"
                },
                "phase": "Bound"
            }
        }
    }
}

 




Did you find this article helpful?

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



Comments


Add a Comment


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