forked from GuyBarros/nomad_jobs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconsul-resolvers.nomad
85 lines (64 loc) · 1.25 KB
/
consul-resolvers.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
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
job "Consul-Resolvers" {
datacenters = ["eu-west-2","eu-west-1","eu-west-3","ukwest","sa-east-1","ap-northeast-1","dc1","europe-west3-dc"]
type = "batch"
task "resolver-for-countapi" {
driver = "exec"
template {
data = <<EOH
set -v
cat << EOF > proxy-defaults.json
{
"Kind": "proxy-defaults",
"Name": "global",
"MeshGateway" : {
"mode" : "local"
}
}
EOF
cat << EOF > count-api.hcl
Kind = "service-defaults"
Name = "count-api"
Protocol = "http"
MeshGateway = {
mode = "local"
}
EOF
cat << EOF > count-api-resolver.hcl
kind = "service-resolver"
name = "count-api"
redirect {
service = "count-api"
datacenter = "eu-west-2"
}
EOF
cat << EOF > mongodb.hcl
Kind = "service-defaults"
Name = "mongodb"
Protocol = "http"
MeshGateway = {
mode = "local"
}
EOF
cat << EOF > mongodb-resolver.hcl
kind = "service-resolver"
name = "mongodb"
redirect {
service = "mongodb"
datacenter = "eu-west-2"
}
EOF
consul config write proxy-defaults.json
consul config write count-api.hcl
consul config write count-api-resolver.hcl
consul config write mongodb.hcl
consul config write mongodb-resolver.hcl
EOH
destination = "script.sh"
perms = "755"
}
config {
command = "bash"
args = ["script.sh"]
}
}
}