-
Notifications
You must be signed in to change notification settings - Fork 153
/
docker-compose.halfstack-ha.yml
226 lines (213 loc) · 6.72 KB
/
docker-compose.halfstack-ha.yml
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
version: "2.4"
services:
backendai-half-db:
image: postgres:15.1-alpine
command: postgres -c 'max_connections=256'
networks:
- half
ports:
- "8100:5432"
environment:
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-develove}
- POSTGRES_DB=${POSTGRES_DBNAME:-backend}
volumes:
- "./tmp/backend.ai-halfstack-ha/postgres-data:/var/lib/postgresql/data:rw"
# Initial master is redis-node01.
backendai-half-redis-node01:
image: redis:7.0.5-alpine
hostname: node01
networks:
- half
ports:
- 0.0.0.0:${REDIS_MASTER_PORT}:${REDIS_MASTER_PORT}
command: >
redis-server
--port ${REDIS_MASTER_PORT}
--requirepass ${REDIS_PASSWORD:-develove}
--masterauth ${REDIS_PASSWORD:-develove}
--replica-announce-ip node01
--replica-announce-port ${REDIS_MASTER_PORT}
--min-slaves-to-write 1
--min-slaves-max-lag 10
# IMPORTANT: We have INTENTIONALLY OMITTED the healthchecks
# because it interferes with pause/unpause of container to simulate
# network partitioning.
backendai-half-redis-node02:
image: redis:7.0.5-alpine
hostname: node02
networks:
- half
ports:
- 0.0.0.0:${REDIS_SLAVE1_PORT}:${REDIS_SLAVE1_PORT}
command: >
redis-server
--port ${REDIS_SLAVE1_PORT}
--requirepass ${REDIS_PASSWORD:-develove}
--masterauth ${REDIS_PASSWORD:-develove}
--slaveof node01 ${REDIS_MASTER_PORT}
--replica-announce-ip node02
--replica-announce-port ${REDIS_SLAVE1_PORT}
--min-slaves-to-write 1
--min-slaves-max-lag 10
backendai-half-redis-node03:
image: redis:7.0.5-alpine
hostname: node03
ports:
- 0.0.0.0:${REDIS_SLAVE2_PORT}:${REDIS_SLAVE2_PORT}
networks:
- half
command: >
redis-server
--port ${REDIS_SLAVE2_PORT}
--requirepass ${REDIS_PASSWORD:-develove}
--masterauth ${REDIS_PASSWORD:-develove}
--slaveof node01 ${REDIS_MASTER_PORT}
--replica-announce-ip node03
--replica-announce-port ${REDIS_SLAVE2_PORT}
--min-slaves-to-write 1
--min-slaves-max-lag 10
backendai-half-redis-sentinel01:
image: redis:7.0.5-alpine
hostname: sentinel01
networks:
- half
volumes:
- type: bind
source: ${COMPOSE_PATH}
target: /config
ports:
- 0.0.0.0:${REDIS_SENTINEL1_PORT}:${REDIS_SENTINEL1_PORT}
depends_on:
- backendai-half-redis-node01
- backendai-half-redis-node02
- backendai-half-redis-node03
command: >
redis-sentinel /config/sentinel01.conf
environment:
- REDIS_PASSWORD=${REDIS_PASSWORD:-develove}
backendai-half-redis-sentinel02:
image: redis:7.0.5-alpine
hostname: sentinel02
networks:
- half
volumes:
- type: bind
source: ${COMPOSE_PATH}
target: /config
ports:
- 0.0.0.0:${REDIS_SENTINEL2_PORT}:${REDIS_SENTINEL2_PORT}
depends_on:
- backendai-half-redis-node01
- backendai-half-redis-node02
- backendai-half-redis-node03
command: >
redis-sentinel /config/sentinel02.conf
environment:
- REDIS_PASSWORD=${REDIS_PASSWORD:-develove}
backendai-half-redis-sentinel03:
image: redis:7.0.5-alpine
hostname: sentinel03
networks:
- half
volumes:
- type: bind
source: ${COMPOSE_PATH}
target: /config
ports:
- 0.0.0.0:${REDIS_SENTINEL3_PORT}:${REDIS_SENTINEL3_PORT}
depends_on:
- backendai-half-redis-node01
- backendai-half-redis-node02
- backendai-half-redis-node03
command: >
redis-sentinel /config/sentinel03.conf
environment:
- REDIS_PASSWORD=${REDIS_PASSWORD:-develove}
backendai-half-etcd-proxy:
image: quay.io/coreos/etcd:v3.5.4
depends_on:
- "backendai-half-etcd-node01"
- "backendai-half-etcd-node02"
- "backendai-half-etcd-node03"
networks:
- half
ports:
- "8220:2379"
environment:
- ENDPOINTS=backendai-half-etcd-node01:2379,backendai-half-etcd-node02:2379,backendai-half-etcd-node03:2379
command: >
sh -c
"/usr/local/bin/etcd grpc-proxy start
--endpoints=$${ENDPOINTS}
--listen-addr=0.0.0.0:2379"
backendai-half-etcd-node01:
image: quay.io/coreos/etcd:v3.5.4
volumes:
- "./tmp/backend.ai-halfstack-ha/etcd01-data:/etcd-data:rw"
networks:
- half
environment:
- MYSELF=backendai-half-etcd-node01
- CLUSTER=etcd-node01=http://backendai-half-etcd-node01:2380,etcd-node02=http://backendai-half-etcd-node02:2380,etcd-node03=http://backendai-half-etcd-node03:2380
- TOKEN=backendai-etcd-token
- STATE=new
command: >
sh -c
"/usr/local/bin/etcd
--name etcd-node01
--data-dir /etcd-data
--listen-client-urls http://0.0.0.0:2379
--listen-peer-urls http://0.0.0.0:2380
--advertise-client-urls http://$${MYSELF}:2379
--initial-advertise-peer-urls http://$${MYSELF}:2380
--initial-cluster $${CLUSTER}
--initial-cluster-token $${TOKEN}
--initial-cluster-state $${STATE}"
backendai-half-etcd-node02:
image: quay.io/coreos/etcd:v3.5.4
volumes:
- "./tmp/backend.ai-halfstack-ha/etcd02-data:/etcd-data:rw"
networks:
- half
environment:
- MYSELF=backendai-half-etcd-node02
- CLUSTER=etcd-node01=http://backendai-half-etcd-node01:2380,etcd-node02=http://backendai-half-etcd-node02:2380,etcd-node03=http://backendai-half-etcd-node03:2380
- TOKEN=backendai-etcd-token
- STATE=new
command: >
sh -c
"/usr/local/bin/etcd
--name etcd-node02
--data-dir /etcd-data
--listen-client-urls http://0.0.0.0:2379
--listen-peer-urls http://0.0.0.0:2380
--advertise-client-urls http://$${MYSELF}:2379
--initial-advertise-peer-urls http://$${MYSELF}:2380
--initial-cluster $${CLUSTER}
--initial-cluster-token $${TOKEN}
--initial-cluster-state $${STATE}"
backendai-half-etcd-node03:
image: quay.io/coreos/etcd:v3.5.4
volumes:
- "./tmp/backend.ai-halfstack-ha/etcd03-data:/etcd-data:rw"
networks:
- half
environment:
- MYSELF=backendai-half-etcd-node03
- CLUSTER=etcd-node01=http://backendai-half-etcd-node01:2380,etcd-node02=http://backendai-half-etcd-node02:2380,etcd-node03=http://backendai-half-etcd-node03:2380
- TOKEN=backendai-etcd-token
- STATE=new
command: >
sh -c
"/usr/local/bin/etcd
--name etcd-node03
--data-dir /etcd-data
--listen-client-urls http://0.0.0.0:2379
--listen-peer-urls http://0.0.0.0:2380
--advertise-client-urls http://$${MYSELF}:2379
--initial-advertise-peer-urls http://$${MYSELF}:2380
--initial-cluster $${CLUSTER}
--initial-cluster-token $${TOKEN}
--initial-cluster-state $${STATE}"
networks:
half: