forked from orcasecurity-research/kte
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkte.sh
executable file
·196 lines (189 loc) · 4.61 KB
/
kte.sh
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
#!/bin/bash
# Function to display usage information
function display_help {
echo "Usage: ./kte.sh <command> [options]"
echo ""
echo "Commands:"
echo " apply Execute the apply script"
echo " state Execute the state script"
echo " destroy [OPTIONS] Execute the destroy script with options"
echo " tunnel [OPTIONS] Execute the tunnel script with options"
echo " ai [OPTIONS] Execute the ai script with options"
echo
echo "Options:"
echo " -h, --help Display this help manual and exit."
echo
echo "Examples:"
echo " ./kte.sh apply"
}
function display_destroy_help {
echo "Usage: ./kte.sh destroy [options]"
echo ""
echo "Options:"
echo " --addons Destroy addons."
echo " --clusters Destroy clusters."
echo " -h, --help Display this help manual and exit."
echo ""
echo "Examples:"
echo " ./kte.sh destroy"
echo " ./kte.sh destroy --clusters"
}
function display_tunnel_help {
echo "Usage: ./kte.sh tunnel [options]"
echo ""
echo "Options:"
echo " eks tunnel through eks."
echo " gke tunnel through gke."
echo " aks tunnel through aks."
echo " -h, --help Display this help manual and exit."
echo ""
echo "Examples:"
echo " ./kte.sh tunnel eks"
}
function display_ai_help {
echo "Usage: ./kte.sh ai [options]"
echo ""
echo "Options:"
echo " setup <vendor> setup AI and RAG infrastructure for a specific vendor."
echo " prompt start a prompt and ask questions about your k8s findings."
echo " -h, --help Display this help manual and exit."
echo ""
echo "Examples:"
echo " ./kte.sh ai setup eks"
echo " ./kte.sh ai prompt"
}
if [ $# -eq 0 ]; then
display_help
exit 1
fi
destroy_clusters=false
destroy_addons=false
case "$1" in
apply )
shift
while [[ $# -gt 0 ]]; do
case "$1" in
* )
echo "Invalid option: $1"
display_help
exit 1
;;
esac
done
./scripts/apply.sh
;;
state )
shift
while [[ $# -gt 0 ]]; do
case "$1" in
* )
echo "Invalid option: $1"
display_help
exit 1
;;
esac
done
./scripts/state.sh
;;
destroy )
shift
while [[ $# -gt 0 ]]; do
case "$1" in
--clusters )
destroy_clusters=true
shift
;;
--addons )
destroy_addons=true
shift
;;
-h | --help )
display_destroy_help
exit 0
;;
* )
echo "Invalid option: $1"
display_destroy_help
exit 1
;;
esac
done
if [[ $destroy_clusters == true && $destroy_addons == true ]]; then
./scripts/destroy.sh --addons --clusters
elif [[ $destroy_addons == true ]]; then
./scripts/destroy.sh --addons
elif [[ $destroy_clusters == true ]]; then
./scripts/destroy.sh --clusters
else
./scripts/destroy.sh
fi
;;
tunnel )
shift
case "$1" in
eks )
./scripts/tunnel.sh eks
;;
gke )
./scripts/tunnel.sh gke
;;
aks )
./scripts/tunnel.sh aks
;;
-h | --help )
display_tunnel_help
exit 0
;;
* )
echo "Invalid option: $1"
display_tunnel_help
exit 1
;;
esac
;;
ai )
shift
case "$1" in
setup )
shift
case "$1" in
eks )
export PYTHONPATH=$PWD; poetry run python ai/main.py setup eks
;;
gke )
export PYTHONPATH=$PWD; poetry run python ai/main.py setup gke
;;
aks )
export PYTHONPATH=$PWD; poetry run python ai/main.py setup aks
;;
* )
echo "Invalid option: $1"
display_ai_help
exit 1
;;
esac
;;
prompt )
export PYTHONPATH=$PWD; poetry run python ai/main.py prompt
;;
-h | --help )
display_ai_help
exit 0
;;
* )
echo "Invalid option: $1"
display_ai_help
exit 1
;;
esac
;;
-h | --help )
display_help
exit 0
;;
* )
echo "Invalid option: $1"
display_help
exit 1
;;
esac