Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Cleanup for DR Resources #84

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions clean.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/env bash

SECRET_LABEL_KEY="multicluster.odf.openshift.io/secret-type"
SOURCE_LABEL="BLUE"
DESTINATION_LABEL="GREEN"
INTERNAL_LABEL="INTERNAL"
IGNORE_LABEL="IGNORE"
RAMEN_HUB_NAMESPACE="openshift-dr-system"

function clean-hub-cluster {
echo "Cleaning up hub cluster"
oc delete mirrorpeers --all
for NAMESPACE in "$@"; do
oc delete managedclusteraddon tokenexchange -n "${NAMESPACE}"
echo "$SECRET_LABEL_KEY in ($SOURCE_LABEL, $DESTINATION_LABEL, $INTERNAL_LABEL, $IGNORE_LABEL)"
oc delete secrets -l "$SECRET_LABEL_KEY in ($SOURCE_LABEL, $DESTINATION_LABEL, $INTERNAL_LABEL, $IGNORE_LABEL)" -n "${NAMESPACE}"
done
}


function clean-spoke-cluster {
echo "Cleaning spoke cluster"

# Delete all VolumeReplicationClasses
oc delete vrcs --all

# Delete all Object Bucket Claims that contain "odrbucket"
oc get obc -n ${RAMEN_HUB_NAMESPACE} --no-headers=true | awk '/odrbucket/{print $1}'| xargs oc delete -n ${RAMEN_HUB_NAMESPACE} obc
}

while getopts "h:s:" op; do
case "${op}" in
h)
echo "Cleaning up DR Resources in hub cluster"
export KUBECONFIG="$OPTARG"
shift 2
clean-hub-cluster "$@"
;;
s)
echo "Cleaning up DR Resources in spoke cluster"
export KUBECONFIG="$OPTARG"
shift 2
clean-spoke-cluster "$@"
;;
*)
echo "Invalid option"
esac
done