PostgreSQL Setup
PostgreSQL 14 or above.Database
Create a database namedbytebase
with UTF-8 encoding. UTF-8 encoding is required for proper system operation.
User
Create a userbytebase
with one of the following privilege levels:
Option 1: Superuser
This option is not available on managed database services like AWS RDS or Google Cloud SQL.
Option 2: Database Owner
Make the user own the database:Option 3: Schema Create Privilege
Grant CREATE privilege on the public schema:Option 4: Database Owner Role
Grant the db_owner role to the user:PG_URL Environment Variable
ThePG_URL
environment variable configures the PostgreSQL connection for Bytebase. You can set it in two ways:
Direct Connection String
SetPG_URL
directly to a PostgreSQL connection URI:
File Path (Kubernetes & Secret Management)
For Kubernetes deployments and secret manager integration, setPG_URL
to a file path containing the connection string. Bytebase automatically picks up the updated connection string when the file content changes, enabling seamless secret rotation.
Running with Docker
This bash script demonstrates how to add an external PostgreSQL database as the metadata store when running the bytebase container.When connecting to a PostgreSQL instance running on the same host machine, use host.docker.internal as the hostname.
Running with Kubernetes
Direct Configuration
Configure the PostgreSQL connection directly in your deployment manifest:Secret-Based Configuration
For enhanced security, store your PostgreSQL connection string in a Kubernetes Secret:Using Secret as Environment Variable
Add the following environment variable configuration to your deployment’sspec.templates.spec.containers.env
section:
Using Secret as File Mount
Mount the secret as a file and pointPG_URL
to the file path. This approach supports automatic secret rotation - when the Kubernetes Secret is updated, the mounted file content is automatically refreshed, and Bytebase will pick up the new connection string without requiring a restart:
When using file-based secrets, Kubernetes automatically updates the mounted file content when the Secret is updated (typically within a minute). Bytebase monitors the file for changes and automatically reloads the connection string, enabling seamless secret rotation without downtime.