#!/bin/bash

cd "$(dirname "$0")"

#kubectl create namespace overleaf


kubectl delete -n overleaf -f ./overleaf/overleaf-service.yaml -f ./overleaf/overleaf-deployment.yaml -f ./overleaf/overleaf-variables.yaml 
kubectl delete -f ./overleaf/reg-secret.yaml

if [ "$1" = "t" ]
then
#
kubectl delete -f ./overleaf/overleaf-pvc.yaml

# El GUI para mongoDB
#
kubectl delete -f mongo-express/mongo-configmap.yaml -f mongo-express/mongoDB-secret.yaml -f mongo-express/mongo-express.yaml
#
helm uninstall mongo  --namespace overleaf 
helm uninstall redis  --namespace overleaf
kubectl -n overleaf delete persistentvolumeclaim/datadir-mongo-mongodb-0 persistentvolumeclaim/redis-data-redis-master-0

## Uncomment following ling to expose the application via ingress
#kubectl apply -n overleaf -f ./overleaf/overleaf-ingress.yaml
fi
