-
Notifications
You must be signed in to change notification settings - Fork 65
152 lines (117 loc) · 4.62 KB
/
aks_tomcat_README_md.yml
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
on:
schedule:
- cron: '0 18 * * 4'
workflow_dispatch:
name: 'aks/tomcat/README.md'
jobs:
validate:
runs-on: 'ubuntu-latest'
steps:
- uses: 'azure/login@v1'
with:
subscription-id: '${{ secrets.AZURE_SUBSCRIPTION_ID }}'
client-id: '${{ secrets.AZURE_CLIENT_ID }}'
tenant-id: '${{ secrets.AZURE_TENANT_ID }}'
- uses: 'actions/checkout@v3'
- run: |
if [[ -z $REGION ]]; then
export REGION=westus2
fi
if [[ -z $REGION ]]; then
export REGION=westus
fi
if [[ -z $RESOURCE_GROUP ]]; then
export RESOURCE_GROUP=joazrg-$RANDOM
echo "Using '"$RESOURCE_GROUP"' as resource group"
fi
az group create --name $RESOURCE_GROUP --location $REGION
if [[ -z $AKS ]]; then
export AKS=aks-$RANDOM
echo ---------------------------------------------------------------------
echo Creating AKS cluster - $AKS
echo ---------------------------------------------------------------------
az aks create --name $AKS --resource-group $RESOURCE_GROUP --generate-ssh-keys --verbose
sleep 120
fi
cd aks/create-kube-config
az aks get-credentials --resource-group $RESOURCE_GROUP --name $AKS --admin --file config
export KUBECONFIG=$PWD/config
cd ../..
if [[ -z $REGION ]]; then
export REGION=westus
fi
if [[ -z $REGION ]]; then
export REGION=westus
fi
if [[ -z $RESOURCE_GROUP ]]; then
export RESOURCE_GROUP=joazrg-$RANDOM
echo "Using '"$RESOURCE_GROUP"' as resource group"
fi
az group create --name $RESOURCE_GROUP --location $REGION
if [[ -z $ACR_NAME ]]; then
export ACR_NAME=joazcr$RANDOM
fi
az acr create \
--name $ACR_NAME \
--resource-group $RESOURCE_GROUP \
--sku Basic \
--admin-enabled true
cd acr/tomcat
mvn package
export ACR_TOMCAT_IMAGE=tomcat:latest
az acr build --registry $ACR_NAME --image $ACR_TOMCAT_IMAGE .
cd ../..
if [[ -z $REGION ]]; then
export REGION=westus2
fi
if [[ -z $REGION ]]; then
export REGION=westus
fi
if [[ -z $RESOURCE_GROUP ]]; then
export RESOURCE_GROUP=joazrg-$RANDOM
echo "Using '"$RESOURCE_GROUP"' as resource group"
fi
az group create --name $RESOURCE_GROUP --location $REGION
if [[ -z $AKS ]]; then
export AKS=aks-$RANDOM
echo ---------------------------------------------------------------------
echo Creating AKS cluster - $AKS
echo ---------------------------------------------------------------------
az aks create --name $AKS --resource-group $RESOURCE_GROUP --generate-ssh-keys --verbose
sleep 120
fi
if [[ -z $REGION ]]; then
export REGION=westus
fi
if [[ -z $REGION ]]; then
export REGION=westus
fi
if [[ -z $RESOURCE_GROUP ]]; then
export RESOURCE_GROUP=joazrg-$RANDOM
echo "Using '"$RESOURCE_GROUP"' as resource group"
fi
az group create --name $RESOURCE_GROUP --location $REGION
if [[ -z $ACR_NAME ]]; then
export ACR_NAME=joazcr$RANDOM
fi
az acr create \
--name $ACR_NAME \
--resource-group $RESOURCE_GROUP \
--sku Basic \
--admin-enabled true
az aks update --name $AKS --resource-group $RESOURCE_GROUP --attach-acr $ACR_NAME
cd aks/tomcat
sed -i "s/ACR/$ACR_NAME/g" deployment.yml
kubectl apply -f deployment.yml
sleep 240
export URL=http://$(kubectl get service/tomcat --output jsonpath="{.status.loadBalancer.ingress[0].ip}")
export RESULT=$(curl $URL)
az group delete --name $RESOURCE_GROUP --yes || true
if [[ "$RESULT" != *"custom Tomcat"* ]]; then
echo "Response did not contain 'custom Tomcat'"
exit 1
fi
cd ../..
permissions:
contents: 'read'
id-token: 'write'