Skip to content

Commit e1c569c

Browse files
authored
CLOUD-783 - Cleanup test cluster before deletion (#359)
1 parent e779426 commit e1c569c

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Jenkinsfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,15 @@ void shutdownCluster(String CLUSTER_SUFFIX) {
3636
source $HOME/google-cloud-sdk/path.bash.inc
3737
gcloud auth activate-service-account --key-file $CLIENT_SECRET_FILE
3838
gcloud config set project $GCP_PROJECT
39+
for namespace in \$(kubectl get namespaces --no-headers | awk '{print \$1}' | grep -vE "^kube-|^openshift" | sed '/-operator/ s/^/1-/' | sort | sed 's/^1-//'); do
40+
kubectl delete deployments --all -n \$namespace --force --grace-period=0 || true
41+
kubectl delete sts --all -n \$namespace --force --grace-period=0 || true
42+
kubectl delete replicasets --all -n \$namespace --force --grace-period=0 || true
43+
kubectl delete poddisruptionbudget --all -n \$namespace --force --grace-period=0 || true
44+
kubectl delete services --all -n \$namespace --force --grace-period=0 || true
45+
kubectl delete pods --all -n \$namespace --force --grace-period=0 || true
46+
done
47+
kubectl get svc --all-namespaces || true
3948
gcloud container clusters delete --zone $GKERegion $CLUSTER_NAME-${CLUSTER_SUFFIX}
4049
"""
4150
}

0 commit comments

Comments
 (0)