How to delete an OpenShift 4 cluster without a metadata.json file

Solution In Progress - Updated -

Environment

  • Red Hat OpenShift Container Platform 4.x

Issue

  • Lost the directory that stores metadata for OpenShift 4 Cluster.
  • Lost metadata.json file for OpenShift 4 cluster
  • How to delete OpenShift 4 cluster with lost directory or metadata

Resolution

If the OpenShift 4 cluster are deployed by installer and you lost the metadata, there is no way to delete the cluster using the OpenShift installer without the metadata

In order to destrory the cluster using the installer, you should generate metadata.json file.

  • Get CLUSTER_UUID and INFRA_ID
    If the cluster is still running

    $ CLUSTER_NAME=NAME
    $ AWS_REGION=REGION
    $ CLUSTER_UUID=$(oc get clusterversions.config.openshift.io version -o jsonpath='{.spec.clusterID}{"\n"}')
    $ INFRA_ID=$(oc get infrastructures.config.openshift.io cluster -o jsonpath='{.status.infrastructureName}{"\n"}')
    
  • Generate metadata.json file.

    echo "{\"clusterName\":\"${CLUSTER_NAME}\",\"clusterID\":\"${CLUSTER_UUID}\",\"infraID\":\"${INFRA_ID}\",\"aws\":{\"region\":\"${AWS_REGION}\",\"identifier\":[{\"kubernetes.io/cluster/${INFRA_ID}\":\"owned\"},{\"openshiftClusterID\":\"${CLUSTER_UUID}\"}]}}" > metadata.json
    
  • Destroy cluster with the generated metadata.json file

    ./openshift-install  destroy cluster --log-level=debug
    

Diagnostic Steps

  • In the commands above you need your clusterID, see KCS 3831361 on how to get this in several ways.

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

1 Comments

json does not support single quotes, even if the golang parser accepts it, at least jq will not. We really should turn all of the ' into \'