From 69513d9ffb333de753f80f59cbdb8497e3e302d5 Mon Sep 17 00:00:00 2001 From: Codex Bot Date: Mon, 30 Nov 2026 18:27:11 +0800 Subject: [PATCH] Group deployment files by deployment method --- .gitea/workflows/deploy.yml | 4 +- README.md | 2 +- crates/clusters/tests/deployment_config.rs | 4 +- deploy/README.md | 14 ++- deploy/bedrock-deployment.svg | 105 ------------------ deploy/{ => gitea}/build-release.sh | 0 deploy/{ => gitea}/release.sh | 0 deploy/{ => gitea}/render-postgres.py | 0 .../{ => kubernetes}/kubernetes-catalog.yaml | 0 deploy/{ => kubernetes}/multi-storage.yaml | 0 deploy/{ => local}/sqlite.yaml | 0 11 files changed, 15 insertions(+), 114 deletions(-) delete mode 100644 deploy/bedrock-deployment.svg rename deploy/{ => gitea}/build-release.sh (100%) rename deploy/{ => gitea}/release.sh (100%) rename deploy/{ => gitea}/render-postgres.py (100%) rename deploy/{ => kubernetes}/kubernetes-catalog.yaml (100%) rename deploy/{ => kubernetes}/multi-storage.yaml (100%) rename deploy/{ => local}/sqlite.yaml (100%) diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 516ff90..7beb37a 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -18,7 +18,7 @@ jobs: with: persist-credentials: false - name: Build the Rust release - run: bash deploy/build-release.sh + run: bash deploy/gitea/build-release.sh - name: Publish and initialize Bedrock storage env: BEDROCK_PG_HOST: ${{ vars.BEDROCK_PG_HOST }} @@ -26,4 +26,4 @@ jobs: BEDROCK_PG_DATABASE: ${{ vars.BEDROCK_PG_DATABASE }} BEDROCK_PG_USER: ${{ vars.BEDROCK_PG_USER }} BEDROCK_PG_PASSWORD: ${{ secrets.BEDROCK_PG_PASSWORD }} - run: bash deploy/release.sh target/bedrock-release/bedrock "$GITHUB_SHA" + run: bash deploy/gitea/release.sh target/bedrock-release/bedrock "$GITHUB_SHA" diff --git a/README.md b/README.md index 05d2767..16c16bf 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Notion describes sharding online PostgreSQL block data by workspace and feeding ## Database configuration -Set `BEDROCK_DB_CONFIG` to a private YAML deployment configuration. See the [multi-storage example](deploy/multi-storage.yaml). TOML and existing JSON files also load through the same configuration model. +Set `BEDROCK_DB_CONFIG` to a private YAML deployment configuration. See the [multi-storage example](deploy/kubernetes/multi-storage.yaml). TOML and existing JSON files also load through the same configuration model. `resources` lists named backends, each with a `kind` and its own settings. `bindings` maps roles such as `documents` or `attachments` to those resources. The executable logs the configuration version and initializes bound SQL resources at startup. Existing `cluster`, `clusters`, `sql`, `object_storage`, and `sqlite_path` inputs are migrated to this shape when loaded. diff --git a/crates/clusters/tests/deployment_config.rs b/crates/clusters/tests/deployment_config.rs index 9dc2783..c05b9d3 100644 --- a/crates/clusters/tests/deployment_config.rs +++ b/crates/clusters/tests/deployment_config.rs @@ -54,7 +54,7 @@ fn resolves_named_connections_and_round_trips_yaml() { use clusters::ConfigFormat; let config = DeploymentConfig::parse( - include_str!("../../../deploy/multi-storage.yaml"), + include_str!("../../../deploy/kubernetes/multi-storage.yaml"), ConfigFormat::Yaml, ) .unwrap(); @@ -116,7 +116,7 @@ fn imports_catalog_atomically_and_preserves_role_references() { DeploymentConfig::parse("config_version = 'test'", ConfigFormat::Toml).unwrap(); config .import_resources( - include_str!("../../../deploy/kubernetes-catalog.yaml"), + include_str!("../../../deploy/kubernetes/kubernetes-catalog.yaml"), ImportFormat::KubernetesConfigMap, ) .unwrap(); diff --git a/deploy/README.md b/deploy/README.md index e8f110d..ebb5442 100644 --- a/deploy/README.md +++ b/deploy/README.md @@ -1,10 +1,16 @@ # Deployment configuration -Bedrock reads a YAML deployment file from `BEDROCK_DB_CONFIG`. See [local SQLite](sqlite.yaml) and [multiple SQL roles with S3 settings](multi-storage.yaml). The loader also accepts TOML and existing JSON files. +Bedrock reads a YAML deployment file from `BEDROCK_DB_CONFIG`. The loader also accepts TOML and existing JSON files. -- **SQLite** uses a persistent, writable path in the SQL resource's `primary` field. -- **PostgreSQL on the existing host** uses Gitea Actions variables `BEDROCK_PG_HOST`, `BEDROCK_PG_PORT`, `BEDROCK_PG_DATABASE`, `BEDROCK_PG_USER` and secret `BEDROCK_PG_PASSWORD`. The release invokes `python3 deploy/render-postgres.py /path/to/private/bedrock.yaml --deployment production --config-version RELEASE_ID`. The renderer writes a private file. The database must already exist and present a trusted certificate for the selected endpoint. -- **Kubernetes** deploys each database and its Service separately. An in-cluster address can use the Service DNS name, such as `pg-main:5432` in the same namespace. Render the final YAML with deployment credentials, store it in a Secret, mount it into the Bedrock workload and set `BEDROCK_DB_CONFIG` to the mounted file. The [catalog ConfigMap example](kubernetes-catalog.yaml) shows how to package a catalog for the library import API without credentials. Declare the resource kind and driver in the catalog and bind its role in the deployment file. A Service name, port, or Kubernetes object kind alone does not describe the backend or its purpose. +| Deployment method | Directory | +|---|---| +| Local SQLite | [local/](local/) | +| Gitea release to the existing host | [gitea/](gitea/) | +| Kubernetes | [kubernetes/](kubernetes/) | + +- **Local SQLite** uses the [SQLite configuration](local/sqlite.yaml). Set a persistent, writable path in the SQL resource's `primary` field. +- **PostgreSQL on the existing host** uses Gitea Actions variables `BEDROCK_PG_HOST`, `BEDROCK_PG_PORT`, `BEDROCK_PG_DATABASE`, `BEDROCK_PG_USER` and secret `BEDROCK_PG_PASSWORD`. The release invokes `python3 deploy/gitea/render-postgres.py /path/to/private/bedrock.yaml --deployment production --config-version RELEASE_ID`. The renderer writes a private file. The database must already exist and present a trusted certificate for the selected endpoint. +- **Kubernetes** deploys each database and its Service separately. An in-cluster address can use the Service DNS name, such as `pg-main:5432` in the same namespace. The [multi-storage example](kubernetes/multi-storage.yaml) shows such addresses in the Bedrock configuration. Render the final YAML with deployment credentials, store it in a Secret, mount it into the Bedrock workload and set `BEDROCK_DB_CONFIG` to the mounted file. The [catalog ConfigMap example](kubernetes/kubernetes-catalog.yaml) shows how to package a catalog for the library import API without credentials. Declare the resource kind and driver in the catalog and bind its role in the deployment file. A Service name, port, or Kubernetes object kind alone does not describe the backend or its purpose. - **Terraform or cloud inventory** can export the chosen endpoints. Map those results into the Bedrock resource schema before importing. `ImportFormat::TerraformOutputs` reads a named `bedrock_resources` output from `terraform output -json`. Generic catalogs use names as keys and the same `kind` fields shown in the Kubernetes example. Role bindings are assigned in the deployment configuration under `bindings`. Publish the same versioned configuration to every instance in a deployment. Use a new configuration version and restart instances to apply changes. Rollouts can temporarily contain two versions. The catalog APIs edit an in-process draft. Publish the validated YAML through the deployment system to apply it across instances. diff --git a/deploy/bedrock-deployment.svg b/deploy/bedrock-deployment.svg deleted file mode 100644 index 67b1a6d..0000000 --- a/deploy/bedrock-deployment.svg +++ /dev/null @@ -1,105 +0,0 @@ - -Bedrock 的部署与手动验证流程 -main 提交触发 Gitea CD。release.sh 调用配置渲染器并启动临时容器。容器内 Rust Bedrock 初始化已有 PostgreSQL 数据库中的 Bedrock 表。另有独立手动检查路径。 - - - - - - - - - - - - - -BEDROCK / DEPLOYMENT -Bedrock 的部署与手动验证流程 -CD · 原部署机 -手动验证 - - - - - - - - - - - - - - - - -main 收到提交 - -deploy.yml -Gitea 在 ces-control 上检出代码并编排部署。 - -build-release.sh -在 Rust 容器内编译 release,输出 Bedrock 二进制。 -二进制路径与 Git SHA 交给发布脚本 - -release.sh -建立暂存目录,放入二进制。 - -Gitea 部署配置 -PostgreSQL Variables -和密码 Secret - -render-postgres.py -由 release.sh 调用,生成权限为 0600 的 bedrock.yaml。 - -release.sh 启动临时容器 -挂载二进制和配置,运行 Rust bedrock。 - - -Rust Bedrock 读取配置 -通过 db::connect 选择 postgres。 -配置由 BEDROCK_DB_CONFIG 指定。 - -在已有 PostgreSQL 数据库内初始化 -postgres.rs 提供 SQL,common.rs 在事务里执行。 -创建 Bedrock 表并登记 production 部署。 -进入 Store::initialize() -成功 -失败 - - -保存版本并切换 current - -清理暂存目录,保留上一版 current - -手动运行 - -ci/check-sql.sh -脚本独立于部署工作流。 - -准备隔离环境 -启动临时 PostgreSQL 和 MySQL。 -SQLite 使用临时本地文件。 - -运行三库检查 -执行格式检查、测试、构建, -验证 SQLite 默认启动。 - -退出时清理 -删除测试容器和临时网络。 - \ No newline at end of file diff --git a/deploy/build-release.sh b/deploy/gitea/build-release.sh similarity index 100% rename from deploy/build-release.sh rename to deploy/gitea/build-release.sh diff --git a/deploy/release.sh b/deploy/gitea/release.sh similarity index 100% rename from deploy/release.sh rename to deploy/gitea/release.sh diff --git a/deploy/render-postgres.py b/deploy/gitea/render-postgres.py similarity index 100% rename from deploy/render-postgres.py rename to deploy/gitea/render-postgres.py diff --git a/deploy/kubernetes-catalog.yaml b/deploy/kubernetes/kubernetes-catalog.yaml similarity index 100% rename from deploy/kubernetes-catalog.yaml rename to deploy/kubernetes/kubernetes-catalog.yaml diff --git a/deploy/multi-storage.yaml b/deploy/kubernetes/multi-storage.yaml similarity index 100% rename from deploy/multi-storage.yaml rename to deploy/kubernetes/multi-storage.yaml diff --git a/deploy/sqlite.yaml b/deploy/local/sqlite.yaml similarity index 100% rename from deploy/sqlite.yaml rename to deploy/local/sqlite.yaml