Skip to content
Merged
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
18 changes: 18 additions & 0 deletions api/v4/postgrescluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,24 @@ type PostgresClusterSpec struct {
// +kubebuilder:default=Retain
// +optional
ClusterDeletionPolicy *string `json:"clusterDeletionPolicy,omitempty"`

// Monitoring contains configuration for metrics exposure features.
// +optional
Monitoring *PostgresClusterMonitoring `json:"monitoring,omitempty"`
}

// PostgresClusterMonitoring overrides monitoring configuration options for PostgresClusterClass.
// Set a field to false to disable a metric target that is enabled in the class.
type PostgresClusterMonitoring struct {
// PostgreSQLMetrics overrides whether PostgreSQL metrics scraping is enabled.
// When unset, the class-level setting applies.
// +optional
PostgreSQLMetrics *bool `json:"postgresqlMetrics,omitempty"`

// ConnectionPoolerMetrics overrides whether connection pooler metrics scraping is enabled.
// When unset, the class-level setting applies.
// +optional
ConnectionPoolerMetrics *bool `json:"connectionPoolerMetrics,omitempty"`
}

// PostgresClusterResources defines references to Kubernetes resources related to the PostgresCluster, such as ConfigMaps and Secrets.
Expand Down
22 changes: 22 additions & 0 deletions api/v4/postgresclusterclass_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ type PostgresClusterClassSpec struct {
CNPG *CNPGConfig `json:"cnpg,omitempty"`
}

// +kubebuilder:validation:XValidation:rule="!has(self.monitoring) || !has(self.monitoring.connectionPoolerMetrics) || !has(self.monitoring.connectionPoolerMetrics.enabled) || !self.monitoring.connectionPoolerMetrics.enabled || (has(self.connectionPoolerEnabled) && self.connectionPoolerEnabled)",message="connectionPoolerEnabled must be true when monitoring.connectionPoolerMetrics.enabled is true"
// PostgresClusterClassConfig contains provider-agnostic cluster configuration.
// These fields define PostgresCluster infrastructure and can be overridden in PostgresCluster CR.
type PostgresClusterClassConfig struct {
Expand Down Expand Up @@ -99,6 +100,13 @@ type PostgresClusterClassConfig struct {
// +kubebuilder:default=false
// +optional
ConnectionPoolerEnabled *bool `json:"connectionPoolerEnabled,omitempty"`

// Monitoring contains configuration for metrics exposure.
// When enabled, creates metrics resources for clusters using this class.
// Can be overridden in PostgresCluster CR.
// +kubebuilder:default={}
// +optional
Monitoring *PostgresMonitoringClassConfig `json:"monitoring,omitempty"`
}

// ConnectionPoolerMode defines the PgBouncer connection pooling strategy.
Expand Down Expand Up @@ -172,6 +180,20 @@ type PostgresClusterClassStatus struct {
Phase *string `json:"phase,omitempty"`
}

type PostgresMonitoringClassConfig struct {
// +optional
PostgreSQLMetrics *MetricsClassConfig `json:"postgresqlMetrics,omitempty"`
// +optional
ConnectionPoolerMetrics *MetricsClassConfig `json:"connectionPoolerMetrics,omitempty"`
}

type MetricsClassConfig struct {
// Enabled controls whether metrics resources should be created for this target.
// +kubebuilder:default=false
// +optional
Enabled *bool `json:"enabled,omitempty"`
}

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:resource:scope=Cluster
Expand Down
80 changes: 80 additions & 0 deletions api/v4/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions config/crd/bases/enterprise.splunk.com_postgresclusterclasses.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,30 @@ spec:
maximum: 10
minimum: 1
type: integer
monitoring:
default: {}
description: |-
Monitoring contains configuration for metrics exposure.
When enabled, creates metrics resources for clusters using this class.
Can be overridden in PostgresCluster CR.
properties:
connectionPoolerMetrics:
properties:
enabled:
default: false
description: Enabled controls whether metrics resources
should be created for this target.
type: boolean
type: object
postgresqlMetrics:
properties:
enabled:
default: false
description: Enabled controls whether metrics resources
should be created for this target.
type: boolean
type: object
type: object
pgHBA:
description: |-
PgHBA contains pg_hba.conf host-based authentication rules.
Expand Down Expand Up @@ -231,6 +255,12 @@ spec:
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
type: object
x-kubernetes-validations:
- message: connectionPoolerEnabled must be true when monitoring.connectionPoolerMetrics.enabled
is true
rule: '!has(self.monitoring) || !has(self.monitoring.connectionPoolerMetrics)
|| !has(self.monitoring.connectionPoolerMetrics.enabled) || !self.monitoring.connectionPoolerMetrics.enabled
|| (has(self.connectionPoolerEnabled) && self.connectionPoolerEnabled)'
provisioner:
description: |-
Provisioner identifies which database provisioner to use.
Expand Down
15 changes: 15 additions & 0 deletions config/crd/bases/enterprise.splunk.com_postgresclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,21 @@ spec:
x-kubernetes-list-map-keys:
- name
x-kubernetes-list-type: map
monitoring:
description: Monitoring contains configuration for metrics exposure
features.
properties:
connectionPoolerMetrics:
description: |-
ConnectionPoolerMetrics overrides whether connection pooler metrics scraping is enabled.
When unset, the class-level setting applies.
type: boolean
postgresqlMetrics:
description: |-
PostgreSQLMetrics overrides whether PostgreSQL metrics scraping is enabled.
When unset, the class-level setting applies.
type: boolean
type: object
pgHBA:
default: []
description: |-
Expand Down
6 changes: 5 additions & 1 deletion config/samples/enterprise_v4_postgresclusterclass_dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ spec:
cpu: "1"
memory: "2Gi"
connectionPoolerEnabled: true
monitoring:
postgresqlMetrics:
enabled: true
connectionPoolerMetrics:
enabled: true

cnpg:
# Restart method - tolerate downtime in dev
Expand All @@ -36,4 +41,3 @@ spec:
mode: transaction
config:
max_client_conn: "100"

Loading
Loading