-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdocker-compose.yml
88 lines (81 loc) · 2.13 KB
/
docker-compose.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
version: "3.8"
x-common-variables:
master-hostname: &master-hostname 'redis-node'
master-nodes: &master-nodes 3
redis-replicas: &redis-replicas 6
redis-port: &redis-port 6389
redis-mem: &redis-mem 2G
networks:
internal:
services:
arbiter:
image: redis:7-alpine3.20
hostname: redis-arbiter
restart: always
networks:
- internal
deploy:
resources:
limits:
cpus: '0.5'
memory: 100M
replicas: 1
restart_policy:
condition: any
nodes:
image: wsandwitch/redis-cluster:v1.3
build: .
hostname: redis-node{{.Task.Slot}} #must be the same as &master-hostname
restart: always
environment:
ARBITER_HOST: redis-arbiter
ARBITER_PORT: 6379
MASTER_HOST: *master-hostname
REDIS_PORT: *redis-port
REDIS_MAXMEM: *redis-mem
SLOT_NUM: '{{.Task.Slot}}'
SLOTS_TOTAL: *redis-replicas
MASTERS_TOTAL: *master-nodes
CHECK_PERIOD: 15
networks:
- internal
deploy:
resources:
limits:
cpus: '2'
memory: *redis-mem
replicas: *redis-replicas
placement:
constraints:
- "node.labels.LATENCY!=high"
- "node.labels.MEM!=low"
restart_policy:
condition: any
app:
image: jeko/redis-cluster-proxy:unstable
ports:
- 6379:6379
restart: always
environment:
MASTER_HOST: *master-hostname
MASTER_PORT: *redis-port
SLOTS_TOTAL: *redis-replicas
networks:
- internal
entrypoint: /bin/sh
command: -c "redis-cluster-proxy --port 6379 --connections-pool-size 60 --connections-pool-min-size 20 --enable-cross-slot $$(sh -c 'for i in $$(seq -s \" \" 1 3);do echo $$MASTER_HOST$$i:$$MASTER_PORT;done')"
healthcheck:
test: ["CMD-SHELL", "redis-cli --raw set a 1 | grep OK"]
deploy:
# resources:
# limits:
# cpus: '2'
# memory: '2G'
placement:
constraints:
- "node.labels.LATENCY!=high"
- "node.labels.MEM!=low"
max_replicas_per_node: 1
replicas: 2
restart_policy:
condition: any