-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
160 lines (155 loc) · 6.75 KB
/
Copy pathdocker-compose.yml
File metadata and controls
160 lines (155 loc) · 6.75 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
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
# KalamDB 3-Node Cluster Configuration
#
# This compose file runs a 3-node KalamDB cluster with Raft consensus.
# All nodes share the same network and can communicate via their container names.
#
# Usage:
# ./cluster.sh start # Build and start the cluster
# ./cluster.sh stop # Stop the cluster
# ./cluster.sh status # Check cluster status
# ./cluster.sh logs # View all logs
# ./cluster.sh clean # Stop and remove all data
#
# Port Mapping:
# Node 1: HTTP 8081, Raft 9091
# Node 2: HTTP 8082, Raft 9092
# Node 3: HTTP 8083, Raft 9093
services:
# ============================================================================
# Node 1 - Initial leader candidate
# ============================================================================
kalamdb-node1:
image: jamals86/kalamdb:latest
container_name: kalamdb-node1
hostname: kalamdb-node1
ports:
- "8081:2900" # HTTP API
- "9091:2910" # Raft gRPC
volumes:
- node1_data:/data
- shared_storage:/data/storage
# Optional: Override server.toml with your own configuration
# - ./server1.toml:/config/server.toml:ro
environment:
KALAMDB_SERVER_HOST: "0.0.0.0"
KALAMDB_CLUSTER_ID: "${KALAMDB_CLUSTER_ID:-docker-cluster}"
KALAMDB_NODE_ID: "${KALAMDB_NODE_ID_NODE1:-1}"
KALAMDB_CLUSTER_RPC_ADDR: "${KALAMDB_CLUSTER_RPC_ADDR_NODE1:-kalamdb-node1:2910}"
KALAMDB_CLUSTER_API_ADDR: "${KALAMDB_CLUSTER_API_ADDR_NODE1:-http://kalamdb-node1:2900}"
KALAMDB_CLUSTER_PEERS: "${KALAMDB_CLUSTER_PEERS_NODE1:-2@kalamdb-node2:2910@http://kalamdb-node2:2900;3@kalamdb-node3:2910@http://kalamdb-node3:2900}"
KALAMDB_ROOT_PASSWORD: "${KALAMDB_ROOT_PASSWORD:-kalamdb123}"
KALAMDB_JWT_SECRET: "${KALAMDB_JWT_SECRET:-kalamdb-docker-dev-secret-please-change-32chars}"
# TESTING ONLY: allow any browser origin so the sample Admin UI works out of the box.
# Replace "*" with exact UI origins before using this outside local/demo environments.
KALAMDB_SECURITY_CORS_ALLOWED_ORIGINS: "${KALAMDB_SECURITY_CORS_ALLOWED_ORIGINS:-*}"
networks:
- kalamdb-cluster
restart: unless-stopped
command: ["/usr/local/bin/kalamdb-server", "/config/server.toml"]
healthcheck:
test: ["CMD", "/bin/busybox", "wget", "--spider", "-q", "http://127.0.0.1:2900/v1/api/healthcheck"]
interval: 10s
timeout: 5s
start_period: 30s
retries: 3
# ============================================================================
# Node 2
# ============================================================================
kalamdb-node2:
image: jamals86/kalamdb:latest
container_name: kalamdb-node2
hostname: kalamdb-node2
ports:
- "8082:2900" # HTTP API
- "9092:2910" # Raft gRPC
volumes:
- node2_data:/data
- shared_storage:/data/storage
# Optional: Override server.toml with your own configuration
# - ./server2.toml:/config/server.toml:ro
environment:
KALAMDB_SERVER_HOST: "0.0.0.0"
KALAMDB_CLUSTER_ID: "${KALAMDB_CLUSTER_ID:-docker-cluster}"
KALAMDB_NODE_ID: "${KALAMDB_NODE_ID_NODE2:-2}"
KALAMDB_CLUSTER_RPC_ADDR: "${KALAMDB_CLUSTER_RPC_ADDR_NODE2:-kalamdb-node2:2910}"
KALAMDB_CLUSTER_API_ADDR: "${KALAMDB_CLUSTER_API_ADDR_NODE2:-http://kalamdb-node2:2900}"
KALAMDB_CLUSTER_PEERS: "${KALAMDB_CLUSTER_PEERS_NODE2:-1@kalamdb-node1:2910@http://kalamdb-node1:2900;3@kalamdb-node3:2910@http://kalamdb-node3:2900}"
KALAMDB_ROOT_PASSWORD: "${KALAMDB_ROOT_PASSWORD:-kalamdb123}"
KALAMDB_JWT_SECRET: "${KALAMDB_JWT_SECRET:-kalamdb-docker-dev-secret-please-change-32chars}"
# TESTING ONLY: allow any browser origin so the sample Admin UI works out of the box.
# Replace "*" with exact UI origins before using this outside local/demo environments.
KALAMDB_SECURITY_CORS_ALLOWED_ORIGINS: "${KALAMDB_SECURITY_CORS_ALLOWED_ORIGINS:-*}"
networks:
- kalamdb-cluster
depends_on:
kalamdb-node1:
condition: service_started
restart: unless-stopped
command: ["/usr/local/bin/kalamdb-server", "/config/server.toml"]
healthcheck:
test: ["CMD", "/bin/busybox", "wget", "--spider", "-q", "http://127.0.0.1:2900/v1/api/healthcheck"]
interval: 10s
timeout: 5s
start_period: 30s
retries: 3
# ============================================================================
# Node 3
# ============================================================================
kalamdb-node3:
image: jamals86/kalamdb:latest
container_name: kalamdb-node3
hostname: kalamdb-node3
ports:
- "8083:2900" # HTTP API
- "9093:2910" # Raft gRPC
volumes:
- node3_data:/data
- shared_storage:/data/storage
# Optional: Override server.toml with your own configuration
# - ./server3.toml:/config/server.toml:ro
environment:
KALAMDB_SERVER_HOST: "0.0.0.0"
KALAMDB_CLUSTER_ID: "${KALAMDB_CLUSTER_ID:-docker-cluster}"
KALAMDB_NODE_ID: "${KALAMDB_NODE_ID_NODE3:-3}"
KALAMDB_CLUSTER_RPC_ADDR: "${KALAMDB_CLUSTER_RPC_ADDR_NODE3:-kalamdb-node3:2910}"
KALAMDB_CLUSTER_API_ADDR: "${KALAMDB_CLUSTER_API_ADDR_NODE3:-http://kalamdb-node3:2900}"
KALAMDB_CLUSTER_PEERS: "${KALAMDB_CLUSTER_PEERS_NODE3:-1@kalamdb-node1:2910@http://kalamdb-node1:2900;2@kalamdb-node2:2910@http://kalamdb-node2:2900}"
KALAMDB_ROOT_PASSWORD: "${KALAMDB_ROOT_PASSWORD:-kalamdb123}"
KALAMDB_JWT_SECRET: "${KALAMDB_JWT_SECRET:-kalamdb-docker-dev-secret-please-change-32chars}"
# TESTING ONLY: allow any browser origin so the sample Admin UI works out of the box.
# Replace "*" with exact UI origins before using this outside local/demo environments.
KALAMDB_SECURITY_CORS_ALLOWED_ORIGINS: "${KALAMDB_SECURITY_CORS_ALLOWED_ORIGINS:-*}"
networks:
- kalamdb-cluster
depends_on:
kalamdb-node1:
condition: service_started
restart: unless-stopped
command: ["/usr/local/bin/kalamdb-server", "/config/server.toml"]
healthcheck:
test: ["CMD", "/bin/busybox", "wget", "--spider", "-q", "http://127.0.0.1:2900/v1/api/healthcheck"]
interval: 10s
timeout: 5s
start_period: 30s
retries: 3
# ============================================================================
# Cluster Network
# ============================================================================
networks:
kalamdb-cluster:
driver: bridge
ipam:
config:
- subnet: 172.28.0.0/16
# ============================================================================
# Persistent Volumes
# ============================================================================
volumes:
node1_data:
driver: local
node2_data:
driver: local
node3_data:
driver: local
shared_storage:
driver: local