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 790728c
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 13 deletions.
28 changes: 16 additions & 12 deletions hack/scripts/check-dashboard.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ create_db_dependencies() {
echo "folder=$folder"
if [ "$folder" == "druid" ]; then
kubectl create configmap -n demo my-init-script \
--from-literal=init.sql="$(curl -fsSL https://raw.githubusercontent.com/kubedb/samples/old-dbs/druid/monitoring/mysql-init-script.sql)"
--from-literal=init.sql="$(curl -fsSL https://raw.githubusercontent.com/kubedb/samples/master/druid/monitoring/mysql-init-script.sql)"

helm repo add minio https://operator.min.io/
helm upgrade --install --namespace "minio-operator" --create-namespace "minio-operator" minio/operator --set operator.replicaCount=1 --wait
Expand Down Expand Up @@ -59,10 +59,18 @@ create_db_dependencies() {
kubectl apply -f ../samples/solr/monitoring/zookeeper.yaml
kubectl wait --for=jsonpath='{.status.phase}'=Ready ZooKeeper zookeeper -n demo --timeout=10m
fi
}

delete_db_dependencies() {
if [ "$folder" == "connectcluster" ]; then
kubectl apply -f ../samples/kafka/connectcluster/monitoring/kafka.yaml
kubectl wait --for=jsonpath='{.status.phase}'=Ready Kafka kafka-prod -n demo --timeout=10m
fi
}

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,7 +91,7 @@ check_dashboard_for_non_dbs() {
kubectl create ns demo

for folder in "${folder_array[@]}"; do
if [[ -v kind["$folder"] ]]; then
if [[ -v kind["$folder"] ]] && [[ "$folder" != "connectcluster" ]]; then
echo "db name: $folder"

readarray -t inside_files_array < <(ls "$folder")
Expand All @@ -107,20 +115,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"

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 "./hack/yamls/stash"

elif [ "$folder" == "policy" ]; then
echo "non db object name: $folder"
Expand All @@ -129,7 +133,7 @@ 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 "./hack/yamls/policy"
fi

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 790728c

Please sign in to comment.