1
- name : Deploy Otomi
1
+ name : Deploy APL
2
2
on :
3
3
workflow_call :
4
4
inputs :
7
7
type : string
8
8
default : " ['1.31']"
9
9
install_profile :
10
- description : ' Otomi installation profile'
10
+ description : ' APL installation profile'
11
11
type : string
12
12
default : minimal-with-team
13
- cluster_persistence :
14
- description : ' Should a cluster be destroyed on pipeline finish?'
15
- type : string
16
- default : destroy
17
13
domain_zone :
18
14
description : ' Select Domain Zone'
19
15
type : string
20
16
default : DNS-Integration
21
17
kms :
22
- description : ' Should Otomi encrypt secrets in values repo (DNS or KMS is turned on)?'
18
+ description : ' Should APL encrypt secrets in values repo (DNS or KMS is turned on)?'
23
19
type : string
24
20
default : age
25
- generate_password :
26
- description : ' Should a unique password be generated?'
27
- type : string
28
- default : ' yes'
29
21
certificate :
30
22
description : ' Select certificate issuer'
31
23
type : string
41
33
- " ['1.31']"
42
34
default : " ['1.31']"
43
35
install_profile :
44
- description : Otomi installation profile
36
+ description : APL installation profile
45
37
default : minimal-with-team
46
38
type : choice
47
39
options :
50
42
- monitoring-with-team
51
43
- full
52
44
- upgrade
53
- - no-otomi
54
- cluster_persistence :
55
- type : choice
56
- description : Should a cluster be destroyed on pipeline finish?
57
- options :
58
- - preserve
59
- - destroy
60
- default : preserve
61
45
domain_zone :
62
46
type : choice
63
47
description : ' Select Domain Zone'
66
50
- Zone-2
67
51
kms :
68
52
type : choice
69
- description : Should Otomi encrypt secrets in values repo (DNS or KMS is turned on)?
53
+ description : Should APL encrypt secrets in values repo (DNS or KMS is turned on)?
70
54
options :
71
55
- age
72
56
- no_kms
73
57
default : age
74
- generate_password :
75
- type : choice
76
- description : Should a unique password be generated?
77
- options :
78
- - ' yes'
79
- - ' no'
80
- default : ' yes'
81
58
certificate :
82
59
type : choice
83
60
description : Select certificate issuer
@@ -108,10 +85,8 @@ jobs:
108
85
echo 'ref: ${{ github.event.pull_request.head.ref || github.ref }}'
109
86
echo 'install_profile: ${{ inputs.install_profile }}'
110
87
echo 'kubernetes_versions: ${{ inputs.kubernetes_versions }}'
111
- echo 'cluster_persistence: ${{ inputs.cluster_persistence }}'
112
88
echo 'kms: ${{ inputs.kms }}'
113
89
echo 'domain_zone: ${{ inputs.domain_zone }}'
114
- echo 'generate_password: ${{ inputs.generate_password }}'
115
90
echo 'certificate: ${{ inputs.certificate }}'
116
91
117
92
preprocess-linode-input :
@@ -130,7 +105,6 @@ jobs:
130
105
case "${{ inputs.domain_zone }}" in
131
106
"Zone-1") LINODE_CLUSTER_NAME=${{ github.actor }}-1 ;;
132
107
"Zone-2") LINODE_CLUSTER_NAME=${{ github.actor }}-2 ;;
133
- "DNS-Integration") LINODE_CLUSTER_NAME=nightly-apl-test ;;
134
108
esac
135
109
136
110
if [[ $(linode-cli lke clusters-list --json | jq --arg name "$LINODE_CLUSTER_NAME" '[.[] | select(.label == $name)] | length > 0') == "true" ]]; then
@@ -169,19 +143,30 @@ jobs:
169
143
case "${{ inputs.domain_zone }}" in
170
144
"Zone-1") LINODE_CLUSTER_NAME=${{ github.actor }}-1 ;;
171
145
"Zone-2") LINODE_CLUSTER_NAME=${{ github.actor }}-2 ;;
172
- "DNS-Integration") LINODE_CLUSTER_NAME=nightly-apl-test ;;
146
+ "DNS-Integration") LINODE_CLUSTER_NAME=nightly-apl-test-$RANDOM ;;
173
147
esac
174
148
echo LINODE_CLUSTER_NAME=$LINODE_CLUSTER_NAME >> $GITHUB_ENV
175
149
- name : Determine exact k8s version
176
150
run : |
177
151
echo LINODE_K8S_VERSION=$(linode-cli lke versions-list --json | jq -ce --arg version "$(echo ${{ matrix.kubernetes_versions }} | sed -E 's/^([0-9]+\.[0-9])$/\10/')" '.[] | select(.id | tostring | startswith($version)) | .id') >> $GITHUB_ENV
152
+ - name : Creating domain for scheduled integration test
153
+ env :
154
+ EDGEDNS_ZONE : ${{ secrets.EDGEDNS_ZONE }}
155
+ if : ${{ inputs.domain_zone == 'DNS-Integration' }}
156
+ run : |
157
+ # Generating a random 5 char string
158
+ RAND=$(openssl rand -hex 4)
159
+ DOMAIN="integration-${RAND}.${EDGEDNS_ZONE}"
160
+ echo "::add-mask::$DOMAIN"
161
+ echo DOMAIN=$DOMAIN >> $GITHUB_ENV
162
+
178
163
- name : Determine domain name to use
164
+ if : ${{ inputs.domain_zone != 'DNS-Integration' }}
179
165
run : |
180
166
# Mapping of domain_zone to domain names
181
167
case "${{ inputs.domain_zone }}" in
182
168
"Zone-1") DOMAIN=$(jq '."${{ github.actor }}"[0]' <<< ${{ env.DEV_DOMAINS }}) ;;
183
169
"Zone-2") DOMAIN=$(jq '."${{ github.actor }}"[1]' <<< ${{ env.DEV_DOMAINS }}) ;;
184
- "DNS-Integration") DOMAIN=$(jq '."DNS-Integration"[0]' <<< ${{ env.DEV_DOMAINS }}) ;;
185
170
esac
186
171
187
172
echo "::add-mask::$DOMAIN"
@@ -198,6 +183,7 @@ jobs:
198
183
--node_pools.autoscaler.max 3 \
199
184
--node_pools.autoscaler.min 3 \
200
185
--tags testing \
186
+ --tags delete_me_tonight \
201
187
--no-defaults
202
188
- name : Retrieve cluster id
203
189
run : echo "LINODE_CLUSTER_ID=$(linode-cli lke clusters-list --json | jq -ce '.[] | select(.label | startswith("${{ env.LINODE_CLUSTER_NAME }}")) | .id')" >> $GITHUB_ENV
@@ -244,8 +230,7 @@ jobs:
244
230
--docker-password='${{ secrets.BOT_PULL_TOKEN }}'
245
231
- name : Checkout
246
232
uses : actions/checkout@v4
247
- - name : Prepare Otomi chart
248
- if : ${{ inputs.install_profile != 'no-otomi' }}
233
+ - name : Prepare APL chart
249
234
run : |
250
235
ref=${{ github.event.pull_request.head.ref || github.ref }}
251
236
tag=${ref##*/}
@@ -254,7 +239,7 @@ jobs:
254
239
sed --in-place "s/OTOMI_VERSION_PLACEHOLDER/${GITHUB_REF##*/}/g" tests/integration/${{ inputs.install_profile }}.yaml
255
240
touch values-container-registry.yaml
256
241
257
- # If a pipeline installs Otomi from the semver tag then pull container image from DockerHub
242
+ # If a pipeline installs APL from the semver tag then pull container image from DockerHub
258
243
[[ ${GITHUB_REF##*/} =~ ^v[0-9].+$ ]] && exit 0
259
244
260
245
# Pull image from cache registry
@@ -263,40 +248,59 @@ jobs:
263
248
imagePullSecretNames:
264
249
- reg-otomi-github
265
250
EOF
266
- - name : Otomi install
267
- if : ${{ inputs.install_profile != 'no-otomi' }}
251
+ - name : APL install
268
252
env :
269
253
LETSENCRYPT_STAGING : ${{ secrets.LETSENCRYPT_STAGING }}
270
254
LETSENCRYPT_PRODUCTION : ${{ secrets.LETSENCRYPT_PRODUCTION }}
271
- HOST : ${{ secrets.EDGEDNS_HOST }}
272
- ACCESS_TOKEN : ${{ secrets.EDGEDNS_ACCESS_TOKEN }}
273
- CLIENT_TOKEN : ${{ secrets.EDGEDNS_CLIENT_TOKEN }}
274
- CLIENT_SECRET : ${{ secrets.EDGEDNS_CLIENT_SECRET }}
255
+ EDGEDNS_ACCESS_TOKEN : ${{ secrets.EDGEDNS_ACCESS_TOKEN }}
256
+ EDGEDNS_CLIENT_TOKEN : ${{ secrets.EDGEDNS_CLIENT_TOKEN }}
257
+ EDGEDNS_CLIENT_SECRET : ${{ secrets.EDGEDNS_CLIENT_SECRET }}
258
+ EDGEDNS_ZONE : ${{ secrets.EDGEDNS_ZONE }}
259
+ EDGEDNS_HOST : ${{ secrets.EDGEDNS_HOST }}
275
260
run : |
276
261
touch values.yaml
277
- adminPassword=welcomeotomi
262
+
263
+ adminPassword="$(head /dev/urandom | tr -dc 'A-Za-z0-9' | head -c 24)"
278
264
[[ '${{ inputs.certificate }}' == 'letsencrypt_staging' ]] && echo "$LETSENCRYPT_STAGING" >> values.yaml
279
265
[[ '${{ inputs.certificate }}' == 'letsencrypt_production' ]] && echo "$LETSENCRYPT_PRODUCTION" >> values.yaml
280
266
[[ '${{ inputs.kms }}' == 'age' ]] && kms="--set kms.sops.provider=age"
281
- [[ '${{ inputs.generate_password }}' == 'yes' ]] && adminPassword="$(head /dev/urandom | tr -dc 'A-Za-z0-9' | head -c 24)"
282
-
283
267
284
268
install_args="otomi chart/apl --wait --wait-for-jobs --timeout 90m0s \
285
269
--values tests/integration/${{ inputs.install_profile }}.yaml \
286
270
--values values-container-registry.yaml \
287
271
--values values.yaml \
288
272
--set cluster.provider=linode \
289
273
--set dns.domainFilters[0]=${{ env.DOMAIN }} \
290
- --set dns.provider.akamai.clientSecret=${CLIENT_SECRET } \
291
- --set dns.provider.akamai.host=${HOST } \
292
- --set dns.provider.akamai.accessToken=${ACCESS_TOKEN } \
293
- --set dns.provider.akamai.clientToken=${CLIENT_TOKEN } \
274
+ --set dns.provider.akamai.clientSecret=${EDGEDNS_CLIENT_SECRET } \
275
+ --set dns.provider.akamai.host=${EDGEDNS_HOST } \
276
+ --set dns.provider.akamai.accessToken=${EDGEDNS_ACCESS_TOKEN } \
277
+ --set dns.provider.akamai.clientToken=${EDGEDNS_CLIENT_TOKEN } \
294
278
--set otomi.hasExternalDNS=true \
295
279
--set cluster.domainSuffix=${{ env.DOMAIN }} \
296
280
--set otomi.adminPassword=$adminPassword \
297
281
$kms"
298
282
299
- helm install $install_args
283
+ helm install $install_args &
284
+ HELM_PID=$!
285
+ sleep 120
286
+
287
+ # While helm is installing we can crete the wildcard dns record
288
+ while true; do
289
+ PUB_IP=$(kubectl get svc ingress-nginx-platform-controller -n ingress -ojson | jq '.status.loadBalancer.ingress[0].ip' -r)
290
+ if [[ -n "$PUB_IP" ]]; then
291
+ echo "::add-mask::$PUB_IP"
292
+ echo PUB_IP=$PUB_IP >> $GITHUB_ENV
293
+ break
294
+ else
295
+ echo "Waiting for ingress-nginx-platform-controller IP..."
296
+ sleep 5
297
+ fi
298
+ done
299
+
300
+ pip3 install edgegrid-python requests
301
+ python3 bin/edgedns_A_record.py create $DOMAIN $PUB_IP
302
+
303
+ wait $HELM_PID
300
304
301
305
- name : Gather k8s events on failure
302
306
if : failure()
@@ -306,7 +310,7 @@ jobs:
306
310
if : failure()
307
311
run : |
308
312
kubectl get pods -A -o wide
309
- - name : Gather otomi logs on failure
313
+ - name : Gather APL logs on failure
310
314
if : failure()
311
315
run : |
312
316
kubectl logs jobs/otomi --tail 150
@@ -315,10 +319,19 @@ jobs:
315
319
run : |
316
320
kubectl logs -n maintenance -l app.kubernetes.io/instance=job-e2e --tail 15000
317
321
- name : Remove the test cluster
318
- if : always()
322
+ if : ${{ inputs.domain_zone == 'DNS-Integration' }}
319
323
run : |
320
- [[ "${{ inputs.cluster_persistence }}" == "preserve" ]] && echo "The cluster ${{ env.LINODE_CLUSTER_NAME }} will NOT be destroyed!!" && exit 0
321
324
linode-cli lke cluster-delete ${{ env.LINODE_CLUSTER_ID }}
325
+ - name : Delete Domain
326
+ if : ${{ inputs.domain_zone == 'DNS-Integration' }}
327
+ env :
328
+ EDGEDNS_ACCESS_TOKEN : ${{ secrets.EDGEDNS_ACCESS_TOKEN }}
329
+ EDGEDNS_CLIENT_TOKEN : ${{ secrets.EDGEDNS_CLIENT_TOKEN }}
330
+ EDGEDNS_CLIENT_SECRET : ${{ secrets.EDGEDNS_CLIENT_SECRET }}
331
+ EDGEDNS_ZONE : ${{ secrets.EDGEDNS_ZONE }}
332
+ EDGEDNS_HOST : ${{ secrets.EDGEDNS_HOST }}
333
+ run : |
334
+ python3 bin/edgedns_A_record.py delete $DOMAIN
322
335
- name : Slack Notification
323
336
if : always()
324
337
uses : rtCamp/action-slack-notify@v2
0 commit comments