Unify backend resources and role bindings in clusters

This commit is contained in:
2026-11-30 18:24:24 +08:00
parent ac62c8a655
commit 9869a9966c
18 changed files with 469 additions and 227 deletions
+2 -2
View File
@@ -2,10 +2,10 @@
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.
- **SQLite** uses a persistent, writable path for `sqlite_path`.
- **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.
- **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.
- **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.
+9 -6
View File
@@ -1,18 +1,21 @@
# Illustrative service names. Inject deployment credentials before publishing.
deployment: production
config_version: example-1
clusters:
resources:
pg-main:
kind: sql
driver: postgres
primary: postgres://bedrock@pg-main:5432/bedrock
mysql-legacy:
kind: sql
driver: mysql
primary: mysql://bedrock@mysql-legacy:3306/legacy
sql:
documents: pg-main
legacy: mysql-legacy
object_storage:
attachments:
attachment-store:
kind: object_store
driver: s3
bucket: bedrock-attachments
region: us-east-1
bindings:
documents: pg-main
legacy: mysql-legacy
attachments: attachment-store
+3 -2
View File
@@ -55,10 +55,11 @@ def main():
config = (
f"deployment: {json.dumps(options.deployment)}\n"
f"config_version: {json.dumps(options.config_version)}\n"
"sql:\n"
"bindings:\n"
" documents: postgres\n"
"clusters:\n"
"resources:\n"
" postgres:\n"
" kind: sql\n"
" driver: postgres\n"
f" primary: {json.dumps(database_url())}\n"
)
+8 -1
View File
@@ -1,3 +1,10 @@
deployment: default
config_version: local
sqlite_path: bedrock.sqlite3
resources:
local:
kind: sql
driver: sqlite
primary: bedrock.sqlite3
max_connections: 1
bindings:
documents: local