Spaces:
Paused
Paused
File size: 3,374 Bytes
ae122c6 186edf4 ae122c6 186edf4 ae122c6 186edf4 ae122c6 186edf4 ae122c6 186edf4 ae122c6 186edf4 ae122c6 186edf4 ae122c6 186edf4 ae122c6 186edf4 ae122c6 186edf4 ae122c6 186edf4 ae122c6 186edf4 ae122c6 186edf4 ae122c6 186edf4 ae122c6 186edf4 ae122c6 186edf4 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
#!/bin/bash
set -e
# Colors and formatting
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
CYAN='\033[0;36m'
BOLD='\033[1m'
RESET='\033[0m'
# Yuga Planner Kubernetes Cleanup Script
echo -e "${BOLD}π§Ή Yuga Planner - Kubernetes Cleanup${RESET}"
echo -e "${CYAN}ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ${RESET}"
# Check if kubectl is available
if ! command -v kubectl &> /dev/null; then
echo -e "${RED}β Error: kubectl is required but not installed${RESET}"
exit 1
fi
# Check if we're in the correct directory (project root)
if [ ! -f "deploy/kubernetes.yaml" ]; then
echo -e "${RED}β Error: kubernetes.yaml not found${RESET}"
echo -e "${YELLOW}π‘ Please run this script from the project root${RESET}"
exit 1
fi
# Function to check if resources exist
check_resources() {
local resource_exists=false
if kubectl get deployment yuga-planner &> /dev/null; then
resource_exists=true
fi
if kubectl get service yuga-planner-service &> /dev/null; then
resource_exists=true
fi
if kubectl get secret yuga-planner-secrets &> /dev/null; then
resource_exists=true
fi
if kubectl get configmap yuga-planner-config &> /dev/null; then
resource_exists=true
fi
if [ "$resource_exists" = false ]; then
echo -e "${BLUE}βΉοΈ No Yuga Planner resources found in the current namespace${RESET}"
return 1
fi
return 0
}
# Check if any resources exist
echo -e "${BLUE}π Scanning for Yuga Planner resources...${RESET}"
if ! check_resources; then
echo -e "${GREEN}β
Nothing to clean up${RESET}"
exit 0
fi
# Show what will be deleted
echo -e "${YELLOW}π Found the following Yuga Planner resources:${RESET}"
kubectl get deployment,service,secret,configmap -l app=yuga-planner 2>/dev/null || true
# Confirm deletion
echo ""
echo -e "${BOLD}β οΈ Warning: This will permanently delete all Yuga Planner resources${RESET}"
read -p "$(echo -e "${YELLOW}β Are you sure you want to continue? (y/N): ${RESET}")" -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo -e "${BLUE}β Cleanup cancelled${RESET}"
exit 0
fi
echo -e "${RED}ποΈ Deleting Kubernetes resources...${RESET}"
# Delete resources by label selector (safer approach)
echo -e " ${CYAN}β’ Deleting deployment...${RESET}"
kubectl delete deployment -l app=yuga-planner --ignore-not-found=true
echo -e " ${CYAN}β’ Deleting service...${RESET}"
kubectl delete service -l app=yuga-planner --ignore-not-found=true
echo -e " ${CYAN}β’ Deleting secrets...${RESET}"
kubectl delete secret -l app=yuga-planner --ignore-not-found=true
echo -e " ${CYAN}β’ Deleting configmaps...${RESET}"
kubectl delete configmap -l app=yuga-planner --ignore-not-found=true
echo ""
echo -e "${GREEN}β
Cleanup complete!${RESET}"
echo -e "${CYAN}ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ${RESET}"
echo -e "${BOLD}π Verification:${RESET}"
echo -e " Check remaining: ${GREEN}kubectl get all -l app=yuga-planner${RESET}"
|