Skip to content

Commit

Permalink
feat: add compose configuration for deploying ydb cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
polRk committed Oct 17, 2024
1 parent 839e236 commit b4f75bf
Show file tree
Hide file tree
Showing 5 changed files with 466 additions and 140 deletions.
63 changes: 63 additions & 0 deletions docker/cfg/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
actor_system_config:
cpu_count: 1
node_type: STORAGE
use_auto_config: true
blob_storage_config:
service_set:
groups:
- erasure_species: none
rings:
- fail_domains:
- vdisk_locations:
- node_id: 1
path: SectorMap:1:64
pdisk_category: SSD
channel_profile_config:
profile:
- channel:
- erasure_species: none
pdisk_category: 0
storage_pool_kind: ssd
- erasure_species: none
pdisk_category: 0
storage_pool_kind: ssd
- erasure_species: none
pdisk_category: 0
storage_pool_kind: ssd
profile_id: 0
domains_config:
domain:
- name: Root
storage_pool_types:
- kind: ssd
pool_config:
box_id: 1
erasure_species: none
kind: ssd
pdisk_filter:
- property:
- type: SSD
vdisk_kind: Default
state_storage:
- ring:
node:
- 1
nto_select: 1
ssid: 1
grpc_config:
port: 2135
host_configs:
- drive:
- path: SectorMap:1:64
type: SSD
host_config_id: 1
hosts:
- host: localhost
host_config_id: 1
node_id: 1
port: 19001
walle_location:
body: 1
data_center: az-1
rack: "0"
static_erasure: none
191 changes: 191 additions & 0 deletions docker/compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
x-template: &ydb-common
image: cr.yandex/crptqonuodf51kdj7a7d/ydb:24.2.7
restart: always
hostname: localhost
platform: linux/amd64
privileged: true
volumes:
- ./cfg/config.yaml:/opt/ydb/cfg/config.yaml

name: ydb

services:

static-0:
<<: *ydb-common
container_name: static-0
command:
- /opt/ydb/bin/ydbd
- server
- --grpc-port
- "2135"
- --mon-port
- "8765"
- --ic-port
- "19001"
- --yaml-config
- /opt/ydb/cfg/config.yaml
- --node
- static
- --label
- deployment=docker
ports:
- 2135:2135
- 8765:8765
- 19001:19001
healthcheck:
test: bash -c "exec 6<> /dev/tcp/localhost/2135"
interval: 10s
timeout: 1s
retries: 3
start_period: 30s

static-init:
<<: *ydb-common
restart: on-failure
container_name: static-init
command:
- /opt/ydb/bin/ydbd
- -s
- grpc://localhost:2135
- admin
- blobstorage
- config
- init
- --yaml-file
- /opt/ydb/cfg/config.yaml
depends_on:
static-0:
condition: service_healthy

tenant-init:
<<: *ydb-common
restart: on-failure
container_name: tenant-init
command:
- /opt/ydb/bin/ydbd
- -s
- grpc://localhost:2135
- admin
- database
- /Root/slo
- create
- ssd:1
depends_on:
static-init:
condition: service_completed_successfully

dynamic-1:
<<: *ydb-common
container_name: dynamic-1
command:
- /opt/ydb/bin/ydbd
- server
- --grpc-port
- "2136"
- --mon-port
- "8766"
- --ic-port
- "19002"
- --yaml-config
- /opt/ydb/cfg/config.yaml
- --tenant
- /Root/slo
- --node-broker
- grpc://localhost:2135
- --label
- deployment=docker
ports:
- 2136:2136
- 8766:8766
- 19002:19002
healthcheck:
test: bash -c "exec 6<> /dev/tcp/localhost/2136"
interval: 10s
timeout: 1s
retries: 3
start_period: 30s
depends_on:
static-0:
condition: service_healthy
static-init:
condition: service_completed_successfully
tenant-init:
condition: service_completed_successfully

dynamic-2:
<<: *ydb-common
container_name: dynamic-2
command:
- /opt/ydb/bin/ydbd
- server
- --grpc-port
- "2137"
- --mon-port
- "8767"
- --ic-port
- "19003"
- --yaml-config
- /opt/ydb/cfg/config.yaml
- --tenant
- /Root/slo
- --node-broker
- grpc://localhost:2135
- --label
- deployment=docker
ports:
- 2137:2137
- 8767:8767
- 19003:19003
healthcheck:
test: bash -c "exec 6<> /dev/tcp/localhost/2137"
interval: 10s
timeout: 1s
retries: 3
start_period: 30s
depends_on:
static-0:
condition: service_healthy
static-init:
condition: service_completed_successfully
tenant-init:
condition: service_completed_successfully

dynamic-3:
<<: *ydb-common
container_name: dynamic-3
command:
- /opt/ydb/bin/ydbd
- server
- --grpc-port
- "2138"
- --mon-port
- "8768"
- --ic-port
- "19004"
- --yaml-config
- /opt/ydb/cfg/config.yaml
- --tenant
- /Root/slo
- --node-broker
- grpc://localhost:2135
- --label
- deployment=docker
ports:
- 2138:2138
- 8768:8768
- 19004:19004
healthcheck:
test: bash -c "exec 6<> /dev/tcp/localhost/2138"
interval: 10s
timeout: 1s
retries: 3
start_period: 30s
depends_on:
static-0:
condition: service_healthy
static-init:
condition: service_completed_successfully
tenant-init:
condition: service_completed_successfully

135 changes: 135 additions & 0 deletions docker/gen.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
// This scripts generate compose file

import fs from 'node:fs';

let tenant = "/Root/slo"

// YDB Ports
let YDB_GRPC_PORT = 2135
let YDB_MON_PORT = 8765
let YDB_IC_PORT = 19001

// Generate YDB Static Node
let generateStaticNode = () => /** YAML */`
static-0:
<<: *ydb-common
container_name: static-0
command:
- /opt/ydb/bin/ydbd
- server
- --grpc-port
- "${YDB_GRPC_PORT}"
- --mon-port
- "${YDB_MON_PORT}"
- --ic-port
- "${YDB_IC_PORT}"
- --yaml-config
- /opt/ydb/cfg/config.yaml
- --node
- static
- --label
- deployment=docker
ports:
- ${YDB_GRPC_PORT}:${YDB_GRPC_PORT}
- ${YDB_MON_PORT}:${YDB_MON_PORT}
- ${YDB_IC_PORT}:${YDB_IC_PORT}
healthcheck:
test: bash -c "exec 6<> /dev/tcp/localhost/${YDB_GRPC_PORT}"
interval: 10s
timeout: 1s
retries: 3
start_period: 30s
static-init:
<<: *ydb-common
restart: on-failure
container_name: static-init
command:
- /opt/ydb/bin/ydbd
- -s
- grpc://localhost:${YDB_GRPC_PORT}
- admin
- blobstorage
- config
- init
- --yaml-file
- /opt/ydb/cfg/config.yaml
depends_on:
static-0:
condition: service_healthy
tenant-init:
<<: *ydb-common
restart: on-failure
container_name: tenant-init
command:
- /opt/ydb/bin/ydbd
- -s
- grpc://localhost:${YDB_GRPC_PORT}
- admin
- database
- ${tenant}
- create
- ssd:1
depends_on:
static-init:
condition: service_completed_successfully
`

// Generate YDB Dynamic Node
let generateDynamicNode = (idx) => /** YAML */`
dynamic-${idx}:
<<: *ydb-common
container_name: dynamic-${idx}
command:
- /opt/ydb/bin/ydbd
- server
- --grpc-port
- "${YDB_GRPC_PORT+idx}"
- --mon-port
- "${YDB_MON_PORT+idx}"
- --ic-port
- "${YDB_IC_PORT+idx}"
- --yaml-config
- /opt/ydb/cfg/config.yaml
- --tenant
- ${tenant}
- --node-broker
- grpc://localhost:${YDB_GRPC_PORT}
- --label
- deployment=docker
ports:
- ${YDB_GRPC_PORT+idx}:${YDB_GRPC_PORT+idx}
- ${YDB_MON_PORT+idx}:${YDB_MON_PORT+idx}
- ${YDB_IC_PORT+idx}:${YDB_IC_PORT+idx}
healthcheck:
test: bash -c "exec 6<> /dev/tcp/localhost/${YDB_GRPC_PORT+idx}"
interval: 10s
timeout: 1s
retries: 3
start_period: 30s
depends_on:
static-0:
condition: service_healthy
static-init:
condition: service_completed_successfully
tenant-init:
condition: service_completed_successfully
`

let composeFile = `x-template: &ydb-common
image: cr.yandex/crptqonuodf51kdj7a7d/ydb:24.2.7
restart: always
hostname: localhost
platform: linux/amd64
privileged: true
volumes:
- ./cfg/config.yaml:/opt/ydb/cfg/config.yaml
name: ydb
services:
${generateStaticNode()}${generateDynamicNode(1)}${generateDynamicNode(2)}${generateDynamicNode(3)}
`;

fs.writeFileSync('compose.yaml', composeFile);
Loading

0 comments on commit b4f75bf

Please sign in to comment.