Redhat Openshift Cluster Project Maintenance

Aparna Srinivasan
AparnaSrinivasan
Published in
2 min readMay 13, 2021

Red Hat OpenShift is a cloud based kubernetes container platform which is platform agonostic in nature. This accelerates application development as the container based platform helps in quicker issue resolution. Redhat Openshift Cluster administration is the key as the UI is very user friendly at the same time needs a good knowledge on understanding. With this topic, i would cover how to maintain or even force delete a project to clean up and maintain the cluster.

Ensure we delete our project after use with this steps. This method will avoid any issues/terminating state present in the project:

  1. From the terminal/cmd prmpt, confirm the login through oc login.
  2. Confirm which namespace needs to be removed with oc get namespace

3. Create a temporary .json file: oc get namespace <failing namespace> -o json > tmp.json

  • Edit the file with your favorite text editor vim tmp.json Remove the kubernetes value from the finalizers field and save the file.

4. Do oc proxy in a window and open another terminal.

5. Then run in another terminal below command. Replace ${PROJECT_NAME} to namespace to be deleted

curl -k -H "Content-Type: application/json" -X PUT --data-binary @tmp.json http://127.0.0.1:8001/api/v1/namespaces/${PROJECT_NAME}/finalize

If you get authorization errors, you can also try running this on a master using certificates without the proxy command above:

# curl --cacert /etc/origin/master/ca.crt --key /etc/origin/master/admin.key --cert /etc/origin/master/admin.crt -k  -H "Content-Type: application/json" -X PUT --data-binary @tmp.json https://127.0.0.1:8443/api/v1/namespaces/<terminating-namespace>/finalize

5. Confirm by this oc delete project <project name> --force --grace-period=0

These steps will help in getting the hanging state projects to be cleaned up freeing up more space for active projects.

--

--