diff options
Diffstat (limited to 'deployment/heat')
-rwxr-xr-x | deployment/heat/onap-rke/cleanup.sh | 12 | ||||
-rwxr-xr-x | deployment/heat/onap-rke/scripts/cleanup.sh | 49 |
2 files changed, 46 insertions, 15 deletions
diff --git a/deployment/heat/onap-rke/cleanup.sh b/deployment/heat/onap-rke/cleanup.sh new file mode 100755 index 000000000..24f263be6 --- /dev/null +++ b/deployment/heat/onap-rke/cleanup.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +IFS=' +' + +if [ -z $1 ]; then + echo "ONAP component name missing" + echo "Usage: ./cleanup.sh onap_component_name" + exit 1 +fi + +( cd scripts; ./cleanup.sh $1 onap dev ) diff --git a/deployment/heat/onap-rke/scripts/cleanup.sh b/deployment/heat/onap-rke/scripts/cleanup.sh index f602c70a9..405bc5ae4 100755 --- a/deployment/heat/onap-rke/scripts/cleanup.sh +++ b/deployment/heat/onap-rke/scripts/cleanup.sh @@ -3,39 +3,58 @@ IFS=' ' -if [ -z $1 ]; then - echo "ONAP component name missing" - echo "Usage: ./cleanup.sh onap_component_name" +if [ -z $1 ] || [ -z $2 ] || [ -z $3 ]; then + echo "Usage: ./cleanup.sh onap_component_name namespace deployment" exit 1 fi -COMPONENT=$1 +COMPONENT=`echo "$1" | tr '[:upper:]' '[:lower:]'` +NAMESPACE=`echo "$2" | tr '[:upper:]' '[:lower:]'` +DEPLOYMENT=`echo "$3" | tr '[:upper:]' '[:lower:]'` -if [ $COMPONENT == "dcae" ] || [ $COMPONENT == "DCAE" ]; then - kubectl delete service consul -n onap +if [ $COMPONENT == "dcae" ]; then + ARRAY=(`kubectl get replicasets -n $NAMESPACE | grep $DEPLOYMENT- | awk '{print $1}'`) + for i in ${ARRAY[*]}; do + kubectl delete replicaset -n $NAMESPACE $i + done + + ARRAY=(`kubectl get services -n $NAMESPACE | grep -e ^xdcae | awk '{print $1}'`) + for i in ${ARRAY[*]}; do + kubectl delete service -n $NAMESPACE $i + done + + ARRAY=(`kubectl get services -n $NAMESPACE | grep -e ^holmes | awk '{print $1}'`) + for i in ${ARRAY[*]}; do + kubectl delete service -n $NAMESPACE $i + done fi -if [ $COMPONENT == "sdc" ] || [ $COMPONENT == "SDC" ]; then +if [ $COMPONENT == "sdc" ]; then for keyspace in sdctitan sdcrepository sdcartifact sdccomponent sdcaudit; do - kubectl -n onap exec dev-cassandra-cassandra-0 -- cqlsh -u cassandra -p cassandra -e "drop keyspace ${keyspace}" + kubectl -n $NAMESPACE exec dev-cassandra-cassandra-0 -- cqlsh -u cassandra -p cassandra -e "drop keyspace ${keyspace}" done fi -if [ $COMPONENT == "so" ] || [ $COMPONENT == "SO" ]; then +if [ $COMPONENT == "so" ]; then for database in camundabpmn catalogdb requestdb; do - kubectl -n onap exec dev-mariadb-galera-mariadb-galera-0 -- mysql -uroot -psecretpassword -e "drop database ${database}" + kubectl -n $NAMESPACE exec dev-mariadb-galera-mariadb-galera-0 -- mysql -uroot -psecretpassword -e "drop database ${database}" done fi -if [ $COMPONENT == "sdnc" ] || [ $COMPONENT == "SDNC" ]; then +if [ $COMPONENT == "sdnc" ]; then for database in sdnctl; do - kubectl -n onap exec dev-mariadb-galera-mariadb-galera-0 -- mysql -uroot -psecretpassword -e "drop database ${database}" + kubectl -n $NAMESPACE exec dev-mariadb-galera-mariadb-galera-0 -- mysql -uroot -psecretpassword -e "drop database ${database}" done fi -for op in secrets configmaps pvc pv services deployments statefulsets clusterrolebinding job; do - ARRAY=(`kubectl get $op -n onap | grep dev-$COMPONENT | awk '{print $1}'`) +for op in secrets configmaps pvc pv deployments statefulsets clusterrolebinding jobs; do + ARRAY=(`kubectl get $op -n $NAMESPACE | grep $DEPLOYMENT-$COMPONENT | awk '{print $1}'`) for i in ${ARRAY[*]}; do - kubectl delete $op -n onap $i + kubectl delete $op -n $NAMESPACE $i done done + +ARRAY=(`kubectl get services -n $NAMESPACE | grep -e ^$COMPONENT | awk '{print $1}'`) +for i in ${ARRAY[*]}; do + kubectl delete service -n $NAMESPACE $i +done
\ No newline at end of file |