When creating an OCP cluster using openshift-installer
that fails before the metadata.json
file is created, cleaning up can be difficult because it doesn't know what needs to be removed. Fortunately, there is a workaround:
-
Configure AWS CLI
This assumes you have configured the AWS CLI using your credentials. If you have not done this, follow the instructions
-
Retrieve the cluster ID
Double check the information in the below command to ensure it's accurate for your deployment, e.g. the AWS region.
# if using an RHPDS/opentlc instance, your cluster name is probably "cluster-GUID" aws ec2 describe-instances --region=<AWS_REGION> --filters "Name=tag:clusterid,Values=<CLUSTER_NAME>" --output table
-
Create the
metadata.json
file from a templateReplace the cluster id with your data
cat <<EOL > metadata.json {"clusterName":"<CLUSTER_NAME>","clusterID":"<CLUSTER_ID>","aws":{"region":"<AWS_REGION>","identifier":[{"openshiftClusterID":"<CLUSTER_ID>"},{"kubernetes.io/cluster/<CLUSTER_NAME>":"owned"}]}} EOL
-
Destroy the cluster
openshift-installer destroy cluster
A short bash script which will generate the JSON for you has been attached to this gist.
Usage:
./meta.sh cluster-0000 > metadata.json