Skip to content

Commit

Permalink
cleanup func added
Browse files Browse the repository at this point in the history
Signed-off-by: sayedppqq <[email protected]>
  • Loading branch information
sayedppqq committed May 23, 2024
1 parent 5dd21d6 commit 7a2a521
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 11 deletions.
24 changes: 14 additions & 10 deletions hack/scripts/check-dashboard.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,11 @@ create_db_dependencies() {
fi
}

delete_db_dependencies() {

cleanup() {
path="$1"
kubectl delete -f $path
kubectl delete secret -n demo --all
kubectl delete configmap -n demo --all
}

check_dashboard_for_non_dbs() {
Expand All @@ -83,6 +86,9 @@ check_dashboard_for_non_dbs() {
kubectl create ns demo

for folder in "${folder_array[@]}"; do

cleanup_path=""

if [[ -v kind["$folder"] ]]; then
echo "db name: $folder"

Expand All @@ -107,20 +113,16 @@ for folder in "${folder_array[@]}"; do
$HOME/go/bin/kubectl-dba monitor dashboard $folder $folder -n demo $dashboard_name --prom-svc-name=prometheus-kube-prometheus-prometheus --prom-svc-namespace=monitoring --prom-svc-port=9090
fi
done
cleanup_path="$path"

kubectl delete -f $path
delete_db_dependencies "$folder"
elif [ "$folder" == "stash" ]; then
echo "non db object name: $folder"
readarray -t inside_files_array < <(ls "$folder")

bash ./hack/scripts/stash-flow.sh
check_dashboard_for_non_dbs "$folder" "$inside_files_array"

kubectl delete -f ./hack/yamls/backupconfiguration.yaml
kubectl delete -f ./hack/yamls/restoresession.yaml
kubectl delete -f ./hack/yamls/repository.yaml
kubectl delete -f ../samples/mongodb/monitoring/mongodb_standalone.yaml
cleanup_path="./hack/yamls/stash"

elif [ "$folder" == "policy" ]; then
echo "non db object name: $folder"
Expand All @@ -129,7 +131,9 @@ for folder in "${folder_array[@]}"; do
bash ./hack/scripts/policy-flow.sh
check_dashboard_for_non_dbs "$folder" "$inside_files_array"

kubectl delete -f ./hack/yamls/policy/constraint-template.yaml
kubectl delete -f ./hack/yamls/policy/constraint.yaml
cleanup_path="./hack/yamls/policy"
fi

cleanup "$cleanup_path"

done
2 changes: 1 addition & 1 deletion hack/scripts/stash-flow.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ curl -o kubectl-stash.tar.gz -fsSL https://github.com/stashed/cli/releases/downl
kubectl apply -f ./hack/yamls/stash/repository.yaml
sleep 10

kubectl apply -f ../samples/mongodb/monitoring/mongodb_standalone.yaml
kubectl apply -f ./hack/yamls/stash/mongodb_standalone.yaml
kubectl wait --for=jsonpath='{.status.phase}'=Ready MongoDB mongodb-standalone -n demo --timeout=10m

kubectl apply -f ./hack/yamls/stash/backupconfiguration.yaml
Expand Down
22 changes: 22 additions & 0 deletions hack/yamls/stash/mongodb_standalone.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: kubedb.com/v1alpha2
kind: MongoDB
metadata:
name: mongodb-standalone
namespace: demo
spec:
version: "4.4.26"
terminationPolicy: WipeOut
storage:
storageClassName: "standard"
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
monitor:
agent: prometheus.io/operator
prometheus:
serviceMonitor:
labels:
release: prometheus
interval: 10s

0 comments on commit 7a2a521

Please sign in to comment.