Gary Wu | 950a323 | 2019-03-26 13:08:29 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | IFS=' |
| 4 | ' |
| 5 | |
| 6 | if [ -z $1 ]; then |
| 7 | echo "ONAP component name missing" |
| 8 | echo "Usage: ./cleanup.sh onap_component_name" |
| 9 | exit 1 |
| 10 | fi |
| 11 | |
| 12 | COMPONENT=$1 |
| 13 | |
| 14 | if [ $COMPONENT == "dcae" ] || [ $COMPONENT == "DCAE" ]; then |
| 15 | kubectl delete service consul -n onap |
| 16 | fi |
| 17 | |
Yang Xu | 2563a5e | 2019-06-15 23:59:51 -0400 | [diff] [blame] | 18 | if [ $COMPONENT == "sdc" ] || [ $COMPONENT == "SDC" ]; then |
| 19 | for keyspace in sdctitan sdcrepository sdcartifact sdccomponent sdcaudit; do |
Yang Xu | cde4f9d | 2019-06-16 22:52:41 -0400 | [diff] [blame] | 20 | kubectl exec dev-cassandra-cassandra-0 -- cqlsh -u cassandra -p cassandra -e "drop keyspace ${keyspace}" |
| 21 | done |
| 22 | fi |
| 23 | |
| 24 | if [ $COMPONENT == "so" ] || [ $COMPONENT == "SO" ]; then |
| 25 | for database in camundabpmn catalogdb requestdb; do |
| 26 | kubectl exec dev-mariadb-galera-mariadb-galera-0 -- mysql -uroot -psecretpassword -e "drop database ${database}" |
| 27 | done |
| 28 | fi |
| 29 | |
| 30 | if [ $COMPONENT == "sdnc" ] || [ $COMPONENT == "SDNC" ]; then |
| 31 | for database in sdnctl; do |
| 32 | kubectl exec dev-mariadb-galera-mariadb-galera-0 -- mysql -uroot -psecretpassword -e "drop database ${database}" |
Yang Xu | 2563a5e | 2019-06-15 23:59:51 -0400 | [diff] [blame] | 33 | done |
| 34 | fi |
| 35 | |
Gary Wu | 950a323 | 2019-03-26 13:08:29 -0700 | [diff] [blame] | 36 | for op in secrets configmaps pvc pv services deployments statefulsets clusterrolebinding; do |
| 37 | ARRAY=(`kubectl get $op -n onap | grep dev-$COMPONENT | awk '{print $1}'`) |
| 38 | for i in ${ARRAY[*]}; do |
| 39 | kubectl delete $op -n onap $i |
| 40 | done |
| 41 | done |