forked from argoproj/argo-workflows
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwork-avoidance.yaml
109 lines (103 loc) · 2.67 KB
/
work-avoidance.yaml
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
# This example shows how to use a PVC and optional input artifacts to avoid work.
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: work-avoidance-
spec:
entrypoint: main
volumeClaimTemplates:
- metadata:
name: work
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: 10Mi
onExit: save-markers
templates:
- name: main
steps:
- - name: load-markers
template: load-markers
- - name: echo
template: echo
arguments:
parameters:
- name: num
value: "{{item}}"
withSequence:
count: "3"
- name: load-markers
inputs:
artifacts:
- name: markers
path: /work/markers
optional: true
s3:
key: work-avoidance-markers
bucket: my-bucket
endpoint: minio:9000
insecure: true
accessKeySecret:
name: my-minio-cred
key: accesskey
secretKeySecret:
name: my-minio-cred
key: secretkey
container:
image: docker/whalesay:latest
command:
- mkdir
- -p
- /work/markers
volumeMounts:
- name: work
mountPath: /work
- name: echo
inputs:
parameters:
- name: num
script:
image: docker/whalesay:latest
command:
- bash
- -eux
source: |
marker=/work/markers/$(date +%Y-%m-%d)-echo-{{inputs.parameters.num}}
if [ -e ${marker} ]; then
echo "work already done"
exit 0
fi
echo "working very hard"
# toss a virtual coin and exit 1 if 1
if [ $(($(($RANDOM%10))%2)) -eq 1 ]; then
echo "oh no!"
exit 1
fi
touch ${marker}
volumeMounts:
- name: work
mountPath: /work
- name: save-markers
container:
image: docker/whalesay:latest
command:
- "true"
volumeMounts:
- name: work
mountPath: /work
outputs:
artifacts:
- name: markers
path: /work/markers
s3:
key: work-avoidance-markers
bucket: my-bucket
endpoint: minio:9000
insecure: true
accessKeySecret:
name: my-minio-cred
key: accesskey
secretKeySecret:
name: my-minio-cred
key: secretkey