<style>
/* Make the ... appear in front of the spec items in the right hand nav menu  */
.md-sidebar--secondary span.md-ellipsis {
	direction: rtl;
}
</style>

# Postgres reference

<!--
  This documentation was automatically generated by https://github.com/nais/pgrator/actions
  
  DO NOT MAKE MANUAL CHANGES TO THIS FILE, THEY WILL BE OVERWRITTEN!
-->

> **Preview**
> Postgres is in preview. Use it with care; the API and supported workflows may change.
> See the [Postgres overview](/persistence/postgres.md) for current availability.

This document describes the configuration values in the `Postgres` spec, commonly known as the `postgres.yaml` file. Each `Postgres` starts with a branch named `main`. `spec.activeBranch` selects the branch for workloads without an explicit `uses.postgres[].branch`; `status.activeBranch` reports the branch that is active now. Switching branches is not instant. See [Postgres branches](/persistence/postgres/explanations/branches.md) for the branch model.

## activeBranch

ActiveBranch selects the local branch name within this Postgres for normal workloads.
When omitted, pgrator retains the current active branch.

Type: `string`<br />
Required: `false`<br />

> **Example**
> ```yaml
> spec:
>   activeBranch: main
> ```

## extensions

Extensions to enable in the Postgres database.
See [available extensions](/persistence/postgres/reference/extensions.md) for names included in the PostgreSQL image.

Type: `array`<br />
Required: `false`<br />

> **Example**
> ```yaml
> spec:
>   extensions:
>     - name: vector
> ```

### extensions[].name

Name of the Postgres extension to enable.

Type: `string`<br />
Required: `true`<br />

> **Example**
> ```yaml
> spec:
>   extensions:
>     - name: vector
> ```

## highAvailability

HighAvailability adds a third instance and enables synchronous replication.

A cluster always runs a primary and a standby, so failover is available either
way. What this adds is the guarantee that an acknowledged commit survives
losing the primary, at the cost of write latency.

Type: `boolean`<br />
Required: `false`<br />

> **Example**
> ```yaml
> spec:
>   highAvailability: true
> ```

## majorVersion

MajorVersion of Postgres to use.
Only PostgreSQL 18 is available in preview. The schema also accepts 16 and 17,
but the platform image catalog does not provide those versions.

Type: `enum`<br />
Required: `true`<br />
Allowed values: `16`, `17`, `18`<br />

> **Example**
> ```yaml
> spec:
>   majorVersion: "18"
> ```

## resources

Resources configures compute and disk for the Postgres cluster.

Type: `object`<br />
Required: `false`<br />

> **Example**
> ```yaml
> spec:
>   resources:
>     cpu: 100m
>     diskSize: 10Gi
>     memory: 512Mi
> ```

### resources.cpu

Cpu is the CPU resources for the Postgres cluster.
Use CPU cores or millicores: `1` is one core, `500m` is half a core,
and `100m` is one tenth of a core.

Type: `integer` or `string`<br />
Required: `false`<br />

> **Validation pattern**
> ```regex
> ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
> ```

> **Example**
> ```yaml
> spec:
>   resources:
>     cpu: 100m
> ```

### resources.diskSize

DiskSize is the disk size for the Postgres cluster.
Use a Kubernetes quantity, for example `10Gi` (10 gibibytes) or `100Gi`.
Disk size can only increase.

Type: `integer` or `string`<br />
Required: `false`<br />

> **Validation pattern**
> ```regex
> ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
> ```

> **Example**
> ```yaml
> spec:
>   resources:
>     diskSize: 10Gi
> ```

### resources.memory

Memory is the memory resources for the Postgres cluster.
Use a Kubernetes quantity, for example `512Mi` (512 mebibytes) or `1Gi`
(1 gibibyte).

Type: `integer` or `string`<br />
Required: `false`<br />

> **Validation pattern**
> ```regex
> ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
> ```

> **Example**
> ```yaml
> spec:
>   resources:
>     memory: 512Mi
> ```
