-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompose.cluster.example.yaml
More file actions
129 lines (123 loc) · 4.55 KB
/
Copy pathcompose.cluster.example.yaml
File metadata and controls
129 lines (123 loc) · 4.55 KB
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
# Three-broker Fibril cluster in coordinated (Ganglion) mode, for trying out
# clustering with no clone and no build. The brokers form one coordination
# group and each broker's admin dashboard is exposed on the host.
#
# docker compose -f compose.cluster.example.yaml up
#
# Then open a dashboard and visit the topology page:
# http://127.0.0.1:8081/ http://127.0.0.1:8082/ http://127.0.0.1:8083/
#
# Clients can connect to any broker (9876, 9877, 9878) and are routed to the
# current owner of each partition. Stop and remove everything, including the
# persisted data volumes, with:
#
# docker compose -f compose.cluster.example.yaml down -v
#
# Clustering is experimental and not yet production-ready high availability.
x-broker: &broker
image: ghcr.io/axmouth/fibril-server:main
restart: unless-stopped
services:
broker-1:
<<: *broker
ports:
- "9876:9876" # broker (client connections)
- "8081:8081" # admin dashboard
environment:
FIBRIL_BROKER_BIND: 0.0.0.0:9876
FIBRIL_ADMIN_BIND: 0.0.0.0:8081
FIBRIL_COORDINATION_MODE: ganglion
# Demo-only shared secret. Real deployments generate their own with
# fibrilctl secret generate and never commit it.
FIBRIL_CLUSTER_SECRET: fibril-demo-cluster-secret
FIBRIL_COORDINATION_NODE_ID: broker-1
FIBRIL_COORDINATION_RAFT_ID: "1"
FIBRIL_COORDINATION_LISTEN: 0.0.0.0:7000
FIBRIL_COORDINATION_PEERS: 1=broker-1:7000,2=broker-2:7000,3=broker-3:7000
FIBRIL_COORDINATION_BOOTSTRAP: "true"
volumes:
- broker-1-data:/app/server_data
broker-2:
<<: *broker
ports:
- "9877:9876"
- "8082:8081"
environment:
FIBRIL_BROKER_BIND: 0.0.0.0:9876
FIBRIL_ADMIN_BIND: 0.0.0.0:8081
FIBRIL_COORDINATION_MODE: ganglion
# Demo-only shared secret. Real deployments generate their own with
# fibrilctl secret generate and never commit it.
FIBRIL_CLUSTER_SECRET: fibril-demo-cluster-secret
FIBRIL_COORDINATION_NODE_ID: broker-2
FIBRIL_COORDINATION_RAFT_ID: "2"
FIBRIL_COORDINATION_LISTEN: 0.0.0.0:7000
FIBRIL_COORDINATION_PEERS: 1=broker-1:7000,2=broker-2:7000,3=broker-3:7000
volumes:
- broker-2-data:/app/server_data
broker-3:
<<: *broker
ports:
- "9878:9876"
- "8083:8081"
environment:
FIBRIL_BROKER_BIND: 0.0.0.0:9876
FIBRIL_ADMIN_BIND: 0.0.0.0:8081
FIBRIL_COORDINATION_MODE: ganglion
# Demo-only shared secret. Real deployments generate their own with
# fibrilctl secret generate and never commit it.
FIBRIL_CLUSTER_SECRET: fibril-demo-cluster-secret
FIBRIL_COORDINATION_NODE_ID: broker-3
FIBRIL_COORDINATION_RAFT_ID: "3"
FIBRIL_COORDINATION_LISTEN: 0.0.0.0:7000
FIBRIL_COORDINATION_PEERS: 1=broker-1:7000,2=broker-2:7000,3=broker-3:7000
volumes:
- broker-3-data:/app/server_data
# One-shot seeder so the cluster comes up already alive: a couple of
# multi-partition queues (one grouped) and a Plexus stream, so the topology
# page shows ownership spread across the three brokers instead of an empty
# board. Runs once after the brokers are healthy, then exits.
seed:
<<: *broker
restart: "no"
depends_on:
broker-1:
condition: service_healthy
broker-2:
condition: service_healthy
broker-3:
condition: service_healthy
entrypoint:
- /bin/sh
- -c
- |
set -eu
broker=broker-1:9876
admin=http://broker-1:8081
echo "fibril seed: declaring demo queues and a stream..."
# A queue declare fails until the coordination group has elected a
# leader, so retry the first one until it lands.
n=0
until fibrilctl --broker "$$broker" queue declare orders --partitions 4; do
n=$$((n + 1))
if [ "$$n" -ge 60 ]; then
echo "fibril seed: gave up waiting for the cluster to be ready"
exit 1
fi
echo "fibril seed: cluster not ready yet, retrying..."
sleep 2
done
fibrilctl --broker "$$broker" queue declare payments --partitions 3
fibrilctl --broker "$$broker" queue declare emails --group marketing --partitions 2
if curl -fsS -X POST "$$admin/admin/api/streams" \
-H 'content-type: application/json' \
-d '{"tp":"events","partition_count":3,"durability":"speculative"}'; then
echo ""
else
echo "fibril seed: stream declare skipped"
fi
echo "fibril seed: done"
volumes:
broker-1-data:
broker-2-data:
broker-3-data: