Managed PostgreSQL¶
A PostgreSQL cluster managed by the CloudNativePG operator: one primary and optional streaming replicas with automatic failover.
Create¶
PostgreSQL → Create: name, number of instances, storage size, CPU and memory, optional backup configuration (object storage and retention) and PostgreSQL parameters.
- Instances: 1 is a single primary; 2 or more adds replicas and failover.
- Storage can be increased later, never decreased.
- Databases: create additional databases and owners on a cluster from its detail page.
Connect¶
From workloads in your tenant (apps, instances on the tenant network through the cluster), use the read-write service:
<cluster-name>-rw.<tenant-id>.svc.cluster.local:5432
Credentials are in the secret <cluster-name>-app in your tenant.
Not available yet: reaching a cluster from the internet or from outside your tenant.
Backups and restore¶
The Backups tab of a cluster manages continuous backups to object storage.
| Action | Notes |
|---|---|
| Switch backups on | For a cluster that has none; sets how long backups are kept (for example 14d). Does not restart the database. |
| Back up now | Takes a backup immediately. |
| Schedule | A five-field cron expression in UTC, at most once an hour, and the retention. |
| Restore | Creates a new cluster from another cluster's backups, at a point in time or at a named backup. The original is left as it is. |
Deleting a cluster asks whether to keep its backups.
Metering¶
vCPU-hours, memory GB-hours and storage GB-hours for every instance of the cluster.
Terraform¶
# A managed PostgreSQL cluster with one primary and one replica.
resource "rso_postgres_cluster" "db" {
name = "tf-example-db"
instances = 2
storage_size = "5Gi"
cpu_request = "100m"
memory_request = "256Mi"
cpu_limit = "500m"
memory_limit = "512Mi"
}
output "postgres_host" {
value = rso_postgres_cluster.db.host
}
More databases¶
Every cluster comes with a database app. Add more with rso_postgres_database:
# A second database in a managed PostgreSQL cluster, next to the default `app`.
resource "rso_postgres_cluster" "db" {
name = "tf-example-dbs"
storage_size = "5Gi"
}
resource "rso_postgres_database" "reports" {
cluster = rso_postgres_cluster.db.name
name = "tf-example-reports"
owner = "app"
}
output "database" {
value = rso_postgres_database.reports.name
}
In the console and the API, the owner role and the reclaim policy can be changed in place. Deleting a database removes it from
the platform's management; PostgreSQL drops it and its data only when reclaim_policy is delete.
With retain (the default) the data stays in the cluster. The app database a cluster comes with
is removed only with the cluster. What the Terraform resource supports is in its
reference.