-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcountdash.nomad
103 lines (91 loc) · 2.62 KB
/
countdash.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# example from https://developer.hashicorp.com/nomad/tutorials/integrate-consul/consul-service-mesh
# modified to accomodate for caddy and prometheus configurations. Has 2 tasks, both with sidecar
# proxies and one upstream from the other
job "countdash" {
datacenters = ["dc1"]
group "api" {
network {
mode = "bridge"
# port used to expose envoy's prometheus metrics
# endpoint, dynamically set by nomad
port "prom" {}
}
service {
name = "count-api"
port = "9001"
meta {
# meta tag that nomad will set in the consul service of the
# sidecar proxy which is used by prometheus to find the port
# to communicate with
prometheus_port = "${NOMAD_HOST_PORT_prom}"
}
connect {
sidecar_service {
proxy {
config {
# tells envoy that where to expose it's metrics endpoint
envoy_prometheus_bind_addr = "0.0.0.0:${NOMAD_PORT_prom}"
}
}
}
}
}
task "api" {
driver = "docker"
config {
image = "hashicorpnomad/counter-api:v1"
}
}
}
group "dashboard" {
network {
mode = "bridge"
# port used to expose envoy's prometheus metrics
# endpoint, dynamically set by nomad
port "prom" {}
port "http" {
static = 9002
to = 9002
}
}
service {
name = "count-dashboard"
port = "9002"
# consul-template will find this tag and use it to create a
# caddy config that serves this service
# tag finder subdomain port to serve
# | | |
# |----------|-------|-----------------------|
tags = ["userfacing:counter:${NOMAD_HOST_PORT_http}"]
meta {
# meta tag that nomad will set in the consul service of the
# sidecar proxy which is used by prometheus to find the port
# to communicate with
prometheus_port = "${NOMAD_HOST_PORT_prom}"
}
connect {
sidecar_service {
proxy {
config {
# tells envoy that where to expose it's metrics endpoint
envoy_prometheus_bind_addr = "0.0.0.0:${NOMAD_PORT_prom}"
}
upstreams {
destination_name = "count-api"
local_bind_port = 8080
}
}
}
}
}
task "dashboard" {
driver = "docker"
env {
COUNTING_SERVICE_URL = "http://${NOMAD_UPSTREAM_ADDR_count_api}"
}
config {
image = "hashicorpnomad/counter-dashboard:v1"
}
}
}
}