Bootstrap FreeKB - OpenShift - Delete group using REST API
OpenShift - Delete group using 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 every group. 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/user.openshift.io/v1/groups"

 

Or, to GET a specific group.

curl
--insecure
--request GET
--header "Accept: application/json"
--header "Authorization: Bearer sha256~0Rs__hPuXmBD3TJTXNDisC7wRBN-nrFnYTxgdBrFT-U"
--url "https://api.openshift.example.com:6443/apis/user.openshift.io/v1/groups/my-group"

 

Something like this should be returned.

{
  [
    {
      "metadata": {
        "name": "my-group",
        "uid": "613c1af0-bf13-42ec-be5b-f6f0c889fd12",
        "resourceVersion": "1050548501",
        "creationTimestamp": "2022-01-07T16:15:57Z",
        "managedFields": [
          {
            "manager": "python-requests",
            "operation": "Update",
            "apiVersion": "user.openshift.io/v1",
            "time": "2022-01-07T16:15:57Z",
            "fieldsType": "FieldsV1",
            "fieldsV1": {
              "f:users": {}
            }
          }
        ]
      },
      "users": [
        "john.doe",
        "jane.doe"
      ]
    }
  ]
}

 

The following DELETE request could then be used to delete the group.

AVOID TROUBLE

Before deleting a group, you probably should remove the group from any Role Bindings or Cluster Role Bindings the group is listed in.

OpenShift - List Role Bindings using REST API

OpenShift - Update a Role Binding using REST API

curl \
--insecure \
--request DELETE \
--header "Authorization: Bearer sha256~0Rs__hPuXmBD3TJTXNDisC7wRBN-nrFnYTxgdBrFT-U" \
--url https://api.openshift.example.com:6443/apis/user.openshift.io/v1/groups/my-group

 




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