-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshutdown.sh
More file actions
executable file
·80 lines (64 loc) · 2.34 KB
/
shutdown.sh
File metadata and controls
executable file
·80 lines (64 loc) · 2.34 KB
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
#!/usr/bin/env bash
set -euo pipefail
# Project: RKE2 HA Kubernetes on AWS
# Description:
# - Destroys all AWS infrastructure provisioned for the cluster
# - Removes control planes, workers, load balancer, networking
#
# Script: shutdown.sh
# Purpose:
# - Completely tears down the RKE2 HA cluster
# - Removes all Terraform-managed resources
#
# ⚠️ WARNING
# - This action is IRREVERSIBLE
# - All cluster data will be lost
#
# Built by: Abhiram
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# When piped through curl, ROOT_DIR resolves to the current directory.
# Fall back to the standard install location used by install.sh.
if [[ ! -d "$ROOT_DIR/terraform" ]]; then
INSTALL_DIR="$HOME/RKE2-Kubernetes-HA-AWS"
if [[ ! -d "$INSTALL_DIR/terraform" ]]; then
echo "[ERROR] No installation found at $INSTALL_DIR — run install.sh first"
exit 1
fi
exec bash "$INSTALL_DIR/shutdown.sh"
fi
# Logging helpers
BLUE="\033[1;34m"
GREEN="\033[1;32m"
YELLOW="\033[1;33m"
RED="\033[1;31m"
RESET="\033[0m"
log_info() { echo -e "${BLUE}[INFO]${RESET} $1"; }
log_warn() { echo -e "${YELLOW}[WARN]${RESET} $1"; }
log_error() { echo -e "${RED}[ERROR]${RESET} $1"; }
log_success() { echo -e "${GREEN}[SUCCESS]${RESET} $1"; }
separator() {
echo -e "\n${BLUE}════════════════════════════════════════════════════════════${RESET}"
}
# Project banner (destructive warning)
separator
echo -e "${RED}RKE2 HA Kubernetes on AWS — DESTRUCTION MODE${RESET}"
echo -e "${RED}--------------------------------------------${RESET}"
echo -e "${YELLOW}• This script will DESTROY all cluster infrastructure${RESET}"
echo -e "${YELLOW}• All EC2 instances, networking, and state will be removed${RESET}"
echo -e "${YELLOW}• This action CANNOT be undone${RESET}"
echo
echo -e "Built by: ${GREEN}Abhiram${RESET}"
separator
# Destroy infrastructure
log_warn "Destroying entire RKE2 HA cluster and infrastructure"
log_warn "This will remove ALL Terraform-managed resources"
separator
log_info "Running Terraform destroy"
separator
cd "$ROOT_DIR/terraform"
terraform destroy -auto-approve
# Destruction complete
separator
log_success "Infrastructure destroyed successfully"
log_success "All cluster resources have been removed"
separator