Skip to content
Install

Create and manage a database

Orchard runs managed Postgres databases in your cluster, next to the apps that use them. Each database belongs to a project and runs as a CloudNativePG cluster. CloudNativePG is the Kubernetes operator that handles failover, storage, and backups, so you do not run Postgres by hand.

  1. Open a project.
  2. Select New app.
  3. In Start from scratch, select Postgres.
  4. In Start from, keep Empty. You can also select Import from URL or Copy of a database.
  5. In Database name, enter a name.
  6. In Postgres version, select a version.
  7. In Storage size, set the volume size. The default is 1 GiB.
  8. In Resources, set the CPU, memory, and Instances.
  9. Select Create database.

To connect an app in the same project, use a reference. A reference follows the database through a password rotation or a restore.

  1. Open the app.
  2. Go to Variables.
  3. Add a variable named DATABASE_URL.
  4. In the value field, select Use a resource.
  5. Select the database.
  6. Select Save.
  1. Open the database.
  2. Select Connect.
  3. Select Private to connect from apps in this project, or Public to connect from anywhere.
  4. Select a format: URI, psql, .env, or JDBC.
  5. For a private connection, select the instances: Primary, Standbys, or Any.

The private host is a cluster-internal address, such as pg-<name>-rw.<namespace>.svc.cluster.local. Traffic to it stays inside the cluster. Apps in the same project use this address.

To print the connection details from the CLI, run orchard db connection <id>. To open a psql session, run orchard db psql <id>, or use the console on the database page. The session runs in a sandboxed client pod in your namespace as the app role, and ends when you quit psql.

Set CPU and memory under Settings > Resources, or with orchard db resources set <id>. Changing them restarts the database.

Orchard sizes shared_buffers and backup compression from the memory limit, and recalculates them when the memory changes. To set shared_buffers yourself, refer to Change Postgres parameters.

TaskLocationRefer to
Read logs and open a shellOverviewLogs and shell
Take and restore backupsBackupsBack up and restore a database
Read metrics and query performanceObserveMonitor a database
Rename, stop, or delete the databaseSettings > General and Danger zoneDelete a database
Grow storageSettings > ResourcesGrow database storage
Change protection settingsSettings > ProtectionProtect a database
Upgrade PostgresSecurityUpgrade Postgres
Add standbysSettings > High availabilityConfigure high availability
Turn on the poolerSettings > Connection poolerUse a connection pooler
Add usersSettings > UsersAdd database users
Change parametersSettings > ParametersChange Postgres parameters
Install extensionsSettings > ExtensionsInstall Postgres extensions

By default, only apps in the project can connect. Public access assigns a port on the organization’s public IP address, so you can connect from your computer or a business intelligence tool.

  • A layer 4 (L4) load balancer in the cluster.
  • A public IP address. To set one for your organization, go to Organization settings > Database defaults > Public database IP. Otherwise, the organization inherits the instance default.

Public access is not available in Cloudflare Tunnel mode, because tunnels carry HTTP only.

  1. Open the database.
  2. Go to Settings > Public access.
  3. Turn on Reachable from the internet.

The connection string appears when the load balancer assigns the address. If the section shows an error, refer to Troubleshoot a public address.

Deleting a database moves it to Recently deleted on the project for 30 days. You can bring it back only if it had at least one completed backup. For the steps, refer to Recover a deleted database.

  1. Open the database.
  2. Go to Settings > Danger zone.
  3. Select Delete database.
  4. Confirm the deletion.