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 apostgresVersion, at least one instance set with a dataVolumeClaimSpec, and a backup repository.
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 throughinstances[*].resources. The operator passes this directly to the Postgres container spec.
Custom Postgres configuration parameters
Usespec.config.parameters to set any tunable PostgreSQL parameter. Values are applied to postgresql.conf and reloaded when possible; some parameters require a server restart.
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
Setspec.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. Usespec.users to declare additional users and the databases they can access.
<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.