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

Solution In Progress - Updated -


  • Red Hat OpenShift Container Platform 4.x


  • 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


If the OpenShift 4 cluster are deployed by installer (for IPI usecases) and you lost the associated metadata.json file, there is no way to delete the cluster using the OpenShift installer without the metadata.json file.

In order to destroy the cluster using the installer, you should generate metadata.json file.
Similar processes for GCP and Azure (or other IPI installs) can be used, however, they are not documented by this KCS (at this time).

  • Generate metadata.json file.

    echo "{\"clusterName\":\"${CLUSTER_NAME}\",\"clusterID\":\"\",\"infraID\":\"${CLUSTER_NAME}\",\"aws\":{\"region\":\"${AWS_REGION}\",\"identifier\":[{\"${CLUSTER_NAME}\":\"owned\"}]}}" > 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.


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 \'

I'm running a pre-release 4.2 cluster on VMWare vSphere, and trying this does not work since I don't have AWS... When I remove the aws-specific stuff and leave only clusterName, clusterID and infraID parts into metadata.json, I get error: "FATAL Failed while preparing to destroy cluster: no platform configured in metadata"

I also have a GA openshift 4.2 cluster (installed as 4.1, later upgraded) and that other cluster's metadata.json does not have anything other than clusterName, clusterID and infraID in it. If I tried to delete that cluster, how should I go about it?

Then, my clusters view in have still yet another 4.1 cluster, which too was installed earlier into vSphere and there is not a single bit about it in existence anymore anywhere in our environment. I cannot even archive that cluster from my clusters view.

This KCS was intended for IPI based installs. Updates have been made to reflect this. For UPI installs, you need to manually delete the resources.

Looking at a current metadata.json from vsphere I see this format (changed to fit the vars mentioned here) might work for you

echo "{\"clusterName\":\"${CLUSTER_NAME}\",\"clusterID\":\"\",\"infraID\":\"${CLUSTER_NAME}\",\"vCenter\":{\"vCenter\":\"${VCENTER_HOST}\",\"username\":\"${VCENTER_USER}\",\"password":\"${VCENTER_PASS}\"}}" > metadata.json

also (assuming your cluster is accesable)

CLUSTERID=`oc get clusterversion -o jsonpath='{.items[].spec.clusterID}{"\n"}'`

If you find you need it

Sorry, i am in a restricted network. no aws or other public cloud provider.

This knowledgebase article doesn't appear to work as it is currently written. First, in the metadata.json it sets both clusterName and infraID to the same value. infraID is not equal to clusterName, it's clusterName plus some five character string on every AWS IPI cluster I've built in the four series. Second, it sets clusterID to an empty string. That might actually be okay, because my cluster hasn't tagged anything with the clusterID, so the destroy command doesn't need it anyway. But maybe that's needed in other kinds of installs. A third problem here is that the "Diagnostic Steps" section does not contain diagnostic steps.

I have tried the solution in my 4.6.36 cluster using
echo "{\"clusterName\":\"${CLUSTER_NAME}\",\"clusterID\":\"\",\"infraID\":\"${CLUSTER_NAME}\",\"aws\":{\"region\":\"${AWS_REGION}\",\"identifier\":[{\"${CLUSTER_NAME}\":\"owned\"}]}}" > metadata.json

and it destroyed my cluster correctly.

The cluster wasn't removed.

I think this KCS never works in the current version. My customer, who used an Azure IPI cluster had deleted their cluster by the following procedure:

$ CLUSTER_ID=$(oc get clusterversion -o jsonpath='{.items[].spec.clusterID}{"\n"}')

$ INFRA_ID=$(oc get infrastructure -o jsonpath='{.items[].status.infrastructureName}{"\n"}')



$ echo "{\"clusterName\":\"${CLUSTER_NAME}\",\"clusterID\":\"${CLUSTER_ID}\",\"infraID\":\"${INFRA_ID}\",\"azure\":{\"region\":\"${AZURE_REGION}\",\"identifier\":[{\"${INFRA_ID}\":\"owned\"}]}}" > metadata.json

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

Could you please fix this KCS?