33 lines
1.2 KiB
Bash
Executable File
33 lines
1.2 KiB
Bash
Executable File
#!/bin/bash
|
|
# filepath: remove-app.sh
|
|
set -e
|
|
|
|
# Set variables
|
|
PROJECT_ID=$(gcloud config get-value project)
|
|
REGION=europe-central2
|
|
ZONE=europe-central2-a
|
|
CLUSTER_NAME=sayed-cluster-1
|
|
|
|
# Get cluster credentials
|
|
gcloud container clusters get-credentials $CLUSTER_NAME --region $REGION --project $PROJECT_ID
|
|
|
|
echo "Removing application resources..."
|
|
|
|
# Delete Ingress and certificates
|
|
kubectl delete ingress contact-app-ingress -n contact-app --ignore-not-found=true
|
|
kubectl delete managedcertificate contact-app-cert -n contact-app --ignore-not-found=true
|
|
|
|
# Delete app deployment and services
|
|
kubectl delete deployment contact-app -n contact-app --ignore-not-found=true
|
|
kubectl delete service contact-app -n contact-app --ignore-not-found=true
|
|
kubectl delete service contact-app-lb -n contact-app --ignore-not-found=true
|
|
|
|
# Delete MongoDB deployment, service, and PVC
|
|
kubectl delete deployment mongo -n contact-app --ignore-not-found=true
|
|
kubectl delete service mongo -n contact-app --ignore-not-found=true
|
|
kubectl delete pvc mongo-pvc -n contact-app --ignore-not-found=true
|
|
|
|
# Delete namespace
|
|
kubectl delete namespace contact-app --ignore-not-found=true
|
|
|
|
echo "Application and associated resources have been removed." |