forked from qdrant/qdrant
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add script to generate
docker-compose.yaml
for Qdrant cluster (qdra…
…nt#1489) * Add a simple script to generate `docker-compose.yaml` for a cluster of specified number of nodes * Improve service error from `RequestError` conversion * fixup! Improve service error from `RequestError` conversion [skip ci] * fixup! Add a simple script to generate `docker-compose.yaml` for a cluster of specified number of nodes [skip ci] * Add CPU limit to the `docker-compose-gen.sh` [skip ci] * fixup! Add CPU limit to the `docker-compose-gen.sh` [skip ci] * Move docker-compose generator script into tools directory, add docs * Apply suggestions from code review Co-authored-by: Roman Titov <ffuugoo@users.noreply.github.com> * Simplify error message constructing --------- Co-authored-by: timvisee <tim@visee.me> Co-authored-by: Tim Visée <tim+github@visee.me>
- Loading branch information
Showing
2 changed files
with
67 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Generate a docker-compose configuration for a cluster. | ||
# | ||
# Parameters: | ||
# - $1: number of nodes (default: 5) | ||
# - $2: base port (default: 6330) | ||
# | ||
# Example usage: | ||
# ./generate_docker_compose_cluster.sh 5 > docker-compose.yaml | ||
|
||
set -euo pipefail | ||
|
||
declare NODES="${1:-5}" | ||
declare BASE_PORT="${2:-6330}" | ||
|
||
cat <<-EOF | ||
version: "3.7" | ||
services: | ||
EOF | ||
|
||
for ((node=0; node<NODES; node++)) | ||
do | ||
declare SERVICE_NAME=qdrant_node_$node | ||
|
||
declare HTTP_PORT=$((BASE_PORT + node * 10 + 3)) | ||
declare GRPC_PORT=$((BASE_PORT + node * 10 + 4)) | ||
|
||
if ((node == 0)) | ||
then | ||
declare COMMAND="./qdrant --uri 'http://$SERVICE_NAME:6335'" | ||
else | ||
declare COMMAND="bash -c \"sleep $((10 + node / 10 + RANDOM % 10)) && ./qdrant --bootstrap 'http://qdrant_node_0:6335' --uri 'http://$SERVICE_NAME:6335'\"" | ||
fi | ||
|
||
cat <<-EOF | ||
$SERVICE_NAME: | ||
image: qdrant/qdrant:latest | ||
command: $COMMAND | ||
restart: always | ||
environment: | ||
- QDRANT__SERVICE__GRPC_PORT=6334 | ||
- QDRANT__CLUSTER__ENABLED=true | ||
- QDRANT__CLUSTER__P2P__PORT=6335 | ||
- QDRANT__CLUSTER__CONSENSUS__MAX_MESSAGE_QUEUE_SIZE=5000 | ||
- QDRANT__LOG_LEVEL=debug,raft=info | ||
ports: | ||
- "$HTTP_PORT:6333" | ||
- "$GRPC_PORT:6334" | ||
deploy: | ||
resources: | ||
limits: | ||
cpus: "0.3" | ||
EOF | ||
done |