Skip to content

Commit 742e38f

Browse files
author
Lily He
committed
update cleanup.sh
1 parent a649328 commit 742e38f

File tree

2 files changed

+71
-263
lines changed

2 files changed

+71
-263
lines changed

kubernetes/delete-weblogic-domain-resources.sh

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ function getVoyagerOfDomain {
6464
local ns=`kubectl get ingress.voyager.appscode.com --all-namespaces | grep $domainName | awk '{ print $1 }'`
6565
if [ -n "$ns" ]; then
6666
echo $voyagerIngressName $domainName-voyager -n $ns >> $2
67-
echo service $domainName-voyager-stats -n $ns >> $2
6867
fi
6968
}
7069

@@ -116,8 +115,12 @@ function getDomainResources {
116115
LABEL_SELECTOR="weblogic.domainUID in ($1)"
117116
fi
118117

119-
# first, let's get all namespaced types with -l $LABEL_SELECTOR
118+
# clean the output file
119+
if [ -e $2 ]; then
120+
rm $2
121+
fi
120122

123+
# first, let's get all namespaced types with -l $LABEL_SELECTOR
121124
NAMESPACED_TYPES="pod,job,deploy,rs,service,pvc,ingress,cm,serviceaccount,role,rolebinding,secret"
122125

123126
# if domain crd exists, look for domains too:
@@ -129,7 +132,7 @@ function getDomainResources {
129132
kubectl get $NAMESPACED_TYPES \
130133
-l "$LABEL_SELECTOR" \
131134
-o=jsonpath='{range .items[*]}{.kind}{" "}{.metadata.name}{" -n "}{.metadata.namespace}{"\n"}{end}' \
132-
--all-namespaces=true > $2
135+
--all-namespaces=true >> $2
133136

134137
# now, get all non-namespaced types with -l $LABEL_SELECTOR
135138

@@ -240,9 +243,9 @@ function deleteDomains {
240243
# for each namespace with leftover resources, try delete them
241244
cat $tempfile | awk '{ print $4 }' | grep -v "^$" | sort -u | while read line; do
242245
if [ "$test_mode" = "true" ]; then
243-
echo kubectl -n $line delete $NAMESPACED_TYPES -l "$LABEL_SELECTOR"
246+
echo kubectl -n $line delete $NAMESPACED_TYPES,ingress.voyager.appscode.com -l "$LABEL_SELECTOR"
244247
else
245-
kubectl -n $line delete $NAMESPACED_TYPES -l "$LABEL_SELECTOR"
248+
kubectl -n $line delete $NAMESPACED_TYPES,ingress.voyager.appscode.com -l "$LABEL_SELECTOR"
246249
fi
247250
done
248251

0 commit comments

Comments
 (0)