Skip to content

Commit 88fde6b

Browse files
apcurriersdutta9
andauthored
Autolab stable version merge to main. (#71)
* Adding autolab files for testing * Adding everything flag and removing lab1 build * Updated usage * Updated tar function for OS X doublefile * minor updates * Modified the lab creation options. --------- Co-authored-by: Shouvik <[email protected]>
1 parent d3c3d06 commit 88fde6b

15 files changed

+1371
-0
lines changed

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,8 @@ Thumbs.db
2424
#Kubernetes-ingress#
2525
####################
2626
kubernetes-ingress
27+
28+
# Deployment Script Artifacts
29+
#############################
30+
n4a-configs.tar.gz
31+
package.json

auto-lab.sh

+278
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,278 @@
1+
#!/usr/bin/env bash
2+
3+
##########################################################################
4+
# #
5+
# Id: auto-lab.sh Release 0.9.0 2024/08/09 09:00:00 acurrier #
6+
# (C) Copyright F5, Inc. 2024 #
7+
# #
8+
# auto-lab.sh - Pre-build environments for Azure labs on OS X #
9+
# Author: Adam Currier <[email protected]> #
10+
# Version: 0.6.0, Date: 2024/08/09 09:00:00 #
11+
# #
12+
##########################################################################
13+
14+
#-------------------------------------------------------------------------
15+
# Todo
16+
#-------------------------------------------------------------------------
17+
# Need to log things to track what is going on. Use tee or redirects.
18+
# Could ask for owner and location values - add this via prompt.
19+
#
20+
21+
#-------------------------------------------------------------------------
22+
# Set Variables
23+
#-------------------------------------------------------------------------
24+
NAME="auto-lab.sh"
25+
VERSION="1"
26+
LOG_FILE="autolab.log" # not used yet, but will be soon
27+
#export LOCATION=centralus # can be changed to your location
28+
export LOCATION=eastus # can be changed to your location
29+
30+
# On OS X, you can pull your username. You can also set it yourself for use in the script:
31+
# export OWNER=<your name>
32+
export OWNER=$(whoami)
33+
34+
#-------------------------------------------------------------------------
35+
# Sourced files
36+
#-------------------------------------------------------------------------
37+
source functions.sh
38+
39+
#-------------------------------------------------------------------------
40+
# add some basic best practice settings to this script:
41+
#-------------------------------------------------------------------------
42+
set -o errexit
43+
#set -o nounset
44+
set -o pipefail
45+
46+
#-------------------------------------------------------------------------
47+
# Let's add some debugging to the script.
48+
#-------------------------------------------------------------------------
49+
if [ "${_DEBUG:-}" == "true" ]; then
50+
set -x
51+
fi
52+
53+
#-------------------------------------------------------------------------
54+
# Lab Functions:
55+
#-------------------------------------------------------------------------
56+
57+
## Lab 1
58+
function lab1(){
59+
cleanup
60+
create_resource_group
61+
create_vnet
62+
create_security_group
63+
create_security_group_rules
64+
create_subnets
65+
create_public_ip
66+
create_identity
67+
create_n4a_deployment
68+
create_analytics
69+
70+
echo
71+
echo "Lab1 infrastructure creation completed!"
72+
echo
73+
}
74+
75+
## Lab 2
76+
function lab2(){
77+
cleanup
78+
create_ubuntu_vm
79+
secure_port_22
80+
create_windows_vm
81+
secure_port_3389
82+
83+
echo
84+
echo "Lab2 infrastructure creation completed!"
85+
echo
86+
}
87+
88+
## Lab 3
89+
function lab3(){
90+
cleanup
91+
create_ubuntu_vm
92+
secure_port_22
93+
create_windows_vm
94+
secure_port_3389
95+
create_aks_cluster1
96+
clone_repo
97+
create_nic_resources1
98+
create_jwt1
99+
deploy_nic1
100+
create_aks_cluster2
101+
create_nic_resources2
102+
create_jwt2
103+
deploy_nic2
104+
kubectl_apply
105+
create_nsg_rule_aks
106+
107+
echo
108+
echo "Lab2 & Lab3 infrastructure creation completed!"
109+
echo
110+
}
111+
112+
## Lab 4
113+
function lab4(){
114+
cleanup
115+
create_ubuntu_vm
116+
secure_port_22
117+
create_windows_vm
118+
secure_port_3389
119+
create_aks_cluster1
120+
clone_repo
121+
create_nic_resources1
122+
create_jwt1
123+
deploy_nic1
124+
create_aks_cluster2
125+
create_nic_resources2
126+
create_jwt2
127+
deploy_nic2
128+
kubectl_apply
129+
create_nsg_rule_aks
130+
deploy_apps
131+
get_node_ids
132+
create_archive
133+
upload_archive
134+
update_hosts_file
135+
136+
echo
137+
echo "Lab2, Lab3 & Lab4 infrastructure creation completed!"
138+
echo
139+
}
140+
141+
function lab99(){
142+
cleanup
143+
create_resource_group
144+
create_vnet
145+
create_security_group
146+
create_security_group_rules
147+
create_subnets
148+
create_public_ip
149+
create_identity
150+
create_n4a_deployment
151+
create_analytics
152+
create_ubuntu_vm
153+
secure_port_22
154+
create_windows_vm
155+
secure_port_3389
156+
create_aks_cluster1
157+
clone_repo
158+
create_nic_resources1
159+
create_jwt1
160+
deploy_nic1
161+
create_aks_cluster2
162+
create_nic_resources2
163+
create_jwt2
164+
deploy_nic2
165+
kubectl_apply
166+
create_nsg_rule_aks
167+
deploy_apps
168+
get_node_ids
169+
create_archive
170+
upload_archive
171+
update_hosts_file
172+
173+
echo
174+
echo "All infrastructure creation completed!"
175+
echo
176+
}
177+
178+
# How to use the script
179+
DELETE=0
180+
OPTSTRING=":adehl:"
181+
182+
function usage {
183+
cat <<EOT
184+
Usage:
185+
$NAME [-l <number>] [-a] [-d] [-h]
186+
Purpose:
187+
In Azure, build the labs for the NGINXaaS workshop.
188+
- Must have valid NGINX Plus JWT in Lab 3 folder.
189+
- Azure CLI must be installed and logged in.
190+
- Currently tested on OS X
191+
192+
Inputs:
193+
-l NUMBER
194+
This option allows you to choose which lab to build. Labs are built
195+
on top of each other (there are dependencies), so prior labs will be
196+
built.
197+
-a
198+
Build lab2, 3 and 4. All labs will be built sequentially.
199+
-d
200+
Delete the whole resource group (will ask for confirmation)
201+
-h
202+
Display this usage help text
203+
204+
EOT
205+
}
206+
207+
while getopts ${OPTSTRING} opt; do
208+
case ${opt} in
209+
l)
210+
echo "Option -l was triggered, Argument: ${OPTARG}"
211+
LAB=${OPTARG}
212+
;;
213+
a)
214+
echo "Option -a was triggered, running setup"
215+
LAB=4
216+
;;
217+
d)
218+
echo "Option -d was triggered, running deletion"
219+
DELETE=1
220+
;;
221+
e)
222+
echo "Option -e was triggered, building everything!"
223+
LAB=99
224+
;;
225+
h)
226+
echo "Option -h was triggered, running usage"
227+
USAGE=1
228+
;;
229+
:)
230+
echo "Option -${OPTARG} requires an argument."
231+
exit 1
232+
;;
233+
?)
234+
echo "Invalid option: -${OPTARG}."
235+
exit 1
236+
;;
237+
esac
238+
done
239+
240+
## Execute the functions for setup, etc.
241+
242+
function main() {
243+
if [[ $LAB == 1 ]]; then
244+
clear
245+
setup
246+
lab1
247+
elif [[ $LAB == 2 ]]; then
248+
clear
249+
setup
250+
lab2
251+
elif [[ $LAB == 3 ]]; then
252+
clear
253+
setup
254+
lab3
255+
elif [[ $LAB == 4 ]]; then
256+
clear
257+
setup
258+
lab4
259+
display
260+
elif [[ $LAB == 99 ]]; then
261+
clear
262+
setup
263+
lab99
264+
display
265+
elif [[ $DELETE == 1 ]]; then
266+
clear
267+
setup
268+
delete
269+
elif [[ $USAGE == 1 ]]; then
270+
clear
271+
usage
272+
else
273+
echo "Nothing to do!"
274+
fi
275+
276+
}
277+
278+
main

0 commit comments

Comments
 (0)