Skip to main content
The PostgresCluster custom resource is the single source of truth for every aspect of a PGO-managed database cluster. When you apply a manifest, the operator reconciles all Kubernetes objects — StatefulSets, Services, Secrets, CronJobs — needed to match the declared state. This page walks through each key section of the spec so you can confidently provision and tune a cluster.

Minimal cluster

The smallest valid cluster requires a postgresVersion, at least one instance set with a dataVolumeClaimSpec, and a backup repository.
Apply the manifest and watch the cluster come up:
Once the cluster is ready, retrieve the connection URI from the auto-generated user secret:

Key spec fields

postgresVersion

Specifies the PostgreSQL major version to install. Accepted values are 11 through 18.
To upgrade a running cluster to a new major version, use the PGUpgrade custom resource rather than editing postgresVersion in place. See the update Postgres guide.

instances

The instances list defines one or more instance sets. Each set maps to a Kubernetes StatefulSet. All instances share the same data through streaming replication orchestrated by Patroni.

backups.pgbackrest.repos

At least one repo is required. Repositories can be PVC-backed volumes or cloud object storage. Repo names must follow the pattern repo1 through repo4. See the backups guide for cloud storage options.

Setting resource requests and limits

Set CPU and memory constraints on instance pods through instances[*].resources. The operator passes this directly to the Postgres container spec.
Always set both requests and limits in production so the Kubernetes scheduler can place pods predictably and so Postgres is protected from noisy neighbors.

Custom Postgres configuration parameters

Use spec.config.parameters to set any tunable PostgreSQL parameter. Values are applied to postgresql.conf and reloaded when possible; some parameters require a server restart.
The operator rejects certain parameters that it manages directly, such as listen_addresses, port, ssl, archive_mode, hot_standby, and synchronous_standby_names. Attempting to set these results in a validation error.

Separate WAL volume

For workloads with heavy write throughput, placing the write-ahead log on its own PVC (and ideally a faster storage class) reduces I/O contention on the data volume.

Pulling from a private registry

Set spec.imagePullSecrets to a list of Kubernetes Secret names that hold Docker credentials. This applies to all containers in the cluster, including pgBackRest and pgBouncer.
Changing imagePullSecrets causes all running pods to restart so they can pick up the new pull credentials.

Defining users and databases

By default, PGO creates one user and one database that match the cluster name. Use spec.users to declare additional users and the databases they can access.
PGO creates a Secret for each user — <cluster>-pguser-<username> — containing the connection string, host, port, database, username, and password.

Running initialization SQL

spec.databaseInitSQL points to a ConfigMap whose data key contains SQL to run once after the cluster is first initialized. This is useful for creating schemas, extensions, or seed data.

Verifying the cluster

High availability

Configure multiple replicas and automatic failover with Patroni.

Backups

Set up scheduled backups to S3, GCS, Azure, or local volumes.

Connection pooling

Add pgBouncer to efficiently manage application connections.

Custom Resource Reference

Full field-by-field reference for the PostgresCluster CRD.