-
Notifications
You must be signed in to change notification settings - Fork 2
/
outer.nomad
54 lines (46 loc) · 1008 Bytes
/
outer.nomad
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
job "outer_service" {
datacenters = ["us-east-1"]
group "service" {
count = 2
spread {
attribute = "${node.unique.id}"
}
network {
port "http" {
to = 4001
}
}
service {
name = "outer"
provider = "nomad"
port = "http"
address = "${attr.unique.platform.aws.public-ipv4}"
tags = [
"traefik.enable=true",
"traefik.http.routers.http.rule=Path(`/outer`)"
]
}
task "curler" {
driver = "docker"
config {
image = "mnomitch/curler"
ports = ["http"]
}
env {
PORT = 4001
}
# This gets a list of the addresses for inner-service and selects the first to query
template {
data = <<EOH
{{- range $index, $service := nomadService "inner" }}
{{- if eq $index 0}}
CURL_ADDR="http://{{.Address}}:{{.Port}}"
{{- end }}
{{- end }}
EOH
destination = "local/file.env"
env = true
}
}
}
}