Skip to content

Commit ad3e89b

Browse files
authored
Autolab config update and fixing env variable output (#75)
1 parent db74747 commit ad3e89b

File tree

4 files changed

+46
-15
lines changed

4 files changed

+46
-15
lines changed

auto-lab.sh

+26-6
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ kubectl_apply
100100
create_nsg_rule_aks
101101

102102
echo
103-
echo "Lab2 & Lab3 infrastructure creation completed!"
103+
echo "Lab3 infrastructure creation completed!"
104104
echo
105105
}
106106

@@ -114,7 +114,7 @@ upload_archive
114114
update_hosts_file
115115

116116
echo
117-
echo "Lab2, Lab3 & Lab4 infrastructure creation completed!"
117+
echo "Lab4 infrastructure creation completed!"
118118
echo
119119
}
120120

@@ -155,14 +155,25 @@ echo "All infrastructure creation completed!"
155155
echo
156156
}
157157

158+
## LabTest
159+
function labtest(){
160+
azcli_test
161+
nginx_ext_test
162+
nginx_jwt_test
163+
164+
echo
165+
echo "Testing of lab conditions completed."
166+
echo
167+
}
168+
158169
# How to use the script
159170
DELETE=0
160-
OPTSTRING=":adehl:"
171+
OPTSTRING=":adehtl:n:"
161172

162173
function usage {
163174
cat <<EOT
164175
Usage:
165-
$NAME [-l <number>] [-a] [-d] [-h]
176+
$NAME [-l <number>] [-n MY_NAME][-a] [-d] [-h]
166177
Purpose:
167178
In Azure, build the labs for the NGINXaaS workshop.
168179
- Must have valid NGINX Plus JWT in Lab 3 folder.
@@ -175,11 +186,13 @@ Inputs:
175186
on top of each other (there are dependencies), so prior labs will be
176187
built.
177188
-a
178-
Build lab2, 3 and 4. All labs will be built sequentially.
189+
Build lab2, 3 or 4. All labs should be built sequentially.
179190
-d
180191
Delete the whole resource group (will ask for confirmation)
181192
-h
182193
Display this usage help text
194+
-t
195+
Test basic environment setup to be sure the script can run.
183196
184197
EOT
185198
}
@@ -202,10 +215,14 @@ while getopts ${OPTSTRING} opt; do
202215
echo "Option -e was triggered, building everything!"
203216
LAB=99
204217
;;
205-
h)
218+
h)
206219
echo "Option -h was triggered, running usage"
207220
USAGE=1
208221
;;
222+
t)
223+
echo "Option -t was triggered, running tests"
224+
TEST=1
225+
;;
209226
:)
210227
echo "Option -${OPTARG} requires an argument."
211228
exit 1
@@ -249,6 +266,9 @@ function main() {
249266
elif [[ $USAGE == 1 ]]; then
250267
clear
251268
usage
269+
elif [[ $TEST == 1 ]]; then
270+
clear
271+
labtest
252272
else
253273
echo "Nothing to do!"
254274
fi

functions.sh

+13-2
Original file line numberDiff line numberDiff line change
@@ -810,8 +810,19 @@ az group delete --name $MY_RESOURCEGROUP
810810
}
811811

812812
function display(){
813-
# Display more variable values that we used in the script.
814-
# Per instructions, copy output and pastr back to teh terminal so we have these moving forward.
813+
# Display more variable values that we used in the script.
814+
# Per instructions, copy output and paste back to the terminal so we have these moving forward.
815+
816+
export MY_N4A_ID=$(az nginx deployment show --resource-group $MY_RESOURCEGROUP --name nginx4a --query id --output tsv)
817+
export MY_LOG_ANALYTICS_ID=`az monitor log-analytics workspace show --resource-group $MY_RESOURCEGROUP --name n4a-loganalytics --query id --output tsv`
818+
kubectl config use-context n4a-aks1
819+
export AKS1_NIC=$(kubectl get pods -n nginx-ingress -o jsonpath='{.items[0].metadata.name}')
820+
kubectl config use-context n4a-aks2
821+
export AKS2_NIC=$(kubectl get pods -n nginx-ingress -o jsonpath='{.items[0].metadata.name}')
822+
export MY_AZURE_PUBLIC_IP=$(az network public-ip show --resource-group $MY_RESOURCEGROUP --name $MY_AZURE_PUBLIC_IP_NAME --query ipAddress --output tsv)
823+
export UBUNTU_VM_PUBLICIP=$(az vm show -d -g $MY_RESOURCEGROUP -n n4a-ubuntuvm --query publicIps -o tsv)
824+
export WINDOWS_VM_PUBLICIP=$(az vm show -d -g $MY_RESOURCEGROUP -n n4a-windowsvm --query publicIps -o tsv)
825+
815826
cat <<EOI
816827
export MY_N4A_ID=$MY_N4A_ID
817828
export MY_LOG_ANALYTICS_ID=$MY_LOG_ANALYTICS_ID

n4a-configs/etc/nginx/conf.d/aks1-upstreams.conf

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ upstream aks1_ingress {
66
# from nginx-ingress NodePort Service / aks Node names
77
# Note: change servers to match
88
#
9-
server aks-nodepool1-_AKS1_NODES_-vmss000000:32090; #aks1 node1
10-
server aks-nodepool1-_AKS1_NODES_-vmss000001:32090; #aks1 node2
11-
server aks-nodepool1-_AKS1_NODES_-vmss000002:32090; #aks1 node3
9+
server aks-nodepool1-_AKS1_NODES_-vmss000000:32080; #aks1 node1
10+
server aks-nodepool1-_AKS1_NODES_-vmss000001:32080; #aks1 node2
11+
server aks-nodepool1-_AKS1_NODES_-vmss000002:32080; #aks1 node3
1212

1313
keepalive 32;
1414

n4a-configs/etc/nginx/conf.d/aks2-upstreams.conf

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ upstream aks2_ingress {
66
# from nginx-ingress NodePort Service / aks Node names
77
# Note: change servers to match
88
#
9-
server aks-nodepool1-_AKS2_NODES_-vmss000000:32090; #aks2 node1
10-
server aks-nodepool1-_AKS2_NODES_-vmss000001:32090; #aks2 node2
11-
server aks-nodepool1-_AKS2_NODES_-vmss000002:32090; #aks2 node3
12-
server aks-nodepool1-_AKS2_NODES_-vmss000003:32090; #aks2 node4
9+
server aks-nodepool1-_AKS2_NODES_-vmss000000:32080; #aks2 node1
10+
server aks-nodepool1-_AKS2_NODES_-vmss000001:32080; #aks2 node2
11+
server aks-nodepool1-_AKS2_NODES_-vmss000002:32080; #aks2 node3
12+
server aks-nodepool1-_AKS2_NODES_-vmss000003:32080; #aks2 node4
1313

1414
keepalive 32;
1515

0 commit comments

Comments
 (0)