Group deployment files by deployment method

This commit is contained in:
2026-11-30 18:27:11 +08:00
parent 9869a9966c
commit 69513d9ffb
11 changed files with 15 additions and 114 deletions
+2 -2
View File
@@ -18,7 +18,7 @@ jobs:
with: with:
persist-credentials: false persist-credentials: false
- name: Build the Rust release - name: Build the Rust release
run: bash deploy/build-release.sh run: bash deploy/gitea/build-release.sh
- name: Publish and initialize Bedrock storage - name: Publish and initialize Bedrock storage
env: env:
BEDROCK_PG_HOST: ${{ vars.BEDROCK_PG_HOST }} BEDROCK_PG_HOST: ${{ vars.BEDROCK_PG_HOST }}
@@ -26,4 +26,4 @@ jobs:
BEDROCK_PG_DATABASE: ${{ vars.BEDROCK_PG_DATABASE }} BEDROCK_PG_DATABASE: ${{ vars.BEDROCK_PG_DATABASE }}
BEDROCK_PG_USER: ${{ vars.BEDROCK_PG_USER }} BEDROCK_PG_USER: ${{ vars.BEDROCK_PG_USER }}
BEDROCK_PG_PASSWORD: ${{ secrets.BEDROCK_PG_PASSWORD }} 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"
+1 -1
View File
@@ -10,7 +10,7 @@ Notion describes sharding online PostgreSQL block data by workspace and feeding
## Database configuration ## 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. `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.
+2 -2
View File
@@ -54,7 +54,7 @@ fn resolves_named_connections_and_round_trips_yaml() {
use clusters::ConfigFormat; use clusters::ConfigFormat;
let config = DeploymentConfig::parse( let config = DeploymentConfig::parse(
include_str!("../../../deploy/multi-storage.yaml"), include_str!("../../../deploy/kubernetes/multi-storage.yaml"),
ConfigFormat::Yaml, ConfigFormat::Yaml,
) )
.unwrap(); .unwrap();
@@ -116,7 +116,7 @@ fn imports_catalog_atomically_and_preserves_role_references() {
DeploymentConfig::parse("config_version = 'test'", ConfigFormat::Toml).unwrap(); DeploymentConfig::parse("config_version = 'test'", ConfigFormat::Toml).unwrap();
config config
.import_resources( .import_resources(
include_str!("../../../deploy/kubernetes-catalog.yaml"), include_str!("../../../deploy/kubernetes/kubernetes-catalog.yaml"),
ImportFormat::KubernetesConfigMap, ImportFormat::KubernetesConfigMap,
) )
.unwrap(); .unwrap();
+10 -4
View File
@@ -1,10 +1,16 @@
# Deployment configuration # 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. | Deployment method | Directory |
- **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. | 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`. - **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. 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.
-105
View File
@@ -1,105 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" width="1160" height="1000" viewBox="0 0 1160 1000" role="img" aria-labelledby="title description">
<title id="title">Bedrock 的部署与手动验证流程</title>
<desc id="description">main 提交触发 Gitea CD。release.sh 调用配置渲染器并启动临时容器。容器内 Rust Bedrock 初始化已有 PostgreSQL 数据库中的 Bedrock 表。另有独立手动检查路径。</desc>
<defs>
<marker id="arrow" viewBox="0 0 9 9" refX="8" refY="4.5" markerWidth="9" markerHeight="9" orient="auto" markerUnits="userSpaceOnUse"><path d="M0 0 9 4.5 0 9z" fill="#557866"/></marker>
<marker id="arrow-red" viewBox="0 0 9 9" refX="8" refY="4.5" markerWidth="9" markerHeight="9" orient="auto" markerUnits="userSpaceOnUse"><path d="M0 0 9 4.5 0 9z" fill="#976752"/></marker>
<pattern id="grid" width="16" height="16" patternUnits="userSpaceOnUse"><circle cx="2" cy="2" r=".7" fill="#a4b2a3" opacity=".28"/></pattern>
</defs>
<style>
text{font-family:-apple-system,BlinkMacSystemFont,"PingFang SC","Hiragino Sans GB","Microsoft YaHei",sans-serif;fill:#1e3328}
.title{font-size:37px;font-weight:720;letter-spacing:-.4px}
.kicker,.code{font-family:ui-monospace,"SF Mono",Consolas,monospace}
.kicker{font-size:13px;letter-spacing:2px;font-weight:650;fill:#426251}
.lane{font-size:23px;font-weight:700}
.headline,.code{font-size:17px;font-weight:700}
.detail{font-size:14px;fill:#475d50}
.badge{font-size:14px;font-weight:650;fill:#325541}
.result{font-size:15px;font-weight:700;fill:#38624b}
.failed{fill:#8b5642}
.flow{fill:none;stroke:#557866;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:round;marker-end:url(#arrow)}
.flow-fail{fill:none;stroke:#976752;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:round;marker-end:url(#arrow-red)}
.side{stroke-dasharray:4 4}
</style>
<rect width="1160" height="1000" rx="23" fill="#f8f8f1"/>
<rect x=".5" y=".5" width="1159" height="999" rx="22.5" fill="none" stroke="#d9dfd3"/>
<path d="M34 103H1126" stroke="#d9dfd3"/>
<rect x="34" y="123" width="738" height="842" rx="17" fill="#eef2e9" stroke="#d9e1d5"/>
<rect x="34" y="123" width="738" height="842" rx="17" fill="url(#grid)"/>
<rect x="792" y="123" width="334" height="842" rx="17" fill="#f1f1e9" stroke="#dfe1d6"/>
<text x="34" y="36" class="kicker">BEDROCK / DEPLOYMENT</text>
<text x="34" y="81" class="title">Bedrock 的部署与手动验证流程</text>
<text x="55" y="159" class="lane">CD · 原部署机</text>
<text x="813" y="159" class="lane">手动验证</text>
<path d="M310 215 V235" class="flow"/>
<path d="M310 298 V318" class="flow"/>
<path d="M310 381 V414" class="flow"/>
<path d="M310 477 V497" class="flow"/>
<path d="M310 560 V580" class="flow"/>
<path d="M310 643 V663" class="flow"/>
<path d="M310 740 V821" class="flow"/>
<path d="M564 447 H536" class="flow side"/>
<path d="M310 896 V906 H224 V919" class="flow"/>
<path d="M310 896 V906 H568 V919" class="flow-fail"/>
<path d="M959 215 V235" class="flow"/>
<path d="M959 298 V318" class="flow"/>
<path d="M959 396 V416" class="flow"/>
<path d="M959 494 V522" class="flow"/>
<rect x="84" y="171" width="452" height="44" rx="9" fill="#e0eee0" stroke="#8eaf98"/>
<path d="M93 183v20" stroke="#8bac94" stroke-width="2" stroke-linecap="round"/>
<text x="104" y="199.0" class="headline">main 收到提交</text>
<rect x="84" y="235" width="452" height="63" rx="9" fill="#fbfbf6" stroke="#bfcec0"/>
<text x="104" y="264" class="code">deploy.yml</text>
<text x="104" y="285" class="detail">Gitea 在 ces-control 上检出代码并编排部署。</text>
<rect x="84" y="318" width="452" height="63" rx="9" fill="#fbfbf6" stroke="#bfcec0"/>
<text x="104" y="347" class="code">build-release.sh</text>
<text x="104" y="368" class="detail">在 Rust 容器内编译 release,输出 Bedrock 二进制。</text>
<text x="327" y="402" class="detail">二进制路径与 Git SHA 交给发布脚本</text>
<rect x="84" y="414" width="452" height="63" rx="9" fill="#fbfbf6" stroke="#bfcec0"/>
<text x="104" y="443" class="code">release.sh</text>
<text x="104" y="464" class="detail">建立暂存目录,放入二进制。</text>
<rect x="564" y="412" width="185" height="70" rx="9" fill="#edf1e8" stroke="#c1ccbf"/>
<text x="584" y="441" class="headline">Gitea 部署配置</text>
<text x="584" y="462" class="detail">PostgreSQL Variables</text>
<text x="584" y="481" class="detail">和密码 Secret</text>
<rect x="84" y="497" width="452" height="63" rx="9" fill="#fbfbf6" stroke="#bfcec0"/>
<text x="104" y="526" class="code">render-postgres.py</text>
<text x="104" y="547" class="detail">由 release.sh 调用,生成权限为 0600 的 bedrock.yaml。</text>
<rect x="84" y="580" width="452" height="63" rx="9" fill="#fbfbf6" stroke="#bfcec0"/>
<text x="104" y="609" class="headline">release.sh 启动临时容器</text>
<text x="104" y="630" class="detail">挂载二进制和配置,运行 Rust bedrock。</text>
<rect x="84" y="663" width="452" height="77" rx="9" fill="#e0eee0" stroke="#8eaf98"/>
<path d="M93 675v53" stroke="#8bac94" stroke-width="2" stroke-linecap="round"/>
<text x="104" y="692" class="headline">Rust Bedrock 读取配置</text>
<text x="104" y="713" class="detail">通过 db::connect 选择 postgres。</text>
<text x="104" y="732" class="detail">配置由 BEDROCK_DB_CONFIG 指定。</text>
<rect x="84" y="821" width="452" height="75" rx="9" fill="#e0eee0" stroke="#8eaf98"/>
<text x="104" y="847" class="headline">在已有 PostgreSQL 数据库内初始化</text>
<text x="104" y="869" class="detail">postgres.rs 提供 SQL,common.rs 在事务里执行。</text>
<text x="104" y="887" class="detail">创建 Bedrock 表并登记 production 部署。</text>
<text x="328" y="787" class="detail">进入 Store::initialize()</text>
<text x="118" y="909" class="result">成功</text>
<text x="614" y="909" class="result failed">失败</text>
<rect x="84" y="919" width="280" height="32" rx="9" fill="#e0eee0" stroke="#8eaf98"/>
<path d="M93 931v8" stroke="#8bac94" stroke-width="2" stroke-linecap="round"/>
<text x="104" y="941.0" class="headline">保存版本并切换 current</text>
<rect x="401" y="919" width="348" height="32" rx="9" fill="#f7eee6" stroke="#d4b7a6"/>
<text x="421" y="941.0" class="headline">清理暂存目录,保留上一版 current</text>
<rect x="813" y="171" width="292" height="44" rx="9" fill="#fbfbf6" stroke="#bfcec0"/>
<text x="833" y="199.0" class="headline">手动运行</text>
<rect x="813" y="235" width="292" height="63" rx="9" fill="#fbfbf6" stroke="#bfcec0"/>
<text x="833" y="264" class="code">ci/check-sql.sh</text>
<text x="833" y="285" class="detail">脚本独立于部署工作流。</text>
<rect x="813" y="318" width="292" height="78" rx="9" fill="#fbfbf6" stroke="#bfcec0"/>
<text x="833" y="347" class="headline">准备隔离环境</text>
<text x="833" y="368" class="detail">启动临时 PostgreSQL 和 MySQL。</text>
<text x="833" y="387" class="detail">SQLite 使用临时本地文件。</text>
<rect x="813" y="416" width="292" height="78" rx="9" fill="#fbfbf6" stroke="#bfcec0"/>
<text x="833" y="445" class="headline">运行三库检查</text>
<text x="833" y="466" class="detail">执行格式检查、测试、构建,</text>
<text x="833" y="485" class="detail">验证 SQLite 默认启动。</text>
<rect x="813" y="522" width="292" height="63" rx="9" fill="#edf1e8" stroke="#c1ccbf"/>
<text x="833" y="551" class="headline">退出时清理</text>
<text x="833" y="572" class="detail">删除测试容器和临时网络。</text>
</svg>

Before

Width:  |  Height:  |  Size: 7.4 KiB