-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompose.yaml
260 lines (236 loc) · 7.43 KB
/
compose.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
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
# Interpolation does not appear to be supported on top level name.
# Would like to use ${CONSUL_DATACENTER:-dc1}, but will pass -p flag
# instead as workaround.
name: dc1
services:
consul-server:
image: ${CONSUL_IMAGE}:${CONSUL_VERSION}
deploy:
replicas: 3
command:
- "agent"
- "-config-dir=/consul/config"
- "-bootstrap-expect=3"
- "-datacenter=${COMPOSE_PROJECT_NAME}"
- "-retry-join=${COMPOSE_PROJECT_NAME}-consul-server-1"
- "-retry-join=${COMPOSE_PROJECT_NAME}-consul-server-2"
- "-retry-join=${COMPOSE_PROJECT_NAME}-consul-server-3"
- "-retry-join-wan=consul-server-wan"
restart: unless-stopped
environment:
CONSUL_LICENSE_PATH: /consul/license/consul.hclic
#CONSUL_HTTP_ADDR: "https://localhost:8501"
configs:
- source: server_config
target: /consul/config/server.hcl
secrets:
- source: enterprise_license
target: /consul/license/consul.hclic
- source: ca_cert
target: /consul/tls/consul-agent-ca.pem
networks:
lan_serf:
wan_serf:
aliases:
- consul-server-wan
ports:
- "8500/tcp" #TODO remove & update hcl
- "8501/tcp"
# consul-gateway:
# image: ${CONSUL_IMAGE}:${CONSUL_VERSION}
# configs:
# - mesh_gateway_config
# - ingress_gateway_config
# - terminating_gateway_config
# depends_on:
# - consul-server
# General NOTE: DNS -
# For application services we are relying on Docker's embedded DNS server to join the consul cluster.
# The embedded DNS server leverages consul as a recursor, along with google for anything external.
# Food for thought - I don't think compose has the capability to scale multiple services
# together.. nor is it probably intended to.
counting:
image: hashicorp/counting-service:0.0.2 # NOTE image tagged as linux/amd64 but will work on arm64
restart: unless-stopped
environment:
PORT: 9001
networks:
- lan_serf
dns: 127.0.0.1
consul-client-counting:
image: ${CONSUL_IMAGE}:${CONSUL_VERSION}
command: "agent -config-dir=/consul/config -datacenter ${COMPOSE_PROJECT_NAME} -retry-join=${COMPOSE_PROJECT_NAME}-consul-server-1"
restart: unless-stopped
environment:
CONSUL_LICENSE_PATH: /consul/license/consul.hclic
configs:
- source: client_config
target: /consul/config/client.hcl
- source: counting_config
target: /consul/config/counting.hcl
secrets:
- source: enterprise_license
target: /consul/license/consul.hclic
network_mode: "service:counting"
depends_on:
- consul-server
consul-copy-bin-counting:
image: ${CONSUL_IMAGE}:${CONSUL_VERSION}
command:
- "/bin/sh"
- "-ec"
- "cp /bin/consul /consul/connect-inject/consul"
volumes:
- consul_bin_counting:/consul/connect-inject:rw
network_mode: none
envoyproxy-counting:
image: ${ENVOY_IMAGE}:${ENVOY_VERSION}
command:
- "/consul/connect-inject/consul"
- "connect"
- "envoy"
- "-sidecar-for"
- "counting"
restart: unless-stopped
volumes:
- consul_bin_counting:/consul/connect-inject:ro
network_mode: "service:counting"
depends_on:
- consul-copy-bin-counting
consul-update-dns-counting:
image: nicolaka/netshoot:v0.7
privileged: true
command:
- "/bin/sh"
- "-c"
- "iptables -t nat -A OUTPUT -d localhost -p udp -m udp --dport 53 -j REDIRECT --to-ports 8600 && \
iptables -t nat -A OUTPUT -d localhost -p tcp -m tcp --dport 53 -j REDIRECT --to-ports 8600" # && \
# while true ; do sleep 1800 ; done"
network_mode: "service:counting"
depends_on:
- consul-client-counting
#netshoot-counting:
# image: nicolaka/netshoot:v0.7
# command:
# - "/bin/sh"
# - "-c"
# - "while true ; do sleep 86400; done"
# restart: unless-stopped
# privileged: true
# network_mode: "service:counting"
# -- DASHBOARD SERVICE --
dashboard:
image: hashicorp/dashboard-service:0.0.4 # NOTE image tagged as linux/amd64 but will work on arm64
restart: unless-stopped
environment:
PORT: 8000
#COUNTING_SERVICE_URL: 'http://counting.service.consul:9001' #TODO force over the mesh
COUNTING_SERVICE_URL: 'http://127.0.0.1:9001'
networks:
- lan_serf
dns: 127.0.0.1
ports:
- "8000/tcp" # dashboard service
consul-client-dashboard:
image: ${CONSUL_IMAGE}:${CONSUL_VERSION}
command: "agent -config-dir=/consul/config -datacenter ${COMPOSE_PROJECT_NAME} -retry-join=${COMPOSE_PROJECT_NAME}-consul-server-1"
restart: unless-stopped
environment:
CONSUL_LICENSE_PATH: /consul/license/consul.hclic
configs:
- source: client_config
target: /consul/config/client.hcl
- source: dashboard_config
target: /consul/config/dashboard.hcl
secrets:
- source: enterprise_license
target: /consul/license/consul.hclic
network_mode: "service:dashboard"
depends_on:
- consul-server
consul-copy-bin-dashboard:
image: ${CONSUL_IMAGE}:${CONSUL_VERSION}
command:
- "/bin/sh"
- "-ec"
- "cp /bin/consul /consul/connect-inject/consul"
volumes:
- consul_bin_counting:/consul/connect-inject:rw
network_mode: none
consul-update-dns-dashboard:
image: nicolaka/netshoot:v0.7
privileged: true
command:
- "/bin/sh"
- "-c"
- "iptables -t nat -A OUTPUT -d localhost -p udp -m udp --dport 53 -j REDIRECT --to-ports 8600 && \
iptables -t nat -A OUTPUT -d localhost -p tcp -m tcp --dport 53 -j REDIRECT --to-ports 8600" # && \
# while true ; do sleep 1800 ; done"
network_mode: "service:dashboard"
depends_on:
- consul-client-dashboard
envoyproxy-dashboard:
image: ${ENVOY_IMAGE}:${ENVOY_VERSION}
command:
- "/consul/connect-inject/consul"
- "connect"
- "envoy"
- "-sidecar-for"
- "dashboard"
restart: unless-stopped
volumes:
- consul_bin_counting:/consul/connect-inject:ro
network_mode: "service:dashboard"
depends_on:
- consul-copy-bin-dashboard
#netshoot-dashboard:
# image: nicolaka/netshoot:v0.7
# command:
# - "/bin/sh"
# - "-c"
# - "while true ; do sleep 86400; done"
# restart: unless-stopped
# privileged: true
# network_mode: "service:dashboard"
networks:
lan_serf:
driver: bridge
driver_opts:
com.docker.network.bridge.enable_ip_masquerade: 'true'
com.docker.network.driver.mtu: 1500
wan_serf:
# override default compose naming scheme so we have a single 'wan_serf'
# routable network across all consul datacenters
name: wan_serf
driver: bridge
driver_opts:
com.docker.network.bridge.enable_ip_masquerade: 'true'
com.docker.network.driver.mtu: 1500
ipam:
config:
- subnet: ${WAN_SERF:-10.100.0.0/16}
volumes:
consul_bin_counting:
driver: local
consul_bin_dashboard:
driver: local
configs:
client_config:
file: "./hcl/client.hcl"
server_config:
file: "./hcl/server.hcl"
# mesh_gateway_config:
# file: #TODO
# ingress_gateway_config:
# file: #TODO
# terminating_gateway_config:
# file: #TODO
counting_config:
file: "./hcl/counting-service.hcl"
dashboard_config:
file: "./hcl/dashboard-service.hcl"
secrets:
enterprise_license:
file: ${CONSUL_LICENSE_PATH:-/dev/null}
ca_cert:
file: ${CONSUL_CACERT:-./secrets/consul-agent-ca.pem}