OpenShift - List Cluster Operators using the REST API

by
Jeremy Canfield |
Updated: October 25 2024
| 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 cluster operators 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/apis/config.openshift.io/v1/clusteroperators"
And here is how to return a specific cluster operator, the "storage" operator 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/apis/config.openshift.io/v1/clusteroperators/storage"
Something like this should be returned.
{
"apiVersion": "config.openshift.io/v1",
"kind": "ClusterOperator",
"metadata": {
"creationTimestamp": "2020-09-30T15:40:38Z",
"generation": 1,
"managedFields": [
{
"apiVersion": "config.openshift.io/v1",
"fieldsType": "FieldsV1",
"fieldsV1": {
"f:spec": {},
"f:status": {
".": {},
"f:extension": {}
}
},
"manager": "cluster-version-operator",
"operation": "Update",
"time": "2020-09-30T15:40:38Z"
},
{
"apiVersion": "config.openshift.io/v1",
"fieldsType": "FieldsV1",
"fieldsV1": {
"f:status": {
"f:conditions": {},
"f:relatedObjects": {},
"f:versions": {}
}
},
"manager": "cluster-storage-operator",
"operation": "Update",
"subresource": "status",
"time": "2024-10-24T23:55:18Z"
}
],
"name": "storage",
"resourceVersion": "1858974899",
"uid": "6c8ce98f-e476-4052-94a8-a26dac9a3cee"
},
"spec": {},
"status": {
"conditions": [
{
"lastTransitionTime": "2024-10-24T02:32:42Z",
"message": "DefaultStorageClassControllerAvailable: StorageClass provided by supplied CSI Driver instead of the cluster-storage-operator\nVSphereProblemDetectorMonitoringControllerAvailable: vsphere-problem-detector alerts are enabled\nVSphereProblemDetectorControllerAvailable: [defaultDatastore ApplTestDC/\"pure150_norep_at_linopshiftd_251\" in vSphere configuration: datastore pure150_norep_at_linopshiftd_251 is part of AT-LinuxOpenShiftDev-repno datastore cluster, StorageClass thin-csi: storage policy openshift-storage-policy-dev001: datastore pure150_norep_at_linopshiftd_251 is part of AT-LinuxOpenShiftDev-repno datastore cluster]\nVSphereCSIDriverOperatorCRAvailable: All is well",
"reason": "AsExpected",
"status": "True",
"type": "Available"
},
{
"lastTransitionTime": "2024-10-24T02:32:42Z",
"message": "VSphereCSIDriverOperatorCRDegraded: All is well",
"reason": "AsExpected",
"status": "False",
"type": "Degraded"
},
{
"lastTransitionTime": "2024-10-24T02:32:42Z",
"message": "VSphereCSIDriverOperatorCRUpgradeable: All is well",
"reason": "AsExpected",
"status": "True",
"type": "Upgradeable"
},
{
"lastTransitionTime": "2024-10-24T02:25:20Z",
"message": "VSphereCSIDriverOperatorCRProgressing: All is well",
"reason": "AsExpected",
"status": "False",
"type": "Progressing"
}
],
"extension": null,
"relatedObjects": [
{
"group": "",
"name": "vsphere-csi-driver-operator-trusted-ca-bundle",
"namespace": "openshift-cluster-csi-drivers",
"resource": "configmaps"
},
{
"group": "",
"name": "vmware-vsphere-csi-driver-operator",
"namespace": "openshift-cluster-csi-drivers",
"resource": "serviceaccounts"
},
{
"group": "rbac.authorization.k8s.io",
"name": "vmware-vsphere-csi-driver-operator-role",
"namespace": "openshift-cluster-csi-drivers",
"resource": "roles"
},
{
"group": "rbac.authorization.k8s.io",
"name": "vmware-vsphere-csi-driver-operator-rolebinding",
"namespace": "openshift-cluster-csi-drivers",
"resource": "rolebindings"
},
{
"group": "rbac.authorization.k8s.io",
"name": "vmware-vsphere-csi-driver-operator-clusterrole",
"resource": "clusterroles"
},
{
"group": "rbac.authorization.k8s.io",
"name": "vmware-vsphere-csi-driver-operator-clusterrolebinding",
"resource": "clusterrolebindings"
},
{
"group": "rbac.authorization.k8s.io",
"name": "vmware-vsphere-csi-driver-operator-prometheus",
"namespace": "openshift-cluster-csi-drivers",
"resource": "roles"
},
{
"group": "rbac.authorization.k8s.io",
"name": "vmware-vsphere-csi-driver-operator-prometheus",
"namespace": "openshift-cluster-csi-drivers",
"resource": "rolebindings"
},
{
"group": "monitoring.coreos.com",
"name": "vmware-vsphere-csi-driver-operator",
"namespace": "openshift-cluster-csi-drivers",
"resource": "prometheusrules"
},
{
"group": "operator.openshift.io",
"name": "csi.vsphere.vmware.com",
"resource": "clustercsidrivers"
},
{
"group": "",
"name": "openshift-cluster-storage-operator",
"resource": "namespaces"
},
{
"group": "",
"name": "openshift-cluster-csi-drivers",
"resource": "namespaces"
},
{
"group": "operator.openshift.io",
"name": "cluster",
"resource": "storages"
},
{
"group": "rbac.authorization.k8s.io",
"name": "cluster-storage-operator-role",
"resource": "clusterrolebindings"
},
{
"group": "sharedresource.openshift.io",
"name": "",
"resource": "sharedconfigmaps"
},
{
"group": "sharedresource.openshift.io",
"name": "",
"resource": "sharedsecrets"
}
],
"versions": [
{
"name": "operator",
"version": "4.14.23"
}
]
}
}
Did you find this article helpful?
If so, consider buying me a coffee over at