kupe_database
Manages a Kupe PostgreSQL database. Create and Update wait for the database to reach phase=Running with the change in effect on every instance. They fail at once if the database is being deleted (Terminating), and after 5 minutes if it stays Degraded once the platform has picked up the change. If the timeout fires first, the apply fails while the database is Degraded with the change picked up, or on Update while the platform is failing to apply the change; otherwise it ends with a warning and the platform carries on in the background. A change to deletion_protection alone takes effect at once and is not waited for. Delete waits until the database is gone. Set timeouts with the timeouts attribute, for example timeouts = { create = "45m" } (defaults: create/update 30m, delete 15m).
Applications reach the database through kupe_database_binding, which places a Service and a credentials Secret in each namespace it lists, in one cluster. Credentials are never returned by the API or stored in Terraform state.
Destroy semantics
Section titled “Destroy semantics”Deleting a database removes it immediately. Its storage is kept for 7 days for support-assisted recovery, then permanently deleted. There is no self-service restore in v1. deletion_protection (default true) makes the Kupe platform refuse the delete: set it to false and apply before destroying. Add lifecycle { prevent_destroy = true } to stop Terraform from planning the destroy at all.
Example Usage
Section titled “Example Usage”resource "kupe_database" "orders" { name = "orders-db" version = "18"
resources = { cpu = "500m" memory = "1Gi" storage = "10Gi" }
high_availability = true
}Protecting a database from destroy
Section titled “Protecting a database from destroy”deletion_protection makes the Kupe platform refuse the delete. prevent_destroy stops Terraform from planning it in the first place, so use both for databases you cannot lose.
resource "kupe_database" "example" { name = "example-db"
resources = { cpu = "1" memory = "2Gi" storage = "50Gi" }
lifecycle { prevent_destroy = true }}To delete a protected database, set deletion_protection = false (and remove prevent_destroy), run terraform apply, then destroy it.
Connecting applications
Section titled “Connecting applications”Grant access with kupe_database_binding. Each binding places a Service named after the database and a credentials Secret into each namespace it lists, in one cluster.
Schema
Section titled “Schema”Required
Section titled “Required”name(String) Database name (immutable after creation). A lowercase DNS label starting with a letter, without--, at most 44 characters. It is also the Service name applications connect to. The Kupe platform also limits it to 56 characters minus the length of the tenant name, so tenant names over 12 characters allow fewer than 44; the provider cannot check that at plan time, so the platform refuses a longer name when the database is created.resources(Attributes) Per-instance resources in Kubernetes quantity format. A high-availability database runs two instances of this size. All three are required, unlike the optional limits ofkupe_cluster. (see below for nested schema)
Optional
Section titled “Optional”deletion_protection(Boolean) Whiletrue, the Kupe platform refuses to delete the database. Set it tofalseand apply before destroying. Defaulttrue, also for an existing database: importing an unprotected database without this attribute in configuration plans turning protection on.engine(String) Database engine. Onlypostgresis supported, and it is the default. The engine of an existing database cannot change: a different value fails the plan instead of replacing the database.high_availability(Boolean) Run two instances with a synchronous standby. Can be turned on or off in place. When unset, a new database is created without it and an existing or imported database keeps its current setting, so removing the attribute from configuration does not turn HA off: set it tofalseto do that.timeouts(Attributes) (see below for nested schema)version(String) Engine major version, e.g.18. When unset, the platform default is used and recorded here. Major version upgrades are not available yet, so changing the version of an existing database fails the plan.
Read-Only
Section titled “Read-Only”created_at(String) Timestamp when the database was created.current_version(String) Full engine version running, e.g.18.0.etag(String) Resource version used for optimistic locking during updates.phase(String) Current phase: Pending, Provisioning, Running, Degraded or Terminating.
Nested Schema for resources
Section titled “Nested Schema for resources”Required:
cpu(String) CPU without a unit, e.g.500mor2.memory(String) Memory with a unit, e.g.1Gior512Mi.storage(String) Storage with a unit, e.g.10Gi. Storage can only grow: a smaller value fails the plan.
Nested Schema for timeouts
Section titled “Nested Schema for timeouts”Optional:
create(String) A string that can be parsed as a duration consisting of numbers and unit suffixes, such as “30s” or “2h45m”. Valid time units are “s” (seconds), “m” (minutes), “h” (hours).delete(String) A string that can be parsed as a duration consisting of numbers and unit suffixes, such as “30s” or “2h45m”. Valid time units are “s” (seconds), “m” (minutes), “h” (hours). Setting a timeout for a Delete operation is only applicable if changes are saved into state before the destroy operation occurs.update(String) A string that can be parsed as a duration consisting of numbers and unit suffixes, such as “30s” or “2h45m”. Valid time units are “s” (seconds), “m” (minutes), “h” (hours).
Import
Section titled “Import”Import is supported using the following syntax:
terraform import kupe_database.orders orders-db