-
Notifications
You must be signed in to change notification settings - Fork 2
373 lines (334 loc) · 16.1 KB
/
prepare-vs-install.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
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
name: Prepare-Streaming-Cluster-Install
on:
schedule:
- cron: '0 0 * * 1'
workflow_dispatch:
inputs:
cloud_provider:
default: aws-cn
required: true
type: string
region:
default: cn-northwest-1
required: true
type: string
uninstall:
default: false
required: true
type: boolean
execute_benchmark:
default: false
required: true
type: boolean
jobs:
prepare_automq_env:
environment: ${{ inputs.cloud_provider || 'aws-cn' }}
name: Prepare AutoMQ Environment
runs-on: ubuntu-latest
env:
STREAMING_PROVIDER: automq
CLOUD_PROVIDER: ${{ inputs.cloud_provider || 'aws-cn' }}
REGION: ${{ inputs.region || 'cn-northwest-1' }}
outputs:
benchmark_result_json_automq: ${{ steps.shared-automq.outputs.benchmark_result_json_automq }}
extracted_data_automq: ${{ steps.shared-automq.outputs.extracted_data_automq }}
baseline_cost_automq: ${{ steps.shared-automq.outputs.baseline_cost_automq }}
usage_cost_automq: ${{ steps.shared-automq.outputs.usage_cost_automq }}
total_cost_automq: ${{ steps.shared-automq.outputs.total_cost_automq }}
steps:
- name: Hello World
run: echo "Hello World"
- name: Checkout Benchmark Code
uses: actions/checkout@v3
- name: Cache local Maven repository
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
# Composition action can't access secrets input, so we inline related step here
- name: Fetch Latest Data
shell: bash
run: |
git pull origin main
- name: Build Benchmark Code
shell: bash
run: |
mvn clean package -Dlicense.skip=true -Dcheckstyle.skip -DskipTests -Dspotless.check.skip
- name: Apply Variables and Secrets for Shared Files
shell: bash
run: |
echo "current path is: $(pwd)"
sed -i "s/\${AUTOMQ_ENVID}/${{ env.STREAMING_PROVIDER }}/g" "driver-nats/deploy/provision-nats-aws.tf"
sed -i "s/\${AUTOMQ_ENVID}/${{ env.STREAMING_PROVIDER }}/g" "driver-pravega/deploy/provision-pravega-aws.tf"
sed -i "s/\${AUTOMQ_ENVID}/${{ env.STREAMING_PROVIDER }}/g" "driver-shared/deploy/${{ env.CLOUD_PROVIDER }}/provision-kafka-aws.tf"
sed -i "s/\${AUTOMQ_ENVID}/${{ env.STREAMING_PROVIDER }}/g" "driver-shared/deploy/${{ env.CLOUD_PROVIDER }}/ansible.cfg"
- name: Apply Variables and Secrets for Streaming Provider
working-directory: driver-shared/deploy/${{ env.CLOUD_PROVIDER }}
## Set AK/SK and terraform s3 backend info
shell: bash
run: |
echo "current path is: $(pwd)"
sed -i "s/\${TF_BACKEND_BUCKET}/$TF_BACKEND_BUCKET/g" "provision-kafka-aws.tf"
sed -i "s/\${TF_BACKEND_KEY}/$TF_BACKEND_KEY-${{ env.CLOUD_PROVIDER }}-${{ env.STREAMING_PROVIDER }}/g" "provision-kafka-aws.tf"
sed -i "s/\${TF_BACKEND_REGION}/$REGION/g" "provision-kafka-aws.tf"
sed -i "s/\${AUTOMQ_ACCESS_KEY}/${{ secrets.AUTOMQ_ACCESS_KEY }}/g" "provision-kafka-aws.tf"
sed -i "s/\${AUTOMQ_SECRET_KEY}/${{ secrets.AUTOMQ_SECRET_KEY }}/g" "provision-kafka-aws.tf"
env:
## sed match only support ENV rather than expression like ${{ secrets.TF_BACKEND_BUCKET }}
TF_BACKEND_BUCKET: ${{ secrets.TF_BACKEND_BUCKET }}
TF_BACKEND_KEY: ${{ secrets.TF_BACKEND_KEY }}
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AUTOMQ_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AUTOMQ_SECRET_KEY }}
aws-region: ${{ inputs.region || 'cn-northwest-1' }}
- name: Setup SSH key
shell: bash
run: |
mkdir -p ~/.ssh
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/kpc_sshkey
echo "${{ secrets.SSH_PUBLIC_KEY }}" > ~/.ssh/kpc_sshkey.pub
chmod 600 ~/.ssh/kpc_sshkey
chmod 644 ~/.ssh/kpc_sshkey.pub
- name: Install python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Setup Infra Cost
shell: bash
run: |
# Downloads the CLI based on your OS/arch and puts it in /usr/local/bin
curl -fsSL https://raw.githubusercontent.com/infracost/infracost/master/scripts/install.sh | sh
infracost --version
infracost configure set api_key ${{ secrets.INFRA_COST_API_KEY }}
- name: AWS Cost Estimate
shell: bash
run: |
echo "[INFO] Provider is AutoMQ"
cd driver-shared/deploy/${{ env.CLOUD_PROVIDER }}
infracost breakdown --path . --usage-file $GITHUB_WORKSPACE/infracost/${{ env.STREAMING_PROVIDER }}-medium-500m.yml --terraform-var-file $GITHUB_WORKSPACE/driver-automq/deploy/aws-cn/var.tfvars >> /tmp/aws-cost.txt
COST_DETAIL_FILE=/tmp/aws-cost.txt
cat $COST_DETAIL_FILE
- name: Execute Shared Steps
id: shared-automq
uses: ./.github/actions/prepare-vs-shared
with:
streaming_provider: automq
automq_access_key: ${{ secrets.AUTOMQ_ACCESS_KEY }}
automq_secret_key: ${{ secrets.AUTOMQ_SECRET_KEY }}
tf_backend_bucket: ${{ secrets.TF_BACKEND_BUCKET }}
tf_backend_key: ${{ secrets.TF_BACKEND_KEY }}-${{ inputs.cloud_provider || 'aws-cn' }}
region: ${{ inputs.region || 'cn-northwest-1' }}
cloud_provider: ${{ inputs.cloud_provider || 'aws-cn' }}
ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }}
ssh_public_key: ${{ secrets.SSH_PUBLIC_KEY }}
infra_cost_api_key: ${{ secrets.INFRA_COST_API_KEY }}
uninstall: ${{ inputs.uninstall || false }}
execute_benchmark: ${{ inputs.execute_benchmark || false }}
prepare_kafka_env:
environment: ${{ inputs.cloud_provider || 'aws-cn' }}
name: Prepare Kafka Environment
runs-on: ubuntu-latest
env:
STREAMING_PROVIDER: kafka
CLOUD_PROVIDER: ${{ inputs.cloud_provider || 'aws-cn' }}
REGION: ${{ inputs.region || 'cn-northwest-1' }}
outputs:
benchmark_result_json_kafka: ${{ steps.shared-kafka.outputs.benchmark_result_json_kafka }}
extracted_data_kafka: ${{ steps.shared-kafka.outputs.extracted_data_kafka }}
baseline_cost_kafka: ${{ steps.shared-kafka.outputs.baseline_cost_kafka }}
usage_cost_kafka: ${{ steps.shared-kafka.outputs.usage_cost_kafka }}
total_cost_kafka: ${{ steps.shared-kafka.outputs.total_cost_kafka }}
steps:
- name: Hello World
run: echo "Hello World"
- name: Checkout Benchmark Code
uses: actions/checkout@v3
- name: Cache local Maven repository
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
# Composition action can't access secrets input, so we inline related step here
- name: Fetch Latest Data
shell: bash
run: |
git pull origin main
- name: Build Benchmark Code
shell: bash
run: |
mvn clean package -Dlicense.skip=true -Dcheckstyle.skip -DskipTests -Dspotless.check.skip
- name: Apply Variables and Secrets for Shared Files
shell: bash
run: |
echo "current path is: $(pwd)"
sed -i "s/\${AUTOMQ_ENVID}/${{ env.STREAMING_PROVIDER }}/g" "driver-nats/deploy/provision-nats-aws.tf"
sed -i "s/\${AUTOMQ_ENVID}/${{ env.STREAMING_PROVIDER }}/g" "driver-pravega/deploy/provision-pravega-aws.tf"
sed -i "s/\${AUTOMQ_ENVID}/${{ env.STREAMING_PROVIDER }}/g" "driver-shared/deploy/${{ env.CLOUD_PROVIDER }}/provision-kafka-aws.tf"
sed -i "s/\${AUTOMQ_ENVID}/${{ env.STREAMING_PROVIDER }}/g" "driver-shared/deploy/${{ env.CLOUD_PROVIDER }}/ansible.cfg"
- name: Apply Variables and Secrets for Streaming Provider
working-directory: driver-shared/deploy/${{ env.CLOUD_PROVIDER }}
## Set AK/SK and terraform s3 backend info
shell: bash
run: |
echo "current path is: $(pwd)"
sed -i "s/\${TF_BACKEND_BUCKET}/$TF_BACKEND_BUCKET/g" "provision-kafka-aws.tf"
sed -i "s/\${TF_BACKEND_KEY}/$TF_BACKEND_KEY-${{ env.CLOUD_PROVIDER }}-${{ env.STREAMING_PROVIDER }}/g" "provision-kafka-aws.tf"
sed -i "s/\${TF_BACKEND_REGION}/$REGION/g" "provision-kafka-aws.tf"
sed -i "s/\${AUTOMQ_ACCESS_KEY}/${{ secrets.AUTOMQ_ACCESS_KEY }}/g" "provision-kafka-aws.tf"
sed -i "s/\${AUTOMQ_SECRET_KEY}/${{ secrets.AUTOMQ_SECRET_KEY }}/g" "provision-kafka-aws.tf"
env:
## sed match only support ENV rather than expression like ${{ secrets.TF_BACKEND_BUCKET }}
TF_BACKEND_BUCKET: ${{ secrets.TF_BACKEND_BUCKET }}
TF_BACKEND_KEY: ${{ secrets.TF_BACKEND_KEY }}
REGION: ${{ inputs.region || 'cn-northwest-1' }}
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AUTOMQ_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AUTOMQ_SECRET_KEY }}
aws-region: ${{ inputs.region || 'cn-northwest-1' }}
- name: Setup SSH key
shell: bash
run: |
mkdir -p ~/.ssh
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/kpc_sshkey
echo "${{ secrets.SSH_PUBLIC_KEY }}" > ~/.ssh/kpc_sshkey.pub
chmod 600 ~/.ssh/kpc_sshkey
chmod 644 ~/.ssh/kpc_sshkey.pub
- name: Install python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Setup Infra Cost
shell: bash
run: |
# Downloads the CLI based on your OS/arch and puts it in /usr/local/bin
curl -fsSL https://raw.githubusercontent.com/infracost/infracost/master/scripts/install.sh | sh
infracost --version
infracost configure set api_key ${{ secrets.INFRA_COST_API_KEY }}
- name: AWS Cost Estimate
shell: bash
run: |
echo "[INFO] Provider is AutoMQ"
cd driver-shared/deploy/${{ env.CLOUD_PROVIDER }}
infracost breakdown --path . --usage-file $GITHUB_WORKSPACE/infracost/${{ env.STREAMING_PROVIDER }}-medium-500m.yml --terraform-var-file $GITHUB_WORKSPACE/driver-kafka/deploy/aws-cn/var.tfvars >> /tmp/aws-cost.txt
COST_DETAIL_FILE=/tmp/aws-cost.txt
cat $COST_DETAIL_FILE
- name: Execute Shared Steps
id: shared-kafka
uses: ./.github/actions/prepare-vs-shared
with:
streaming_provider: kafka
automq_access_key: ${{ secrets.AUTOMQ_ACCESS_KEY }}
automq_secret_key: ${{ secrets.AUTOMQ_SECRET_KEY }}
tf_backend_bucket: ${{ secrets.TF_BACKEND_BUCKET }}
tf_backend_key: ${{ secrets.TF_BACKEND_KEY }}-${{ inputs.cloud_provider || 'aws-cn' }}
region: ${{ inputs.region || 'cn-northwest-1' }}
cloud_provider: ${{ inputs.cloud_provider || 'aws-cn' }}
ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }}
ssh_public_key: ${{ secrets.SSH_PUBLIC_KEY }}
infra_cost_api_key: ${{ secrets.INFRA_COST_API_KEY }}
uninstall: ${{ inputs.uninstall || false }}
execute_benchmark: ${{ inputs.execute_benchmark || false }}
prepare_msk_env:
environment: ${{ inputs.cloud_provider || 'aws-cn' }}
name: Prepare MSK Environment
runs-on: ubuntu-latest
env:
STREAMING_PROVIDER: msk
CLOUD_PROVIDER: ${{ inputs.cloud_provider || 'aws-cn' }}
REGION: ${{ inputs.region || 'cn-northwest-1' }}
steps:
- name: Checkout Benchmark Code
uses: actions/checkout@v3
- name: Cache local Maven repository
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
# Composition action can't access secrets input, so we inline related step here
- name: Fetch Latest Data
shell: bash
run: |
git pull origin main
- name: Build Benchmark Code
shell: bash
run: |
mvn clean package -Dlicense.skip=true -Dcheckstyle.skip -DskipTests -Dspotless.check.skip
- name: Download Kafka Code For Elasticity Benchmark
working-directory: workflow_scripts/bin
shell: bash
run: |
wget https://archive.apache.org/dist/kafka/3.7.0/kafka_2.13-3.7.0.tgz
- name: Apply Variables and Secrets for Streaming Provider
working-directory: driver-msk/deploy/${{ env.CLOUD_PROVIDER }}
## Set AK/SK and terraform s3 backend info
shell: bash
run: |
echo "current path is: $(pwd)"
sed -i "s/\${TF_BACKEND_BUCKET}/$TF_BACKEND_BUCKET/g" "provision-kafka-aws.tf"
sed -i "s/\${TF_BACKEND_KEY}/$TF_BACKEND_KEY-${{ env.CLOUD_PROVIDER }}-${{ env.STREAMING_PROVIDER }}/g" "provision-kafka-aws.tf"
sed -i "s/\${TF_BACKEND_REGION}/$REGION/g" "provision-kafka-aws.tf"
sed -i "s/\${AUTOMQ_ACCESS_KEY}/${{ secrets.AUTOMQ_ACCESS_KEY }}/g" "provision-kafka-aws.tf"
sed -i "s/\${AUTOMQ_SECRET_KEY}/${{ secrets.AUTOMQ_SECRET_KEY }}/g" "provision-kafka-aws.tf"
env:
## sed match only support ENV rather than expression like ${{ secrets.TF_BACKEND_BUCKET }}
TF_BACKEND_BUCKET: ${{ secrets.TF_BACKEND_BUCKET }}
TF_BACKEND_KEY: ${{ secrets.TF_BACKEND_KEY }}
REGION: ${{ inputs.region || 'cn-northwest-1' }}
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AUTOMQ_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AUTOMQ_SECRET_KEY }}
aws-region: ${{ inputs.region || 'cn-northwest-1' }}
- name: Setup SSH key
shell: bash
run: |
mkdir -p ~/.ssh
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/kpc_sshkey
echo "${{ secrets.SSH_PUBLIC_KEY }}" > ~/.ssh/kpc_sshkey.pub
chmod 600 ~/.ssh/kpc_sshkey
chmod 644 ~/.ssh/kpc_sshkey.pub
- name: Install python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Setup Infra Cost
shell: bash
run: |
# Downloads the CLI based on your OS/arch and puts it in /usr/local/bin
curl -fsSL https://raw.githubusercontent.com/infracost/infracost/master/scripts/install.sh | sh
infracost --version
infracost configure set api_key ${{ secrets.INFRA_COST_API_KEY }}
- name: AWS Cost Estimate
shell: bash
run: |
cd driver-${{ env.STREAMING_PROVIDER }}/deploy/${{ env.CLOUD_PROVIDER }}
infracost breakdown --path . --usage-file $GITHUB_WORKSPACE/infracost/${{ env.STREAMING_PROVIDER }}-medium-500m.yml --terraform-var-file $GITHUB_WORKSPACE/driver-${{ env.STREAMING_PROVIDER }}/deploy/aws-cn/var.tfvars >> /tmp/aws-cost.txt
COST_DETAIL_FILE=/tmp/aws-cost.txt
cat $COST_DETAIL_FILE
- name: Execute Shared Steps
id: shared-msk
uses: ./.github/actions/prepare-vs-shared-tf
with:
streaming_provider: ${{ env.STREAMING_PROVIDER }}
automq_access_key: ${{ secrets.AUTOMQ_ACCESS_KEY }}
automq_secret_key: ${{ secrets.AUTOMQ_SECRET_KEY }}
tf_backend_bucket: ${{ secrets.TF_BACKEND_BUCKET }}
tf_backend_key: ${{ secrets.TF_BACKEND_KEY }}-${{ inputs.cloud_provider || 'aws-cn' }}
region: ${{ inputs.region || 'cn-northwest-1' }}
cloud_provider: ${{ inputs.cloud_provider || 'aws-cn' }}
ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }}
ssh_public_key: ${{ secrets.SSH_PUBLIC_KEY }}
infra_cost_api_key: ${{ secrets.INFRA_COST_API_KEY }}
uninstall: ${{ inputs.uninstall || false }}
execute_benchmark: ${{ inputs.execute_benchmark || false }}