-
Notifications
You must be signed in to change notification settings - Fork 0
526 lines (503 loc) · 21.3 KB
/
create-demo-clusters.yml
File metadata and controls
526 lines (503 loc) · 21.3 KB
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
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
name: Create demo clusters for version
on:
workflow_call:
inputs:
version:
description: Version of the images
required: true
type: string
create-k8s-cluster:
description: Create a GKE demo cluster
default: false
type: boolean
create-os4-cluster:
description: Create an Openshift 4 demo cluster
default: false
type: boolean
create-long-cluster:
description: Create a long-running cluster on RC1
default: false
type: boolean
dry-run:
description: Dry-run
default: false
type: boolean
workflow-ref:
description: Ref of the called workflow
type: string
kube-burner-config-ref:
description: Ref of where the kube-burner config files can be found
type: string
kube-burner-config-repo:
description: The repository where the kube-burner config files can be found
type: string
cluster-with-fake-load-name:
description: "The name of the long running cluster where the central deployment is run with a sensor that creates its own fake workload. Must comply to the regex: [a-z][a-z0-9-]{1,26}[a-z0-9]"
type: string
cluster-with-real-load-name:
description: "The name of the long running cluster where collector is run with real workload. Must comply to the regex: [a-z][a-z0-9-]{1,26}[a-z0-9]"
type: string
env:
main_branch: ${{github.event.repository.default_branch}}
script_url: /repos/${{github.repository}}/contents/.github/workflows/scripts/common.sh?ref=${{ github.ref_name }}
DRY_RUN: ${{ inputs.dry-run }}
ACCEPT_RAW: "Accept: application/vnd.github.v3.raw"
GH_TOKEN: ${{ github.token }}
GH_NO_UPDATE_NOTIFIER: 1
TIMEOUT_WAIT_FOR_IMAGES_SECONDS: 3600
jobs:
properties:
runs-on: ubuntu-latest
outputs:
slack-channel: ${{ fromJSON(format('["{0}","{1}"]', steps.fetch.outputs.dry-slack-channel, steps.fetch.outputs.slack-channel))[inputs.dry-run != true] }}
jira-projects: ${{ steps.fetch.outputs.jira-projects }}
steps:
- name: Read workflow properties file
id: fetch
env:
PROPERTIES_URL: /repos/${{ github.repository }}/contents/.github/properties?ref=${{ github.ref_name }}
run: gh api -H "$ACCEPT_RAW" "$PROPERTIES_URL" >> "$GITHUB_OUTPUT"
wait-for-images:
name: Wait for images on Quay.io
runs-on: ubuntu-latest
if: >- # Skip if no clusters are going to be created.
inputs.create-k8s-cluster != false ||
inputs.create-os4-cluster != false ||
inputs.create-long-cluster != false
strategy:
matrix:
image: [main, scanner, scanner-db, collector]
steps:
- name: Checkout local action
uses: actions/checkout@v4
with:
repository: stackrox/actions
path: .actions
ref: ${{ inputs.workflow-ref }}
- name: Wait for the ${{matrix.image}} image
uses: ./.actions/release/wait-for-image
with:
token: ${{secrets.QUAY_RHACS_ENG_BEARER_TOKEN}}
image: "rhacs-eng/${{ matrix.image }}:${{ inputs.version }}"
# Do not wait if running dry
interval: ${{ fromJSON('["30", "0"]')[inputs.dry-run == true] }}
limit: ${{ fromJSON(format('["{0}","{1}"]', env.TIMEOUT_WAIT_FOR_IMAGES_SECONDS, 0))[inputs.dry-run == true] }}
create-k8s-cluster:
name: Create k8s cluster
needs: [wait-for-images]
if: inputs.dry-run != true && inputs.create-k8s-cluster != false
runs-on: ubuntu-latest
steps:
- name: Checkout local action
uses: actions/checkout@v4
with:
repository: stackrox/actions
path: .actions
ref: ${{ inputs.workflow-ref }}
- uses: ./.actions/infra/create-cluster
with:
token: ${{ secrets.INFRA_TOKEN }}
flavor: qa-demo
name: qa-k8s-${{ inputs.version }}
args: main-image=quay.io/rhacs-eng/main:${{ inputs.version }},central-db-image=quay.io/rhacs-eng/central-db:${{ inputs.version }}
lifespan: 48h
notify-k8s-cluster:
name: Notify about K8s cluster creation
needs: [properties, create-k8s-cluster]
runs-on: ubuntu-latest
env:
NAME: qa-k8s-${{ inputs.version }}
steps:
- name: Determine demo url and cluster name
id: get_demo_artifacts
run: |
echo "cluster-name=${NAME//./-}" >> "$GITHUB_OUTPUT"
echo "url=https://${NAME//[.-]/}.demos.rox.systems/login" >> "$GITHUB_OUTPUT"
- name: Post to Slack
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
uses: slackapi/slack-github-action@v1.27.0
with:
channel-id: ${{ needs.properties.outputs.slack-channel }}
payload: >-
{
"text": "QA Demo cluster is being created. Check #acs-infra-notifications for cluster access.",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":tada: *<https://infra.rox.systems/cluster/${{ steps.get_demo_artifacts.outputs.cluster-name }}|QA demo cluster> `${{ steps.get_demo_artifacts.outputs.cluster-name }}` is being created for ${{ inputs.version }} milestone of <${{ github.server_url }}/${{ github.repository }}|${{ github.repository }}>.*"
}
},
{
"type": "divider"
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":arrow_right: When it is ready in ca. 20 minutes, a notification will be posted in #acs-infra-notifications channel, and the cluster will be accessible at ${{ steps.get_demo_artifacts.outputs.url }}. You can find the admin password and kubeconfig with `infractl artifacts ${{ steps.get_demo_artifacts.outputs.cluster-name }}`."
}
}
]
}
create-os4-cluster:
name: Create OS4 cluster
needs: [wait-for-images]
if: inputs.dry-run == false && inputs.create-os4-cluster == true
runs-on: ubuntu-latest
steps:
- name: Checkout local action
uses: actions/checkout@v4
with:
repository: stackrox/actions
path: .actions
ref: ${{ inputs.workflow-ref }}
- uses: ./.actions/infra/create-cluster
with:
token: ${{ secrets.INFRA_TOKEN }}
flavor: openshift-4-demo
name: openshift-4-demo-${{ inputs.version }}
args: central-services-helm-chart-version=${{ inputs.version }},secured-cluster-services-helm-chart-version=${{ inputs.version }}
lifespan: 48h
notify-os4-cluster:
name: Notify about Openshift cluster creation
needs: [properties, create-os4-cluster]
runs-on: ubuntu-latest
env:
NAME: openshift-4-demo-${{ inputs.version }}
steps:
- name: Determine demo url and cluster name
id: get_demo_artifacts
run: |
echo "cluster-name=${NAME//./-}" >> "$GITHUB_OUTPUT"
echo "url=https://central-stackrox.apps.${NAME//./-}.ocp.infra.rox.systems/login" >> "$GITHUB_OUTPUT"
- name: Post to Slack
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
uses: slackapi/slack-github-action@v1.27.0
with:
channel-id: ${{ needs.properties.outputs.slack-channel }}
payload: >-
{
"text": "Openshift 4 Demo cluster is being created. Check #acs-infra-notifications for cluster access.",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":tada: *<https://infra.rox.systems/cluster/${{ steps.get_demo_artifacts.outputs.cluster-name }}|Openshift 4 Demo cluster> `${{ steps.get_demo_artifacts.outputs.cluster-name }}` is being created for ${{ inputs.version }} milestone of <${{ github.server_url }}/${{ github.repository }}|${{ github.repository }}>.*"
}
},
{
"type": "divider"
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":arrow_right: The cluster will be accessible at ${{ steps.get_demo_artifacts.outputs.url }} in ~40 minutes. You can find the admin password and kubeconfig with `infractl artifacts ${{ steps.get_demo_artifacts.outputs.cluster-name }}`."
}
}
]
}
create-long-running-cluster-for-fake-load:
name: Create GKE long-running cluster for fake load
needs: [wait-for-images]
if: >-
inputs.dry-run != true &&
inputs.create-long-cluster == true
runs-on: ubuntu-latest
steps:
- name: Checkout local action
uses: actions/checkout@v4
with:
repository: stackrox/actions
path: .actions
ref: ${{ inputs.workflow-ref }}
- uses: ./.actions/infra/create-cluster
with:
token: ${{ secrets.INFRA_TOKEN }}
flavor: gke-default
name: ${{ inputs.cluster-with-fake-load-name }}
lifespan: 168h
args: nodes=5,machine-type=e2-standard-8
wait: true
# TODO ROX-19190 Don't DRY. Make this and the above into a separate action.
create-long-running-cluster-for-real-load:
name: Create GKE long-running cluster for real load
needs: [wait-for-images]
if: >-
inputs.dry-run != true &&
inputs.create-long-cluster == true
runs-on: ubuntu-latest
steps:
- name: Checkout local action
uses: actions/checkout@v4
with:
repository: stackrox/actions
path: .actions
ref: ${{ inputs.workflow-ref }}
- uses: ./.actions/infra/create-cluster
with:
token: ${{ secrets.INFRA_TOKEN }}
flavor: gke-default
name: ${{ inputs.cluster-with-real-load-name }}
lifespan: 168h
args: nodes=5,machine-type=e2-standard-8
wait: true
start-acs:
name: Start ACS
needs: [properties, create-long-running-cluster-for-fake-load]
runs-on: ubuntu-latest
outputs:
rox-password: ${{ steps.launch-central.outputs.rox-password }}
central-ip: ${{ steps.launch-central.outputs.central-ip }}
env:
NAME: ${{ inputs.cluster-with-fake-load-name }}
KUBECONFIG: artifacts/kubeconfig
INFRA_TOKEN: ${{secrets.INFRA_TOKEN}}
USE_GKE_GCLOUD_AUTH_PLUGIN: "True"
steps:
- uses: stackrox/actions/infra/install-infractl@v1
- name: Test readiness
run: |
STATUS=$(infractl get "${NAME//./-}" --json | jq -r .Status)
if [ "$STATUS" != "READY" ]; then
exit 1
fi
- name: Check out stackrox code
uses: actions/checkout@v4
with:
ref: ${{inputs.version}}
repository: stackrox/stackrox
- name: Checkout local action
uses: actions/checkout@v4
with:
repository: stackrox/actions
path: .actions
ref: ${{ inputs.workflow-ref }}
- uses: "google-github-actions/auth@v2"
with:
credentials_json: "${{ secrets.GCP_RELEASE_AUTOMATION_SA }}"
- name: "Set up Cloud SDK"
uses: "google-github-actions/setup-gcloud@v2"
with:
install_components: "gke-gcloud-auth-plugin"
- name: Download artifacts
id: artifacts
run: |
infractl artifacts "${NAME//./-}" -d artifacts >> "$GITHUB_STEP_SUMMARY"
- name: Launch central
id: launch-central
uses: ./.actions/release/start-acs
with:
main-image-tag: ${{inputs.version}}
kubeconfig: ${{ env.KUBECONFIG }}
pagerduty-integration-key: ${{ secrets.RELEASE_MANAGEMENT_PAGERDUTY_INTEGRATION_KEY }}
registry-username: ${{ secrets.QUAY_RHACS_ENG_RO_USERNAME }}
registry-password: ${{ secrets.QUAY_RHACS_ENG_RO_PASSWORD }}
stackrox-dir: ${{ github.workspace }}
name: ${{ env.NAME }}
- name: Post to Slack
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
uses: slackapi/slack-github-action@v1.27.0
with:
channel-id: ${{ needs.properties.outputs.slack-channel }}
payload: >-
{
"text": "Long-running cluster created. Setup your local access with `scripts/release-tools/setup-central-access.sh | bash -s -- ${{ inputs.cluster-with-fake-load-name }}`",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":tada: *Long-running cluster `${{ inputs.cluster-with-fake-load-name }}` created for ${{ inputs.version }} milestone of <${{ github.server_url }}/${{ github.repository }}|${{ github.repository }}>.*"
}
},
{
"type": "divider"
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":arrow_right: Setup your local access to Central by running:\n```./scripts/release-tools/setup-central-access.sh ${{ inputs.cluster-with-fake-load-name }}```\nfrom your local machine."
}
}
]
}
- name: Start fake workload
env:
API_ENDPOINT: localhost:8000
ROX_PASSWORD: ${{ steps.launch-central.outputs.rox-password }}
run: |
kubectl -n stackrox port-forward deploy/central 8000:8443 > /dev/null 2>&1 &
sleep 20
./scale/launch_workload.sh np-load
echo "Fake workload has been deployed to the long-running cluster" >> "$GITHUB_STEP_SUMMARY"
start-secured-cluster:
name: Start secured cluster
needs: [properties, start-acs, create-long-running-cluster-for-real-load]
runs-on: ubuntu-latest
env:
SECURED_CLUSTER_NAME: ${{ inputs.cluster-with-real-load-name }}
KUBECONFIG: artifacts/kubeconfig
INFRA_TOKEN: ${{secrets.INFRA_TOKEN}}
USE_GKE_GCLOUD_AUTH_PLUGIN: "True"
steps:
- uses: stackrox/actions/infra/install-infractl@v1
- name: Test readiness for secured cluster
run: |
STATUS=$(infractl get "${SECURED_CLUSTER_NAME//./-}" --json | jq -r .Status)
if [ "$STATUS" != "READY" ]; then
exit 1
fi
- name: Check out code
uses: actions/checkout@v4
with:
ref: ${{inputs.version}}
repository: stackrox/stackrox
- uses: "google-github-actions/auth@v2"
with:
credentials_json: "${{ secrets.GCP_RELEASE_AUTOMATION_SA }}"
- name: "Set up Cloud SDK"
uses: "google-github-actions/setup-gcloud@v2"
with:
install_components: "gke-gcloud-auth-plugin"
- name: Download artifacts
id: artifacts
run: |
infractl artifacts "${SECURED_CLUSTER_NAME//./-}" -d artifacts
- name: Launch secured cluster
id: launch-secured-cluster
env:
MAIN_IMAGE_TAG: ${{inputs.version}} # Release version, e.g. 3.63.0-rc.2.
REGISTRY_USERNAME: ${{ secrets.QUAY_RHACS_ENG_RO_USERNAME }}
REGISTRY_PASSWORD: ${{ secrets.QUAY_RHACS_ENG_RO_PASSWORD }}
ROX_ADMIN_PASSWORD: ${{ needs.start-acs.outputs.rox-password }}
ROX_ADMIN_USERNAME: admin
CENTRAL_IP: ${{ needs.start-acs.outputs.central-ip }}
CLUSTER_API_ENDPOINT: https://${{ needs.start-acs.outputs.central-ip }}:443
API_ENDPOINT: ${{ needs.start-acs.outputs.central-ip }}:443
CLUSTER: secured-cluster
COLLECTION_METHOD: core_bpf
MONITORING_SUPPORT: "true"
STORAGE: pvc
MONITORING_LOAD_BALANCER: none
COMMON_DIR: ${{ github.workspace }}/deploy/common
run: |
# Overriding COLLECTION_METHOD for 3.x releases because 'core_bpf' was introduced in 4.1.0
# 4.0 is already out of support
# TODO(ROX-20631): remove the override after 3.74 is out of support
if [[ "${MAIN_IMAGE_TAG}" == 3.* ]]; then
export COLLECTION_METHOD="kernel-module"
fi
"${{ github.workspace }}/deploy/k8s/sensor.sh"
kubectl -n stackrox create secret generic access-rhacs \
--from-literal="username=${ROX_ADMIN_USERNAME}" \
--from-literal="password=${ROX_ADMIN_PASSWORD}" \
--from-literal="central_url=${CLUSTER_API_ENDPOINT}"
echo "Deploying Monitoring..."
helm_args=(
--set persistence.type="${STORAGE}"
--set exposure.type="${MONITORING_LOAD_BALANCER}"
)
helm dependency update "${COMMON_DIR}/../charts/monitoring"
envsubst < "${COMMON_DIR}/../charts/monitoring/values.yaml" > "${COMMON_DIR}/../charts/monitoring/values_substituted.yaml"
helm upgrade -n stackrox --install --create-namespace stackrox-monitoring "${COMMON_DIR}/../charts/monitoring" --values "${COMMON_DIR}/../charts/monitoring/values_substituted.yaml" "${helm_args[@]}"
rm "${COMMON_DIR}/../charts/monitoring/values_substituted.yaml"
echo "Deployed Monitoring..."
start-kube-burner:
name: Start kube-burner
needs: [properties, start-secured-cluster]
runs-on: ubuntu-latest
env:
SECURED_CLUSTER_NAME: ${{ inputs.cluster-with-real-load-name }}
KUBECONFIG: ${{ github.workspace }}/artifacts/kubeconfig
INFRA_TOKEN: ${{secrets.INFRA_TOKEN}}
USE_GKE_GCLOUD_AUTH_PLUGIN: "True"
steps:
- uses: stackrox/actions/infra/install-infractl@v1
- name: Check out kube-burner config repository code
uses: actions/checkout@v4
with:
repository: stackrox/${{ inputs.kube-burner-config-repo }}
path: .kube-burner-config
ref: ${{ inputs.kube-burner-config-ref }}
- name: Check out cloud-bulldozer/benchmark-operator code
run: |
git clone https://github.com/cloud-bulldozer/benchmark-operator.git
cd ${{ github.workspace }}/benchmark-operator
git checkout 081359d2a90ba556a603840b18015d10d05a89ec
- name: Checkout local action
uses: actions/checkout@v4
with:
repository: stackrox/actions
path: .actions
ref: ${{ inputs.workflow-ref }}
- uses: "google-github-actions/auth@v2"
with:
credentials_json: "${{ secrets.GCP_RELEASE_AUTOMATION_SA }}"
- name: "Set up Cloud SDK"
uses: "google-github-actions/setup-gcloud@v2"
with:
install_components: "gke-gcloud-auth-plugin"
- name: Download artifacts
id: artifacts
run: |
infractl artifacts "${SECURED_CLUSTER_NAME//./-}" -d ${{ github.workspace }}/artifacts
- name: Launch kube-burner
id: launch-kube-burner
env:
REGISTRY_USERNAME: ${{ secrets.QUAY_RHACS_ENG_RO_USERNAME }}
REGISTRY_PASSWORD: ${{ secrets.QUAY_RHACS_ENG_RO_PASSWORD }}
uses: ./.actions/release/start-kube-burner
with:
kube-burner-config-dir: ./.kube-burner-config/scripts/release-tools/kube-burner-configs
benchmark-operator-dir: ${{ github.workspace }}/benchmark-operator
notify-failed-clusters:
name: Notify about failed cluster creation
needs:
[
properties,
create-k8s-cluster,
create-os4-cluster,
create-long-running-cluster-for-fake-load,
create-long-running-cluster-for-real-load,
]
if:
>- # Required as create-*-cluster jobs could be skipped while other jobs could fail.
always() && (
needs.create-k8s-cluster.result == 'failure' ||
needs.create-os4-cluster.result == 'failure' ||
needs.create-long-running-cluster-for-fake-load.result == 'failure' ||
needs.create-long-running-cluster-for-real-load.result == 'failure'
)
runs-on: ubuntu-latest
steps:
- name: Post to Slack
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
uses: slackapi/slack-github-action@v1.27.0
with:
channel-id: ${{ needs.properties.outputs.slack-channel }}
payload: >-
{
"text": "Couldn't create test cluster. Check <${{github.server_url}}/${{github.repository}}/actions/runs/${{github.run_id}}|${{github.workflow}}>" for details",
"blocks": [
{ "type": "section", "text": { "type": "mrkdwn", "text":
":red_circle: *Couldn't create test clusters for ${{inputs.version}} milestone of <${{github.server_url}}/${{github.repository}}|${{github.repository}}>.*" }},
{ "type": "divider" },
{ "type": "section", "text": { "type": "mrkdwn", "text":
":arrow_right: *Please investigate the output of the
<${{github.server_url}}/${{github.repository}}/actions/runs/${{github.run_id}}|${{github.workflow}}>
workflow run and then restart the workflow.*" }},
{ "type": "section", "text": { "type": "mrkdwn", "text":
">
Repository: <${{github.server_url}}/${{github.repository}}|${{github.repository}}>\n>
Milestone: ${{inputs.version}}\n>
Workflow: <${{github.server_url}}/${{github.repository}}/actions/runs/${{github.run_id}}|${{github.workflow}}>" }}
]}