blob: 405bc5ae43e85f8468aff66f7465214aa5c40bf2 [file] [log] [blame]
Gary Wu950a3232019-03-26 13:08:29 -07001#!/bin/bash
2
3IFS='
4'
5
Marco Plataniabad325e2019-08-16 10:32:58 -04006if [ -z $1 ] || [ -z $2 ] || [ -z $3 ]; then
7 echo "Usage: ./cleanup.sh onap_component_name namespace deployment"
Gary Wu950a3232019-03-26 13:08:29 -07008 exit 1
9fi
10
Marco Plataniabad325e2019-08-16 10:32:58 -040011COMPONENT=`echo "$1" | tr '[:upper:]' '[:lower:]'`
12NAMESPACE=`echo "$2" | tr '[:upper:]' '[:lower:]'`
13DEPLOYMENT=`echo "$3" | tr '[:upper:]' '[:lower:]'`
Gary Wu950a3232019-03-26 13:08:29 -070014
Marco Plataniabad325e2019-08-16 10:32:58 -040015if [ $COMPONENT == "dcae" ]; then
16 ARRAY=(`kubectl get replicasets -n $NAMESPACE | grep $DEPLOYMENT- | awk '{print $1}'`)
Gary Wu950a3232019-03-26 13:08:29 -070017 for i in ${ARRAY[*]}; do
Marco Plataniabad325e2019-08-16 10:32:58 -040018 kubectl delete replicaset -n $NAMESPACE $i
19 done
20
21 ARRAY=(`kubectl get services -n $NAMESPACE | grep -e ^xdcae | awk '{print $1}'`)
22 for i in ${ARRAY[*]}; do
23 kubectl delete service -n $NAMESPACE $i
24 done
25
26 ARRAY=(`kubectl get services -n $NAMESPACE | grep -e ^holmes | awk '{print $1}'`)
27 for i in ${ARRAY[*]}; do
28 kubectl delete service -n $NAMESPACE $i
29 done
30fi
31
32if [ $COMPONENT == "sdc" ]; then
33 for keyspace in sdctitan sdcrepository sdcartifact sdccomponent sdcaudit; do
34 kubectl -n $NAMESPACE exec dev-cassandra-cassandra-0 -- cqlsh -u cassandra -p cassandra -e "drop keyspace ${keyspace}"
35 done
36fi
37
38if [ $COMPONENT == "so" ]; then
39 for database in camundabpmn catalogdb requestdb; do
40 kubectl -n $NAMESPACE exec dev-mariadb-galera-mariadb-galera-0 -- mysql -uroot -psecretpassword -e "drop database ${database}"
41 done
42fi
43
44if [ $COMPONENT == "sdnc" ]; then
45 for database in sdnctl; do
46 kubectl -n $NAMESPACE exec dev-mariadb-galera-mariadb-galera-0 -- mysql -uroot -psecretpassword -e "drop database ${database}"
47 done
48fi
49
50for op in secrets configmaps pvc pv deployments statefulsets clusterrolebinding jobs; do
51 ARRAY=(`kubectl get $op -n $NAMESPACE | grep $DEPLOYMENT-$COMPONENT | awk '{print $1}'`)
52 for i in ${ARRAY[*]}; do
53 kubectl delete $op -n $NAMESPACE $i
Gary Wu950a3232019-03-26 13:08:29 -070054 done
55done
Marco Plataniabad325e2019-08-16 10:32:58 -040056
57ARRAY=(`kubectl get services -n $NAMESPACE | grep -e ^$COMPONENT | awk '{print $1}'`)
58for i in ${ARRAY[*]}; do
59 kubectl delete service -n $NAMESPACE $i
60done