How To
Summary
Red Hat OpenShift Container Platform Projects have a Kubernetes finalizer that prevents the deletion of the Project before all the resources are removed. After all visible resources are removed from the Project, a hidden item can still prevent the Project from being deleted, so the Project gets stuck in a 'Terminating' status.
Objective
The objective is to provide a process for Red Hat OpenShift Container Platform to delete a project that is stuck in a
'Terminating' status.
Environment
Red Hat OpenShift Container Platform 4.8
Steps
- Log in to your Red Hat OpenShift Container Platform Console.
- In Red Hat OpenShift Container Platform Console click the drop-down arrow next to your username, select the option 'Copy login command', then click 'Display Token'.


NOTE: You might need to authenticate again. - Highlight and copy the oc login command.
- Connect to the Red Hat OpenShift Platform Server with SSH.
- When successfully logged in paste the oc login command, copied in Step 3.
oc login –-token=sha256...... - Run the following command to retrieve a list of Projects.
A list of Projects are displayed, take note of the Project name that has a 'Terminating' status.oc get projects
NOTE: In the following commands, replace <Project> with the actual Project name. - Obtain a copy of the configuration for the Project that is in a
Terminatingstatus by running the following command.oc get namespace <Project> -o json > <Project>-ns.json - Create a Backup of the JSON configuration file.
cp <Project>-ns.json <Project>-ns.backup.json -
Edit the saved JSON configuration file.
vi <Project>-ns.json{ "apiVersion": "v1", "kind": "Namespace", "metadata": { ... "name": "finalizer-example", ... }, "spec": { "finalizers": [ "kubernetes" ] }, "status": { ... } } - Scroll down the file and remove the contents of the finalizer array so your file looks similar to the next screen.
Delete the reference to"Kubernetes".... }, "spec": { "finalizers": [] }, ... -
Press escape (Esc) followed by
:xto save the file. - Run a cat command on the <Project>-ns.json file to confirm the JSON file was saved correctly.
cat <Project>-ns.json - Run the following curl command in your terminal window to fully remove the unwanted Project.
curl -k -H "Content-Type: application/json" -H "Authorization: Bearer $(oc whoami -t)" -X PUT --data-binary @<Project>-ns.json https://<OPENSHIFT_CONSOLE_ADDRESS>:6443/api/v1/namespaces/<Project>/finalize - Confirm in the Red Hat OpenShift Server from the command line that the Project was removed by running the 'oc get projects' command again.
NOTE: You can also verify from the Red Hat OpenShift Console page that the Project was removed from under the Projects section.oc get projects
Document Location
Worldwide
[{"Type":"MASTER","Line of Business":{"code":"LOB24","label":"Security Software"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Product":{"code":"SSTDPP","label":"IBM Cloud Pak for Security"},"ARM Category":[{"code":"a8m3p0000000rbnAAA","label":"Administration Task"}],"ARM Case Number":"","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"All Versions"}]
Was this topic helpful?
Document Information
Modified date:
30 August 2022
UID
ibm16607563