Skip to main content
The PostgresCluster custom resource is the primary API for PGO. It defines a complete, production-grade PostgreSQL cluster including instance sets, backup repositories, connection pooling, monitoring, and high availability. PGO continuously reconciles the cluster to match the desired state you declare in this resource. API group: postgres-operator.crunchydata.com/v1beta1 Kind: PostgresCluster Scope: Namespaced

Example

The apiVersion must be postgres-operator.crunchydata.com/v1beta1. The example in the PGO source repository uses postgres-operator.crunchydata.com/v1 — always use v1beta1 for current deployments.

Spec fields

integer
required
The major version of PostgreSQL to run. Accepted values: 11 through 18.
[]InstanceSpec
required
One or more sets of PostgreSQL pods that replicate data for this cluster. At least one instance set must be defined. Each set is backed by a StatefulSet. Multiple instance sets allow you to place replicas on different node pools or availability zones.
Backups
PostgreSQL backup configuration. Contains the pgbackrest archive configuration and optional snapshots configuration.
PostgresProxySpec
Configuration for the connection pooler that sits in front of PostgreSQL. Currently supports pgBouncer.
See the connection pooling guide for practical pgBouncer configuration examples.
MonitoringSpec
Configuration for PostgreSQL monitoring tools.
DataSource
Bootstrap the cluster data directory from an existing backup or cluster. Only one data source can be specified at a time.
PostgresConfigSpec
General PostgreSQL server configuration.
PostgresAuthenticationSpec
PostgreSQL host-based authentication (pg_hba.conf) rules. Rules are evaluated in order; the first match determines the authentication method. Connections matching no rule are rejected.When omitted or empty, PostgreSQL accepts encrypted network connections from users with a password.
See the authentication guide for common HBA configurations.
SecretProjection
Secret projection supplying a custom server TLS certificate for PostgreSQL connections. The secret must contain tls.crt, tls.key, and ca.crt keys.When provided, customReplicationTLSSecret must also be provided, and both secrets must share the same CA certificate.
See the TLS guide for instructions on bringing your own certificates.
SecretProjection
Secret projection supplying the replication client TLS certificate. Required when customTLSSecret is set. Must contain tls.crt, tls.key, and ca.crt keys with the same CA as customTLSSecret.
DatabaseInitSQL
A ConfigMap containing SQL to run once after the cluster is initialized. The ConfigMap must be in the same namespace as the cluster.
[]PostgresUserSpec
Users to create inside PostgreSQL and the databases they should access. Maximum 64 users. The default creates one user matching the cluster name with access to a database of the same name. An empty list creates no users.
Removing a user from this list does not drop the user or revoke their access in PostgreSQL.
PatroniSpec
Patroni high-availability configuration. Changes to dynamicConfiguration are automatically reloaded; other changes cause PostgreSQL to restart.
PostgresStandbySpec
Run this cluster as a read-only hot standby that follows another PostgreSQL server or pgBackRest repository.
ServiceSpec
Specification of the Kubernetes Service that exposes the PostgreSQL primary instance.
ServiceSpec
Specification of the Kubernetes Service that exposes PostgreSQL replica instances.
UserInterfaceSpec
Configuration for a pgAdmin user interface deployed alongside this cluster. See also the standalone PGAdmin custom resource.
string
Container image for PostgreSQL. When omitted, the operator uses an environment variable named RELATED_IMAGE_POSTGRES_{postgresVersion} (e.g. RELATED_IMAGE_POSTGRES_16). For PostGIS images, the format is RELATED_IMAGE_POSTGRES_{version}_GIS_{postgisVersion}.
string
Image pull policy for all PostgreSQL containers. One of: Always, Never, IfNotPresent.
[]LocalObjectReference
Image pull secrets for pulling images from a private registry. Changing this value causes all running pods to restart.
string
PostGIS extension version installed in the PostgreSQL image. When image is not set, indicates that a PostGIS-enabled image should be used.
integer
Port on which PostgreSQL listens. Default: 5432. Minimum: 1024.
boolean
When true, disables the operator’s default pod scheduling constraints and uses only the custom constraints you provide. When false or unset, default constraints are applied in addition to any custom ones.
[]integer
Group IDs added to every container in the cluster. Useful when accessing shared file systems with restricted permissions. Values must be between 1 and 2147483647.
boolean
Whether the cluster is deployed in an OpenShift environment. When unset, the operator auto-detects the environment.
boolean
When true, suspends rollout and reconciliation of changes to the PostgresCluster spec. The cluster continues running but no spec changes are applied.
boolean
When true, scales all workloads to zero and suspends CronJobs. Services and Volumes remain in place. The cluster can be restarted by setting this to false.
InstrumentationSpec
Configuration for the OpenTelemetry collector container used to collect logs and metrics from all cluster pods.
Metadata
Labels and annotations to propagate to all resources created for this cluster.

Status fields

PGO populates the following fields in status to reflect the observed state of the cluster.