#!/usr/bin/env bash # ============================================================================= # stop-app.sh # Deletes all Kubernetes objects created for the Todo application. # The PersistentVolume host directory is preserved (data survives restart). # ============================================================================= set -euo pipefail K8S_DIR="$(dirname "$0")/k8s" echo "======================================================" echo " Stopping K8s Todo App" echo "======================================================" # Delete in reverse creation order to avoid dependency issues echo "" echo "[1/5] Deleting Deployment..." kubectl delete -f "$K8S_DIR/deployment.yaml" --ignore-not-found=true echo " ✓ Deployment deleted" echo "" echo "[2/5] Deleting Services..." kubectl delete -f "$K8S_DIR/service.yaml" --ignore-not-found=true echo " ✓ Services deleted" echo "" echo "[3/5] Deleting StatefulSet, PVC, Secret and PV..." kubectl delete -f "$K8S_DIR/statefulset.yaml" --ignore-not-found=true echo " ✓ StatefulSet, PVC, Secret and PV deleted" echo "" echo "[4/5] Deleting ConfigMap..." kubectl delete -f "$K8S_DIR/configmap.yaml" --ignore-not-found=true echo " ✓ ConfigMap deleted" echo "" echo "[5/5] Deleting Namespace (this removes any remaining objects)..." kubectl delete -f "$K8S_DIR/namespace.yaml" --ignore-not-found=true echo " ✓ Namespace deleted" echo "" echo "======================================================" echo " Application stopped and all objects removed." echo " Database files remain at /mnt/data/postgres inside minikube." echo " To fully reset: minikube ssh -- 'sudo rm -rf /mnt/data/postgres'" echo "======================================================"