fix: auto-enable cluster bootstrap, add init-db.sql to postgres volumes

- Auto-enable cluster seeding when BOOTSTRAP_CLUSTERS is set
  (no longer requires separate BOOTSTRAP_ENABLE_CLUSTERS=true)
- Add BOOTSTRAP_ENABLE_CLUSTERS to README .env template
- Mount init-db.sql in postgres service volumes
This commit is contained in:
Ivan087
2026-05-20 18:00:49 +08:00
parent 33ddaf97db
commit 0144e9cab7
3 changed files with 6 additions and 2 deletions

View File

@ -75,7 +75,8 @@ BOOTSTRAP_REGISTRY_USER=admin-or-user
BOOTSTRAP_REGISTRY_PASS=change-me BOOTSTRAP_REGISTRY_PASS=change-me
BOOTSTRAP_REGISTRY_INSECURE=false BOOTSTRAP_REGISTRY_INSECURE=false
# Kubernetes 集群 bootstrap名称列表用逗号分隔 # Kubernetes 集群 bootstrap需要显式启用并设置名称列表
BOOTSTRAP_ENABLE_CLUSTERS=true
BOOTSTRAP_CLUSTERS=cluster1,cluster2 BOOTSTRAP_CLUSTERS=cluster1,cluster2
BOOTSTRAP_CLUSTER_CLUSTER1_HOST=https://x.x.x.x:6443 BOOTSTRAP_CLUSTER_CLUSTER1_HOST=https://x.x.x.x:6443
BOOTSTRAP_CLUSTER_CLUSTER1_DESC=GPU Cluster 1 BOOTSTRAP_CLUSTER_CLUSTER1_DESC=GPU Cluster 1

View File

@ -138,7 +138,9 @@ func loadBootstrapConfigFromEnv() (*BootstrapConfig, bool) {
}) })
} }
if parseBoolEnv("BOOTSTRAP_ENABLE_CLUSTERS", false) { enableClusters := parseBoolEnv("BOOTSTRAP_ENABLE_CLUSTERS", false) ||
os.Getenv("BOOTSTRAP_CLUSTERS") != ""
if enableClusters {
for _, clusterName := range discoverBootstrapClusters() { for _, clusterName := range discoverBootstrapClusters() {
prefix := "BOOTSTRAP_CLUSTER_" + normalizeEnvName(clusterName) + "_" prefix := "BOOTSTRAP_CLUSTER_" + normalizeEnvName(clusterName) + "_"
host := os.Getenv(prefix + "HOST") host := os.Getenv(prefix + "HOST")

View File

@ -28,6 +28,7 @@ services:
- "${POSTGRES_PORT:-15432}:5432" - "${POSTGRES_PORT:-15432}:5432"
volumes: volumes:
- postgres_data:/var/lib/postgresql/data - postgres_data:/var/lib/postgresql/data
- ./backend/scripts/init-db.sql:/docker-entrypoint-initdb.d/01-init.sql:ro
healthcheck: healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-postgres} -d ${POSTGRES_DB:-ocdp}"] test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-postgres} -d ${POSTGRES_DB:-ocdp}"]
interval: 10s interval: 10s