<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>

# Nais 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!
-->

> **Experimental feature**
> This feature is an alpha feature, and is subject to API change, instability or removal.
> See the [main Postgres page](/persistence/postgresql.md) for more information.

This document describes all possible configuration values in the `Postgres` spec, commonly known as the `postgres.yaml` file. A `Postgres` is a logical database: pgrator creates its default `main` branch as a separate CNPG cluster. `spec.activeBranch` requests a local branch name; `status.activeBranch` is the observed selection. A requested branch must have an initialized, Ready, non-terminating CNPG cluster before pgrator updates observed status. This check is not an atomic cutover guarantee; verify workload connections when switching branches.

## 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.

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

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

### extensions[].name

Name of the Postgres extension to enable.

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

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

## 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.

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.

Type: `integer` or `string`<br />
Required: `false`<br />
Pattern: `^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$`<br />

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

### resources.diskSize

DiskSize is the disk size for the Postgres cluster.

Type: `integer` or `string`<br />
Required: `false`<br />
Pattern: `^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$`<br />

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

### resources.memory

Memory is the memory resources for the Postgres cluster.

Type: `integer` or `string`<br />
Required: `false`<br />
Pattern: `^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$`<br />

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