-
Notifications
You must be signed in to change notification settings - Fork 0
309 lines (233 loc) · 14.5 KB
/
update-tap-values.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
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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
name: Update TAP values
env:
# ==== Versions ====
TANZU_CLI_VERSION: v0.25.4
TAP_VERSION_NUMBER: 1.4.0
CERT_MANAGER_VERSION: v1.11.0
AZ_CLI_VERSION: 2.45.0
# ==== General settings ====
APP_NAME: tap42
LOCATION: westeurope # francecentral
RG_KV: rg-kv-tanzu101 # RG where to deploy KV
RG_APP: rg-aks-tap-apps # RG where to deploy the other Azure services: AKS, TAP, ACR, MySQL, etc.
#DNS_ZONE: cloudapp.azure.com
#APP_DNS_ZONE: tap.westeurope.cloudapp.azure.com
#CUSTOM_DNS: appinnohandsonlab.com
#AZURE_DNS_LABEL_NAME: tap
TANZU_DNS_CHILD_ZONE: tap.appinnohandsonlab.com
################################## DO NOT CHANGE params below ##################################
# https://learn.microsoft.com/en-us/rest/api/storageservices/setting-timeouts-for-blob-service-operations
AZ_BLOB_MAX_CONNECTIONS: 10
AZ_BLOB_MAXSIZE_CONDITION: 440401920 # 420 Mb
AZ_BLOB_TIMEOUT: 600
# ==== Tanzu Tools ====
PG_PORT: 5432
IMG_PKG_CONCURRENCY: 2 # 1 or 2 ONLY for GitHub pulic Runners /!\ not more. Test with value 42 on Self-Hosted Runners deployed to AKS
TANZU_INSTALL_DIR: tanzu
TANZU_ESSENTIALS: tanzu-cluster-essentials-linux-amd64-1.4.0.tgz
TANZU_GUI_CAT: tap-gui-blank-catalog.tgz
TANZU_CLI: tanzu-framework-linux-amd64-v0.25.4.tar # /!\ the version name must match M.n.p like v0.25.4 NOT v0.25.4.1
TANZU_BLOB_CLI: tanzu-cli
TANZU_BLOB_ESSENTIALS: tanzu-essentials
TANZU_BLOB_GUI_CAT: tanzu-catalog
TANZU_REGISTRY: registry.tanzu.vmware.com
REPOSITORY: tap # set this to your ACR repository
REPO_SUBFOLDER_APP_TAP: tanzu-app-tap
CATALOG_URL: https://github.com/ezYakaEagle442/tap-catalog
TAP_NAMESPACE: tanzu
DEV_NAMESPACE: tap-dev
TAP_INSTALL_NAMESPACE: tap-install
KAPP_NAMESPACE: kapp-controller
# ==== Secrets ====
PG_ADM_PWD: ${{ secrets.PG_ADM_PWD }}
credentials: ${{ secrets.AZURE_CREDENTIALS }}
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
CERT_ADMIN_EMAIL: ${{ secrets.TANZU_NET_USER }}
TANZU_NET_USER: ${{ secrets.TANZU_NET_USER }}
TANZU_NET_PASSWORD: ${{ secrets.TANZU_NET_PASSWORD }}
GH_PAT: ${{ secrets.GH_PAT }}
TAP_BACKSTAGE_AUTH_MICROSOFT_CLIENT_ID: ${{ secrets.TAP_BACKSTAGE_AUTH_MICROSOFT_CLIENT_ID }}
TAP_BACKSTAGE_AUTH_MICROSOFT_CLIENT_SECRET: ${{ secrets.TAP_BACKSTAGE_AUTH_MICROSOFT_CLIENT_SECRET }}
TAP_BACKSTAGE_AUTH_MICROSOFT_TENANT_ID: ${{ secrets.TAP_BACKSTAGE_AUTH_MICROSOFT_TENANT_ID }}
on:
workflow_dispatch:
workflow_call:
jobs:
update-tap-values:
runs-on: ubuntu-latest
steps:
- name: Login with GHA Runner SP
uses: azure/login@v1 # https://github.com/marketplace/actions/azure-login
with:
creds: ${{ env.credentials }} # ${{ secrets.AZURE_CREDENTIALS }}
- name: Checkout
uses: actions/checkout@v3 # https://github.com/actions/checkout
- name: Set Base environment variables
run: |
# ==== AKS ====
AKS_CLUSTER_NAME=$(az deployment group show --name aks-main -g ${{ env.RG_APP }} --query properties.outputs.aksName.value -o tsv | tr -d '\r' | tr -d '"')
echo "AKS_CLUSTER_NAME="$AKS_CLUSTER_NAME
echo "AKS_CLUSTER_NAME=$AKS_CLUSTER_NAME" >> $GITHUB_ENV
# ==== Storage ====
storage_name=$(az deployment group show --name storage -g ${{ env.RG_APP }} --query properties.outputs.azurestorageName.value -o tsv)
echo "storage_name=" $storage_name
echo "AZ_STORAGE_NAME="$storage_name >> $GITHUB_ENV
blobContainerName=$(az deployment group show --name storage -g ${{ env.RG_APP }} --query properties.outputs.blobcontainerName.value -o tsv)
echo "blobContainerName=" $blobContainerName
echo "AZ_BLOB_CONTAINER_NAME="$blobContainerName >> $GITHUB_ENV
# ==== Tanzu DB ====
PG_SERVER_NAME=$(az deployment group show --name postgresqldb -g ${{ env.RG_APP }} --query properties.outputs.postgreSQLServerName.value -o tsv)
PG_SERVER_NAME=$PG_SERVER_NAME".postgres.database.azure.com"
echo "PG_SERVER_NAME="$PG_SERVER_NAME
echo "PG_SERVER_NAME="$PG_SERVER_NAME >> $GITHUB_ENV
PG_DB_NAME=$(az deployment group show --name postgresqldb -g ${{ env.RG_APP }} --query properties.outputs.postgreSQLDBName.value -o tsv)
echo "PG_DB_NAME="$PG_DB_NAME
echo "PG_DB_NAME="$PG_DB_NAME >> $GITHUB_ENV
PG_ADM_USR=$(az deployment group show --name postgresqldb -g ${{ env.RG_APP }} --query properties.outputs.postgreSQLUser.value -o tsv)
echo "PG_ADM_USR="$PG_ADM_USR
echo "PG_ADM_USR="$PG_ADM_USR >> $GITHUB_ENV
# ==== ACR ====
REGISTRY_URL=$(az deployment group show --name acr -g ${{ env.RG_APP }} --query properties.outputs.acrRegistryUrl.value -o tsv)
echo "REGISTRY_URL="$REGISTRY_URL
echo "REGISTRY_URL="$REGISTRY_URL >> $GITHUB_ENV
AZURE_CONTAINER_REGISTRY=$(az deployment group show --name acr -g ${{ env.RG_APP }} --query properties.outputs.acrName.value -o tsv)
echo "AZURE_CONTAINER_REGISTRY="$AZURE_CONTAINER_REGISTRY
echo "AZURE_CONTAINER_REGISTRY="$AZURE_CONTAINER_REGISTRY >> $GITHUB_ENV
# ==== KV ====
KV_NAME=$(az deployment group show --name aks-tap-kv -g ${{ env.RG_KV }} --query properties.outputs.keyVaultName.value -o tsv)
echo "KV_NAME=$KV_NAME" >> $GITHUB_ENV
echo "KV_NAME=$KV_NAME"
SPRING_CLOUD_AZURE_KEY_VAULT_ENDPOINT=$(az deployment group show --name aks-tap-kv -g ${{ env.RG_KV }} --query properties.outputs.keyVaultURI.value -o tsv)
echo "SPRING_CLOUD_AZURE_KEY_VAULT_ENDPOINT=$SPRING_CLOUD_AZURE_KEY_VAULT_ENDPOINT" >> $GITHUB_ENV
echo "SPRING_CLOUD_AZURE_KEY_VAULT_ENDPOINT=$SPRING_CLOUD_AZURE_KEY_VAULT_ENDPOINT"
echo "GH_WORKSPACE=${{ github.workspace }}" >> $GITHUB_ENV # "/github/workspace"
echo "LOCAL_IP=$(curl whatismyip.akamai.com)" >> $GITHUB_ENV
shell: bash
- name: Display environment variables
run: |
echo "Checking GITHUB_ENV"
echo "LOCAL_IP=$LOCAL_IP"
echo "AKS_CLUSTER_NAME=$AKS_CLUSTER_NAME"
echo "AZ_STORAGE_NAME="$AZ_STORAGE_NAME
echo "AZURE_CONTAINER_REGISTRY="$AZURE_CONTAINER_REGISTRY
echo "REGISTRY_URL="$REGISTRY_URL
echo "PG_DB_NAME="$PG_DB_NAME
echo "PG_ADM_USR="$PG_ADM_USR
echo "PG_SERVER_NAME="$PG_SERVER_NAME
echo "PG_PORT="$PG_PORT
echo "GH_WORKSPACE=$GH_WORKSPACE"
shell: bash
# https://github.com/Azure/aks-set-context/tree/releases/v1
- name: AKS Set Context
uses: azure/aks-set-context@v1
with:
creds: '${{ secrets.AZURE_CREDENTIALS }}' # Azure credentials
resource-group: ${{ env.RG_APP }}
cluster-name: ${{ env.AKS_CLUSTER_NAME }}
id: akslogin
- name: K8S Test with AAD
run: |
kubectl config get-contexts
kubectl cluster-info
kubectl get nodes -o wide
mkdir ${{ env.TANZU_INSTALL_DIR }}/k8s/deploy
mkdir ${{ env.TANZU_INSTALL_DIR }}/deploy
shell: bash
- name: Authorize local IP access to the Azure BLOB Storage
if: ${{ always() }}
run: |
LOCAL_IP=$(curl whatismyip.akamai.com)
echo "LOCAL_IP=$(curl whatismyip.akamai.com)" >> $GITHUB_ENV
echo "About to ADD network-rule to ALLOW $LOCAL_IP to Azure BLOB Storage ${{ env.AZ_STORAGE_NAME }}"
az storage account network-rule add --ip-address $LOCAL_IP --account-name ${{ env.AZ_STORAGE_NAME }} --action "Allow" -g ${{ env.RG_APP }} --only-show-errors
sleep 30
shell: bash
- name: Download Tanzu Tools from Azure BLOB Storage
id: blob_download
run: |
# https://learn.microsoft.com/en-us/azure/storage/blobs/blob-cli
pwd
ls -al
ls -al ${{ github.workspace }}/${{ env.TANZU_INSTALL_DIR }}
# TODO: need a workaround to resolve the network issues between GHA Runnr and Azure Storage
# https://github.com/actions/runner-images/blob/main/images/linux/scripts/helpers/install.sh
echo "About to download Tanzu tools from Azure BLOB Storage"
az storage blob download --name ${{ env.TANZU_BLOB_CLI }} --file ${{ github.workspace }}/${{ env.TANZU_INSTALL_DIR }}/${{ env.TANZU_CLI }} --container-name ${{ env.AZ_BLOB_CONTAINER_NAME }} --account-name ${{ env.AZ_STORAGE_NAME }} --auth-mode login --max-connections ${{ env.AZ_BLOB_MAX_CONNECTIONS }}
az storage blob download --name ${{ env.TANZU_BLOB_ESSENTIALS }} --file ${{ github.workspace }}/${{ env.TANZU_INSTALL_DIR }}/${{ env.TANZU_ESSENTIALS }} --container-name ${{ env.AZ_BLOB_CONTAINER_NAME }} --account-name ${{ env.AZ_STORAGE_NAME }} --auth-mode login --max-connections ${{ env.AZ_BLOB_MAX_CONNECTIONS }}
az storage blob download --name ${{ env.TANZU_GUI_CAT }} --file ${{ github.workspace }}/${{ env.TANZU_INSTALL_DIR }}/${{ env.TANZU_GUI_CAT }} --container-name ${{ env.AZ_BLOB_CONTAINER_NAME }} --account-name ${{ env.AZ_STORAGE_NAME }} --auth-mode login --max-connections ${{ env.AZ_BLOB_MAX_CONNECTIONS }}
ls -al ${{ github.workspace }}/${{ env.TANZU_INSTALL_DIR }}
ls -al ${{ github.workspace }}/${{ env.TANZU_INSTALL_DIR }}/${{ env.TANZU_CLI }}
ls -al ${{ github.workspace }}/${{ env.TANZU_INSTALL_DIR }}/${{ env.TANZU_ESSENTIALS }}
ls -al ${{ github.workspace }}/${{ env.TANZU_INSTALL_DIR }}/${{ env.TANZU_GUI_CAT }}
shell: bash
- name: Disable local IP access to the Azure BLOB Storage
if: ${{ always() }}
run: |
echo "About to REMOVE network-rule ALLOWING $LOCAL_IP to Azure BLOB Storage ${{ env.AZ_STORAGE_NAME }}"
az storage account network-rule remove --ip-address $LOCAL_IP --account-name ${{ env.AZ_STORAGE_NAME }} -g ${{ env.RG_APP }} --only-show-errors
shell: bash
- name: Install CLI & Plugins
run: |
ls -al ${{ env.TANZU_INSTALL_DIR }}
tar -xvf ${{ env.TANZU_INSTALL_DIR }}/${{ env.TANZU_ESSENTIALS }} -C ${{ env.TANZU_INSTALL_DIR }}
tar -xvf ${{ env.TANZU_INSTALL_DIR }}/${{ env.TANZU_CLI }} -C ${{ env.TANZU_INSTALL_DIR }}
ls -al ${{ env.TANZU_INSTALL_DIR }}
export TANZU_CLI_NO_INIT=true
export VERSION=${{ env.TANZU_CLI_VERSION }}
cd ${{ env.TANZU_INSTALL_DIR }}
ls -al
install cli/core/$VERSION/tanzu-core-linux_amd64 /usr/local/bin/tanzu
cp kapp /usr/local/bin/kapp
cp imgpkg /usr/local/bin/imgpkg
tanzu version
tanzu plugin install --local cli all
tanzu plugin list
shell: bash
- name: Update TAP-Values
run: |
export METADATA_STORE_ACCESS_TOKEN=$(kubectl create token metadata-store-read-client -n metadata-store)
acr_usr=$(az acr credential show --name ${{ env.REGISTRY_URL }} -g ${{ env.RG_APP }} | jq -r .username) # ${{ env.AZURE_CONTAINER_REGISTRY }}
acr_pwd=$(az acr credential show --name ${{ env.REGISTRY_URL }} -g ${{ env.RG_APP }} | jq -r .passwords[0].value)
export INSTALL_REGISTRY_HOSTNAME=${{ env.REGISTRY_URL }}
export INSTALL_REGISTRY_USERNAME=$acr_usr
export INSTALL_REGISTRY_PASSWORD=$acr_pwd
export INSTALL_REPO=${{ env.REPOSITORY }}
export PG_SQL_HOSTNAME=${{ env.PG_SERVER_NAME }}
export PG_SQL_PORT=${{ env.PG_PORT }}
export PG_SQL_DATABASE=${{ env.PG_DB_NAME }}
export PG_SQL_USERNAME=${{ env.PG_ADM_USR }}
export PG_SQL_PASSWORD=${{ env.PG_ADM_PWD }}
export TAP_VERSION=${{ env.TAP_VERSION_NUMBER }}
# need to substitute env var in the template file
export TANZU_INSTALL_DIR=${{ env.TANZU_INSTALL_DIR }}
export DEV_NAMESPACE=${{ env.DEV_NAMESPACE }}
export APP_DNS_ZONE=${{ env.TANZU_DNS_CHILD_ZONE }}
export TANZU_NET_USER=${{ env.TANZU_NET_USER }}
export TANZU_NET_PASSWORD=${{ env.TANZU_NET_PASSWORD }}
export AZURE_CONTAINER_REGISTRY=${{ env.AZURE_CONTAINER_REGISTRY }}
export REGISTRY_URL=${{ env.REGISTRY_URL }}
export REPOSITORY=${{ env.REPOSITORY }}
export REPO_SUBFOLDER_APP_TAP=${{ env.REPO_SUBFOLDER_APP_TAP }}
export GH_PAT=${{ env.GH_PAT }}
export TAP_BACKSTAGE_AUTH_MICROSOFT_CLIENT_ID=${{ env.TAP_BACKSTAGE_AUTH_MICROSOFT_CLIENT_ID }}
export TAP_BACKSTAGE_AUTH_MICROSOFT_CLIENT_SECRET=${{ env.TAP_BACKSTAGE_AUTH_MICROSOFT_CLIENT_SECRET }}
export TAP_BACKSTAGE_AUTH_MICROSOFT_TENANT_ID=${{ env.TAP_BACKSTAGE_AUTH_MICROSOFT_TENANT_ID }}
export REPOSITORY_USERNAME=$acr_usr
export REPOSITORY_PASSWORD=$acr_pwd
ls -al ${{ github.workspace }}/${{ env.TANZU_INSTALL_DIR }}
envsubst < ${{ env.TANZU_INSTALL_DIR }}/tap-values.yml > ${{ env.TANZU_INSTALL_DIR }}/deploy/tap-values.yml
echo ""
ls -al ${{ env.TANZU_INSTALL_DIR }}/deploy/tap-values.yml
echo ""
az acr login --name ${{ env.REGISTRY_URL }} -u $acr_usr -p $acr_pwd
docker login ${{ env.TANZU_REGISTRY}} -u ${{ env.TANZU_NET_USER }} -p ${{ env.TANZU_NET_PASSWORD }}
tanzu package installed update tap -p tap.tanzu.vmware.com -v $TAP_VERSION --values-file ${{ env.TANZU_INSTALL_DIR }}/deploy/tap-values.yml -n ${{ env.TAP_INSTALL_NAMESPACE}}
tanzu package installed list -A
shell: bash
- name: Azure Logout security hardening
run: |
az logout
az cache purge
az account clear
shell: bash