Created
August 21, 2019 15:44
-
-
Save jwmatthews/02d433fbf1c52ed46fafab691567df65 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
SRC_KUBECONFIG="/Users/jmatthews/.agnosticd/jwm0817ocp3b/kubeconfig" | |
DST_KUBECONFIG="/Users/jmatthews/.agnosticd/jwm0817ocp4b/ocp4-workshop_jwm0817ocp4b_kubeconfig" | |
MIG_NAMESPACE="mig" | |
MSSQL_NAMESPACE="mssql-persistent" | |
## Destination Cleanup | |
echo "Removing migmigrations" | |
names=`KUBECONFIG=${DST_KUBECONFIG} oc get migmigration -o name -n ${MIG_NAMESPACE}` | |
if [ "$?" != "0" ]; then | |
echo "Error getting migmigration from '${MIG_NAMESPACE}'" | |
exit | |
fi | |
for name in $names | |
do | |
: | |
echo "Delete migmigration '${name}'" | |
KUBECONFIG=${DST_KUBECONFIG} oc delete ${name} -n ${MIG_NAMESPACE} | |
if [ "$?" != "0" ]; then | |
echo "Error deleting '${name}' from '${MIG_NAMESPACE}'" | |
exit | |
fi | |
done | |
echo "Removing migplans" | |
names=`KUBECONFIG=${DST_KUBECONFIG} oc get migplan -o name -n ${MIG_NAMESPACE}` | |
if [ "$?" != "0" ]; then | |
echo "Error getting migplan from '${MIG_NAMESPACE}'" | |
exit | |
fi | |
for name in $names | |
do | |
: | |
echo "Delete migplan ${name}" | |
KUBECONFIG=${DST_KUBECONFIG} oc delete ${name} -n ${MIG_NAMESPACE} | |
if [ "$?" != "0" ]; then | |
echo "Error deleting '${name}' from '${MIG_NAMESPACE}'" | |
exit | |
fi | |
done | |
echo "Removing project ${MSSQL_NAMESPACE}" | |
KUBECONFIG=${DST_KUBECONFIG} oc delete project ${MSSQL_NAMESPACE} | |
echo "Scaling app in ${MSSQL_NAMESPACE} back up" | |
KUBECONFIG=${SRC_KUBECONFIG} oc scale deploymentconfig mssql-deployment --replicas=1 -n ${MSSQL_NAMESPACE} | |
KUBECONFIG=${SRC_KUBECONFIG} oc scale deployment mssql-app-deployment --replicas=1 -n ${MSSQL_NAMESPACE} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When run successfully displays:
$ time ./cleanup.sh
Removing migmigrations
Delete migmigration 'migmigration.migration.openshift.io/510b8210-c42a-11e9-9782-3f17256f64e1'
migmigration.migration.openshift.io "510b8210-c42a-11e9-9782-3f17256f64e1" deleted
Removing migplans
Delete migplan migplan.migration.openshift.io/aug211142am
migplan.migration.openshift.io "aug211142am" deleted
Removing project mssql-persistent
project.project.openshift.io "mssql-persistent" deleted
Scaling app in mssql-persistent back up
deploymentconfig.apps.openshift.io/mssql-deployment scaled
deployment.extensions/mssql-app-deployment scaled
real 0m9.227s
user 0m1.328s
sys 0m0.555s