betelgeusebytes/k8s/observability-stack/cleanup.sh

63 lines
2.1 KiB
Bash
Executable File

#!/bin/bash
set -e
echo "=================================================="
echo "Removing Observability Stack from Kubernetes"
echo "=================================================="
echo ""
RED='\033[0;31m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
echo -e "${RED}WARNING: This will delete all observability data!${NC}"
echo ""
read -p "Are you sure you want to continue? (yes/no): " confirm
if [ "$confirm" != "yes" ]; then
echo "Cleanup cancelled."
exit 0
fi
echo -e "${YELLOW}Removing Ingress...${NC}"
kubectl delete -f 20-grafana-ingress.yaml --ignore-not-found
echo -e "${YELLOW}Removing Deployments and DaemonSets...${NC}"
kubectl delete -f 16-node-exporter.yaml --ignore-not-found
kubectl delete -f 15-kube-state-metrics.yaml --ignore-not-found
kubectl delete -f 14-alloy.yaml --ignore-not-found
kubectl delete -f 13-grafana.yaml --ignore-not-found
kubectl delete -f 12-tempo.yaml --ignore-not-found
kubectl delete -f 11-loki.yaml --ignore-not-found
kubectl delete -f 10-prometheus.yaml --ignore-not-found
echo -e "${YELLOW}Removing RBAC...${NC}"
kubectl delete -f 08-rbac.yaml --ignore-not-found
echo -e "${YELLOW}Removing ConfigMaps...${NC}"
kubectl delete -f 07-grafana-datasources.yaml --ignore-not-found
kubectl delete -f 06-alloy-config.yaml --ignore-not-found
kubectl delete -f 05-tempo-config.yaml --ignore-not-found
kubectl delete -f 04-loki-config.yaml --ignore-not-found
kubectl delete -f 03-prometheus-config.yaml --ignore-not-found
echo -e "${YELLOW}Removing PVCs...${NC}"
kubectl delete -f 02-persistent-volume-claims.yaml --ignore-not-found
echo -e "${YELLOW}Removing PVs...${NC}"
kubectl delete -f 01-persistent-volumes.yaml --ignore-not-found
echo -e "${YELLOW}Removing Namespace...${NC}"
kubectl delete -f 00-namespace.yaml --ignore-not-found
echo ""
echo -e "${RED}=================================================="
echo "Cleanup Complete!"
echo "==================================================${NC}"
echo ""
echo "Data directories on hetzner-2 node are preserved."
echo "To remove them, run on the node:"
echo " sudo rm -rf /mnt/local-ssd/{prometheus,loki,tempo,grafana}"
echo ""