-
Notifications
You must be signed in to change notification settings - Fork 2
/
fan-out-fan-in.hcl
140 lines (108 loc) · 2.27 KB
/
fan-out-fan-in.hcl
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
variable "datacenters" {
type = list(string)
default = ["dc1"]
}
variable "image" {
type = string
default = "ghcr.io/hyperbadger/nomad-pipeline:main"
}
variable "nomad_addr" {
type = string
default = "http://host.docker.internal:4646"
}
variable "docker_extra_hosts" {
type = list(string)
default = ["host.docker.internal:host-gateway"]
}
job "fan-out-fan-in" {
name = "fan-out-fan-in"
datacenters = var.datacenters
type = "batch"
meta = {
"nomad-pipeline.enabled" = "true"
}
group "▶️" {
task "init" {
driver = "docker"
config {
image = var.image
args = ["agent", "init"]
extra_hosts = var.docker_extra_hosts
auth_soft_fail = true
}
env {
NOMAD_ADDR = var.nomad_addr
NOMAD_PIPELINE_DEBUG = "true"
}
}
}
group "1-submit-tasks" {
count = 0
meta = {
"nomad-pipeline.root" = "true"
"nomad-pipeline.next" = "2-do-work"
}
task "submit" {
driver = "raw_exec"
config {
command = "/bin/bash"
args = ["local/main.sh"]
}
template {
data = <<-EOT
#!/bin/bash
sleep 5
echo "alot of work" > queue
EOT
destination = "local/main.sh"
}
}
}
group "2-do-work" {
count = 0
meta = {
"nomad-pipeline.count" = "5"
"nomad-pipeline.next" = "3-process-output"
}
scaling {
enabled = true
max = 10
}
task "work" {
driver = "raw_exec"
config {
command = "/bin/bash"
args = ["local/main.sh"]
}
template {
data = <<-EOT
#!/bin/bash
echo "pick things off queue and do work"
# sleep 10
sleep $((5 + RANDOM % 20));
EOT
destination = "local/main.sh"
}
}
}
group "3-process-output" {
count = 0
meta = {
"nomad-pipeline.dependencies" = "2-do-work"
}
task "process" {
driver = "raw_exec"
config {
command = "/bin/bash"
args = ["local/main.sh"]
}
template {
data = <<-EOT
#!/bin/bash
echo "process output of work"
EOT
destination = "local/main.sh"
}
}
}
}