-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparallel-aggregate-workflow.yml
94 lines (87 loc) · 2.56 KB
/
parallel-aggregate-workflow.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
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: parallel-aggregate-workflow-
spec:
entrypoint: run-parallel-aggregate-workflow
volumeClaimTemplates:
- metadata:
name: results
spec:
accessModes: ["ReadWriteMany"]
resources:
requests:
storage: 1Gi
templates:
- name: run-parallel-aggregate-workflow
dag:
tasks:
- name: nginx-server
template: nginx-server
- name: extract-files
template: glob-files
- name: run-file
dependencies: [nginx-server, extract-files]
template: compute-result
arguments:
parameters:
- name: nginx-server-ip
value: "{{tasks.nginx-server.ip}}"
- name: file
value: "{{item}}"
withParam: "{{tasks.extract-files.outputs.result}}"
- name: produce-aggregate-results
dependencies: [run-file]
template: aggregate-results
- name: nginx-server
daemon: true
container:
image: nginx:latest
readinessProbe:
httpGet:
path: /
port: 80
initialDelaySeconds: 2
timeoutSeconds: 1
- name: glob-files
script:
image: node:lts-alpine
command: [node]
source: |
const cp = require('child_process');
const files = cp.execSync("find . -name '*.conf'").toString();
console.log(
JSON.stringify(
files.split('\n').filter(Boolean)
)
);
- name: compute-result
inputs:
parameters:
- name: nginx-server-ip
- name: file
container:
image: byrnedo/alpine-curl:latest
command: [sh, -c]
args:
[
'curl http://{{inputs.parameters.nginx-server-ip}}:80 && echo "{{inputs.parameters.file}} ($(echo -n {{inputs.parameters.file}} | wc -m | xargs))" | tee /results/result-{{pod.name}}.txt',
]
volumeMounts:
- name: results
mountPath: /results
- name: aggregate-results
container:
image: alpine:latest
command: [sh, -c]
args: ["cat /results/* > /tmp/aggregated-results.txt"]
volumeMounts:
- name: results
mountPath: /results
outputs:
artifacts:
- name: aggregated-results
globalName: aggregated-results
path: /tmp/aggregated-results.txt
archive:
none: {}