Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions api/v4/postgrescluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ type ManagedRole struct {
// Validation rules ensure immutability of Class, and that Storage and PostgresVersion can only be set once and cannot be removed or downgraded.
// +kubebuilder:validation:XValidation:rule="!has(oldSelf.postgresVersion) || (has(self.postgresVersion) && int(self.postgresVersion.split('.')[0]) >= int(oldSelf.postgresVersion.split('.')[0]))",messageExpression="!has(self.postgresVersion) ? 'postgresVersion cannot be removed once set (was: ' + oldSelf.postgresVersion + ')' : 'postgresVersion major version cannot be downgraded (from: ' + oldSelf.postgresVersion + ', to: ' + self.postgresVersion + ')'"
// +kubebuilder:validation:XValidation:rule="!has(oldSelf.storage) || (has(self.storage) && quantity(self.storage).compareTo(quantity(oldSelf.storage)) >= 0)",messageExpression="!has(self.storage) ? 'storage cannot be removed once set (was: ' + string(oldSelf.storage) + ')' : 'storage size cannot be decreased (from: ' + string(oldSelf.storage) + ', to: ' + string(self.storage) + ')'"
// +kubebuilder:validation:XValidation:rule="!self.connectionPoolerEnabled || self.connectionPoolerConfig != null || (self.cnpg != null && self.cnpg.connectionPooler != null)",message="connectionPoolerConfig must be set in cluster spec or class when connectionPoolerEnabled is true"
type PostgresClusterSpec struct {
// This field is IMMUTABLE after creation.
// +kubebuilder:validation:Required
Expand Down Expand Up @@ -96,6 +97,11 @@ type PostgresClusterSpec struct {
// +optional
ConnectionPoolerEnabled *bool `json:"connectionPoolerEnabled,omitempty"`

// ConnectionPoolerConfig overrides the connection pooler configuration from the class.
// Only takes effect when connection pooling is enabled.
// +optional
ConnectionPoolerConfig *ConnectionPoolerConfig `json:"connectionPoolerConfig,omitempty"`

// ManagedRoles contains PostgreSQL roles that should be created in the cluster.
// This field supports Server-Side Apply with per-role granularity, allowing
// multiple PostgresDatabase controllers to manage different roles independently.
Expand Down
1 change: 1 addition & 0 deletions api/v4/postgresclusterclass_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ const (

// ConnectionPoolerConfig defines PgBouncer connection pooler configuration.
// When enabled, creates RW and RO pooler deployments for clusters using this class.
// +kubebuilder:validation:XValidation:rule="!self.connectionPoolerEnabled || self.connectionPoolerConfig != null || (self.cnpg != null && self.cnpg.connectionPooler != null)",message="connectionPoolerConfig must be set in cluster spec or class when connectionPoolerEnabled is true"
type ConnectionPoolerConfig struct {
// Instances is the number of PgBouncer pod replicas.
// Higher values provide better availability and load distribution.
Expand Down
7 changes: 7 additions & 0 deletions config/samples/enterprise_v4_postgresclusterclass_dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,14 @@ spec:
limits:
cpu: "1"
memory: "2Gi"
connectionPoolerEnabled: true

cnpg:
# Restart method - tolerate downtime in dev
primaryUpdateMethod: restart
connectionPooler:
instances: 2
mode: transaction
config:
max_client_conn: "100"

Loading
Loading