-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkill-minikube.sh
More file actions
executable file
·145 lines (128 loc) · 4.01 KB
/
kill-minikube.sh
File metadata and controls
executable file
·145 lines (128 loc) · 4.01 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#!/bin/bash
set -e
# Source shared utilities
if [ -z "$SCRIPT_DIR" ]; then
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
fi
# If SCRIPT_DIR is the root directory, we need to source from scripts subdirectory
if [ "$(basename "$SCRIPT_DIR")" = "scripts" ]; then
source "$SCRIPT_DIR/utils.sh"
else
source "$SCRIPT_DIR/scripts/utils.sh"
fi
show_script_header "Minikube Cleanup" "Killing minikube for Apollo Supergraph cleanup"
# Function to show usage
show_usage() {
echo "Usage: $0 [OPTIONS]"
echo ""
echo "Options:"
echo " -s, --stop-only Stop minikube but keep the cluster (can be restarted)"
echo " -d, --delete Stop and delete the minikube cluster completely (default)"
echo " -f, --force Force deletion without confirmation"
echo " -h, --help Show this help message"
echo ""
echo "Examples:"
echo " $0 # Stop and delete cluster (default)"
echo " $0 --stop-only # Stop but keep cluster"
echo " $0 --delete # Stop and delete cluster"
echo " $0 --force # Force delete without confirmation"
echo " $0 -s # Stop only (short form)"
echo " $0 -d # Delete (short form)"
echo " $0 -f # Force delete (short form)"
}
# Default values
STOP_ONLY=false
DELETE_CLUSTER=true
FORCE_DELETE=false
# Parse command line arguments
while [[ $# -gt 0 ]]; do
case $1 in
-s|--stop-only)
STOP_ONLY=true
DELETE_CLUSTER=false
shift
;;
-d|--delete)
STOP_ONLY=false
DELETE_CLUSTER=true
shift
;;
-f|--force)
FORCE_DELETE=true
shift
;;
-h|--help)
show_usage
exit 0
;;
*)
print_error "Unknown option: $1"
show_usage
exit 1
;;
esac
done
# Check if minikube is installed
if ! minikube_is_installed; then
print_error "minikube is not installed. Nothing to kill."
exit 1
fi
print_success "minikube is installed"
# Check if minikube cluster exists
if ! minikube status &> /dev/null; then
print_warning "No minikube cluster found. Nothing to kill."
exit 0
fi
# Show current status
print_status "Current minikube status:"
minikube status
echo ""
# Determine action based on options
if [ "$STOP_ONLY" = true ]; then
print_status "Stopping minikube cluster (keeping data)..."
minikube stop
print_success "minikube stopped successfully!"
echo ""
echo "📋 Stop Summary:"
echo " - minikube cluster stopped"
echo " - Cluster data preserved"
echo " - Can be restarted with: minikube start"
echo ""
echo "🔍 Useful commands:"
echo " - Start minikube: minikube start"
echo " - Delete cluster: minikube delete"
echo " - View status: minikube status"
else
# Delete cluster
if [ "$FORCE_DELETE" = false ]; then
echo ""
print_warning "This will completely delete the minikube cluster and all its data!"
echo "This action cannot be undone."
echo ""
read -p "Are you sure you want to continue? (y/N): " -n 1 -r
echo ""
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
print_status "Operation cancelled."
exit 0
fi
fi
print_status "Stopping minikube cluster..."
minikube stop
print_status "Deleting minikube cluster..."
minikube delete
print_success "minikube cluster deleted successfully!"
echo ""
echo "📋 Deletion Summary:"
echo " - minikube cluster stopped"
echo " - All cluster data deleted"
echo " - All containers removed"
echo " - All configurations cleared"
echo ""
echo "🚀 To start fresh:"
echo " ./setup-minikube.sh"
echo ""
echo "🔍 Useful commands:"
echo " - Setup minikube: ./setup-minikube.sh"
echo " - Check if minikube exists: minikube status"
fi
show_script_footer "Minikube Cleanup"