Spaces:
Paused
Paused
set -e | |
# Yuga Planner Kubernetes Cleanup Script | |
# This script removes all Kubernetes resources created by the deployment | |
echo "π§Ή Cleaning up Yuga Planner Kubernetes deployment..." | |
# Check if kubectl is available | |
if ! command -v kubectl &> /dev/null; then | |
echo "β Error: kubectl is required but not installed." | |
exit 1 | |
fi | |
# Check if we're in the correct directory (project root) | |
if [ ! -f "deploy/kubernetes.yaml" ]; then | |
echo "β Error: kubernetes.yaml not found. Please run this script from the project root." | |
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 "βΉοΈ No Yuga Planner resources found in the current namespace." | |
return 1 | |
fi | |
return 0 | |
} | |
# Check if any resources exist | |
if ! check_resources; then | |
echo "β Nothing to clean up." | |
exit 0 | |
fi | |
# Show what will be deleted | |
echo "π Found the following Yuga Planner resources:" | |
kubectl get deployment,service,secret,configmap -l app=yuga-planner 2>/dev/null || true | |
# Confirm deletion | |
read -p "β Are you sure you want to delete these resources? (y/N): " -n 1 -r | |
echo | |
if [[ ! $REPLY =~ ^[Yy]$ ]]; then | |
echo "β Cleanup cancelled." | |
exit 0 | |
fi | |
echo "ποΈ Deleting Kubernetes resources..." | |
# Delete resources by label selector (safer approach) | |
echo " β’ Deleting deployment..." | |
kubectl delete deployment -l app=yuga-planner --ignore-not-found=true | |
echo " β’ Deleting service..." | |
kubectl delete service -l app=yuga-planner --ignore-not-found=true | |
echo " β’ Deleting secrets..." | |
kubectl delete secret -l app=yuga-planner --ignore-not-found=true | |
echo " β’ Deleting configmaps..." | |
kubectl delete configmap -l app=yuga-planner --ignore-not-found=true | |
echo "β Cleanup complete!" | |
echo "π Verify cleanup: kubectl get all -l app=yuga-planner" | |