Skip to main content

okustera_database_postgresql (Resource)

The okustera_database_postgresql resource allows you to declare, scale, and manage a production-grade PostgreSQL 16 cluster. Under the hood, Okustera orchestrates this via the CloudNativePG Operator, configuring automated leader election, continuous WAL archiving, point-in-time recovery (PITR), and credential escrow in OpenStack Barbican.

Example Usage​

High-Availability Production PostgreSQL Cluster​

resource "okustera_database_postgresql" "prod_db" {
name = "production-core-db"
namespace = "default"
instances = 3
storage_size = "100Gi"
storage_class = "ceph-rbd"
database_name = "app"
username = "app_user"
}

Schema​

Required​

  • name (String) Unique name of the PostgreSQL cluster.

Optional​

  • namespace (String) Kubernetes namespace for the database pods. Defaults to default.
  • instances (Number) Number of PostgreSQL replicas (e.g. 1 for development, 3 for production HA). Defaults to 1.
  • storage_size (String) Persistent volume size (e.g. "20Gi", "100Gi").
  • storage_class (String) Kubernetes StorageClass to provision volume claims against (defaults to ceph-rbd).
  • database_name (String) Name of the primary database to initialize (defaults to app).
  • username (String) Name of the database user (defaults to app).
  • password (String, Sensitive) Custom database user password (auto-generated if omitted).

Read-Only Attributes​

  • id (String) The internal cluster ID.
  • primary_endpoint (String) DNS endpoint routing traffic to the active write master (e.g. production-core-db-rw.default.svc:5432).
  • connection_uri (String, Sensitive) Full connection string with credentials.
  • status (String) Current operational status (Running, Creating, Failed).

Import​

Existing PostgreSQL clusters can be imported using their cluster name:

terraform import okustera_database_postgresql.prod_db production-core-db