Skip to content
Closed
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
58 changes: 32 additions & 26 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ jobs:
with:
k3s-channel: "${{ matrix.kubernetes }}"
prefetch-images: |
registry.developers.crunchydata.com/crunchydata/crunchy-pgbackrest:ubi9-2.56.0-2534
registry.developers.crunchydata.com/crunchydata/crunchy-pgbouncer:ubi9-1.24-2534
registry.developers.crunchydata.com/crunchydata/crunchy-postgres:ubi9-16.10-2534
registry.developers.crunchydata.com/crunchydata/crunchy-pgbackrest:ubi9-2.56.0-2542
registry.developers.crunchydata.com/crunchydata/crunchy-pgbouncer:ubi9-1.24-2542
registry.developers.crunchydata.com/crunchydata/crunchy-postgres:ubi9-16.10-2542

- run: make createnamespaces check-envtest-existing
env:
Expand Down Expand Up @@ -98,16 +98,19 @@ jobs:
with:
k3s-channel: "${{ matrix.kubernetes }}"
prefetch-images: |
registry.developers.crunchydata.com/crunchydata/crunchy-pgbackrest:ubi9-2.56.0-2534
registry.developers.crunchydata.com/crunchydata/crunchy-pgbouncer:ubi9-1.24-2534
registry.developers.crunchydata.com/crunchydata/crunchy-postgres-exporter:ubi9-0.17.1-2534
registry.developers.crunchydata.com/crunchydata/crunchy-postgres:ubi9-17.6-2534
registry.developers.crunchydata.com/crunchydata/crunchy-postgres:ubi9-16.10-2534
registry.developers.crunchydata.com/crunchydata/crunchy-postgres-gis:ubi9-16.10-3.3-2534
registry.developers.crunchydata.com/crunchydata/crunchy-postgres-gis:ubi9-16.10-3.4-2534
registry.developers.crunchydata.com/crunchydata/crunchy-upgrade:ubi9-17.6-2534
registry.developers.crunchydata.com/crunchydata/crunchy-postgres-gis:ubi9-17.6-3.4-2534
registry.developers.crunchydata.com/crunchydata/crunchy-postgres-gis:ubi9-17.6-3.5-2534
registry.developers.crunchydata.com/crunchydata/crunchy-pgbackrest:ubi9-2.56.0-2542
registry.developers.crunchydata.com/crunchydata/crunchy-pgbouncer:ubi9-1.24-2542
registry.developers.crunchydata.com/crunchydata/crunchy-postgres-exporter:ubi9-0.17.1-2542
registry.developers.crunchydata.com/crunchydata/crunchy-postgres:ubi9-17.6-2542
registry.developers.crunchydata.com/crunchydata/crunchy-postgres:ubi9-16.10-2542
registry.developers.crunchydata.com/crunchydata/crunchy-postgres-gis:ubi9-16.10-3.3-2542
registry.developers.crunchydata.com/crunchydata/crunchy-postgres-gis:ubi9-16.10-3.4-2542
registry.developers.crunchydata.com/crunchydata/crunchy-upgrade:ubi9-18.0-2542
registry.developers.crunchydata.com/crunchydata/crunchy-postgres-gis:ubi9-17.6-3.4-2542
registry.developers.crunchydata.com/crunchydata/crunchy-postgres-gis:ubi9-17.6-3.5-2542
registry.developers.crunchydata.com/crunchydata/crunchy-postgres-gis:ubi9-17.6-3.6-2542
registry.developers.crunchydata.com/crunchydata/crunchy-postgres:ubi9-18.0-2542
registry.developers.crunchydata.com/crunchydata/crunchy-postgres-gis:ubi9-18.0-3.6-2542

- name: Get pgMonitor files.
run: make get-pgmonitor
Expand All @@ -126,18 +129,21 @@ jobs:
--volume "$(pwd):/mnt" --workdir '/mnt' \
--env 'QUERIES_CONFIG_DIR=/mnt/hack/tools/queries' \
--env 'KUBECONFIG=hack/.kube/postgres-operator/pgo' \
--env 'RELATED_IMAGE_PGBACKREST=registry.developers.crunchydata.com/crunchydata/crunchy-pgbackrest:ubi9-2.56.0-2534' \
--env 'RELATED_IMAGE_PGBOUNCER=registry.developers.crunchydata.com/crunchydata/crunchy-pgbouncer:ubi9-1.24-2534' \
--env 'RELATED_IMAGE_PGEXPORTER=registry.developers.crunchydata.com/crunchydata/crunchy-postgres-exporter:ubi9-0.17.1-2534' \
--env 'RELATED_IMAGE_PGUPGRADE=registry.developers.crunchydata.com/crunchydata/crunchy-upgrade:ubi9-17.6-2534' \
--env 'RELATED_IMAGE_POSTGRES_16=registry.developers.crunchydata.com/crunchydata/crunchy-postgres:ubi9-16.10-2534' \
--env 'RELATED_IMAGE_POSTGRES_16_GIS_3.3=registry.developers.crunchydata.com/crunchydata/crunchy-postgres-gis:ubi9-16.10-3.3-2534' \
--env 'RELATED_IMAGE_POSTGRES_16_GIS_3.4=registry.developers.crunchydata.com/crunchydata/crunchy-postgres-gis:ubi9-16.10-3.4-2534' \
--env 'RELATED_IMAGE_POSTGRES_17=registry.developers.crunchydata.com/crunchydata/crunchy-postgres:ubi9-17.6-2534' \
--env 'RELATED_IMAGE_POSTGRES_17_GIS_3.4=registry.developers.crunchydata.com/crunchydata/crunchy-postgres-gis:ubi9-17.6-3.4-2534' \
--env 'RELATED_IMAGE_POSTGRES_17_GIS_3.5=registry.developers.crunchydata.com/crunchydata/crunchy-postgres-gis:ubi9-17.6-3.5-2534' \
--env 'RELATED_IMAGE_STANDALONE_PGADMIN=registry.developers.crunchydata.com/crunchydata/crunchy-pgadmin4:ubi9-9.2-2534' \
--env 'RELATED_IMAGE_COLLECTOR=registry.developers.crunchydata.com/crunchydata/postgres-operator:ubi9-5.8.3-0' \
--env 'RELATED_IMAGE_PGBACKREST=registry.developers.crunchydata.com/crunchydata/crunchy-pgbackrest:ubi9-2.56.0-2542' \
--env 'RELATED_IMAGE_PGBOUNCER=registry.developers.crunchydata.com/crunchydata/crunchy-pgbouncer:ubi9-1.24-2542' \
--env 'RELATED_IMAGE_PGEXPORTER=registry.developers.crunchydata.com/crunchydata/crunchy-postgres-exporter:ubi9-0.17.1-2542' \
--env 'RELATED_IMAGE_PGUPGRADE=registry.developers.crunchydata.com/crunchydata/crunchy-upgrade:ubi9-18.0-2542' \
--env 'RELATED_IMAGE_POSTGRES_16=registry.developers.crunchydata.com/crunchydata/crunchy-postgres:ubi9-16.10-2542' \
--env 'RELATED_IMAGE_POSTGRES_16_GIS_3.3=registry.developers.crunchydata.com/crunchydata/crunchy-postgres-gis:ubi9-16.10-3.3-2542' \
--env 'RELATED_IMAGE_POSTGRES_16_GIS_3.4=registry.developers.crunchydata.com/crunchydata/crunchy-postgres-gis:ubi9-16.10-3.4-2542' \
--env 'RELATED_IMAGE_POSTGRES_17=registry.developers.crunchydata.com/crunchydata/crunchy-postgres:ubi9-17.6-2542' \
--env 'RELATED_IMAGE_POSTGRES_17_GIS_3.4=registry.developers.crunchydata.com/crunchydata/crunchy-postgres-gis:ubi9-17.6-3.4-2542' \
--env 'RELATED_IMAGE_POSTGRES_17_GIS_3.5=registry.developers.crunchydata.com/crunchydata/crunchy-postgres-gis:ubi9-17.6-3.5-2542' \
--env 'RELATED_IMAGE_POSTGRES_17_GIS_3.6=registry.developers.crunchydata.com/crunchydata/crunchy-postgres-gis:ubi9-17.6-3.6-2542' \
--env 'RELATED_IMAGE_POSTGRES_18=registry.developers.crunchydata.com/crunchydata/crunchy-postgres:ubi9-18.0-2542' \
--env 'RELATED_IMAGE_POSTGRES_18_GIS_3.6=registry.developers.crunchydata.com/crunchydata/crunchy-postgres-gis:ubi9-18.0-3.6-2542' \
--env 'RELATED_IMAGE_STANDALONE_PGADMIN=registry.developers.crunchydata.com/crunchydata/crunchy-pgadmin4:ubi9-9.8-2542' \
--env 'RELATED_IMAGE_COLLECTOR=registry.developers.crunchydata.com/crunchydata/postgres-operator:ubi9-5.8.4-0' \
--env 'PGO_FEATURE_GATES=TablespaceVolumes=true,OpenTelemetryLogs=true,OpenTelemetryMetrics=true' \
--name 'postgres-operator' localhost/postgres-operator

Expand All @@ -153,7 +159,7 @@ jobs:
KUTTL_PG_UPGRADE_TO_VERSION: '17'
KUTTL_PG_VERSION: '16'
KUTTL_POSTGIS_VERSION: '3.4'
KUTTL_PSQL_IMAGE: 'registry.developers.crunchydata.com/crunchydata/crunchy-postgres:ubi9-16.10-2534'
KUTTL_PSQL_IMAGE: 'registry.developers.crunchydata.com/crunchydata/crunchy-postgres:ubi9-16.10-2542'
- run: |
make check-kuttl && exit
failed=$?
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ CONTROLLER ?= $(GO) tool sigs.k8s.io/controller-tools/cmd/controller-gen
CHAINSAW ?= $(GO) run github.com/kyverno/chainsaw@latest
CHAINSAW_TEST ?= $(CHAINSAW) test
CRD_CHECKER ?= $(GO) run github.com/openshift/crd-schema-checker/cmd/crd-schema-checker@latest
ENVTEST ?= $(GO) run sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
ENVTEST ?= $(GO) run sigs.k8s.io/controller-runtime/tools/setup-envtest@release-0.22
KUTTL ?= $(GO) run github.com/kudobuilder/kuttl/cmd/kubectl-kuttl@latest
KUTTL_TEST ?= $(KUTTL) test

Expand Down Expand Up @@ -205,7 +205,7 @@ generate-kuttl: export KUTTL_PG_UPGRADE_FROM_VERSION ?= 16
generate-kuttl: export KUTTL_PG_UPGRADE_TO_VERSION ?= 17
generate-kuttl: export KUTTL_PG_VERSION ?= 16
generate-kuttl: export KUTTL_POSTGIS_VERSION ?= 3.4
generate-kuttl: export KUTTL_PSQL_IMAGE ?= registry.developers.crunchydata.com/crunchydata/crunchy-postgres:ubi9-17.6-2534
generate-kuttl: export KUTTL_PSQL_IMAGE ?= registry.developers.crunchydata.com/crunchydata/crunchy-postgres:ubi9-17.6-2542
generate-kuttl: export KUTTL_TEST_DELETE_NAMESPACE ?= kuttl-test-delete-namespace
generate-kuttl: ## Generate kuttl tests
[ ! -d testing/kuttl/e2e-generated ] || rm -r testing/kuttl/e2e-generated
Expand Down
30 changes: 18 additions & 12 deletions config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,35 @@ spec:
- name: CRUNCHY_DEBUG
value: "true"
- name: RELATED_IMAGE_POSTGRES_16
value: "registry.developers.crunchydata.com/crunchydata/crunchy-postgres:ubi9-16.10-2534"
value: "registry.developers.crunchydata.com/crunchydata/crunchy-postgres:ubi9-16.10-2542"
- name: RELATED_IMAGE_POSTGRES_16_GIS_3.3
value: "registry.developers.crunchydata.com/crunchydata/crunchy-postgres-gis:ubi9-16.10-3.3-2534"
value: "registry.developers.crunchydata.com/crunchydata/crunchy-postgres-gis:ubi9-16.10-3.3-2542"
- name: RELATED_IMAGE_POSTGRES_16_GIS_3.4
value: "registry.developers.crunchydata.com/crunchydata/crunchy-postgres-gis:ubi9-16.10-3.4-2534"
value: "registry.developers.crunchydata.com/crunchydata/crunchy-postgres-gis:ubi9-16.10-3.4-2542"
- name: RELATED_IMAGE_POSTGRES_17
value: "registry.developers.crunchydata.com/crunchydata/crunchy-postgres:ubi9-17.6-2534"
value: "registry.developers.crunchydata.com/crunchydata/crunchy-postgres:ubi9-17.6-2542"
- name: RELATED_IMAGE_POSTGRES_17_GIS_3.4
value: "registry.developers.crunchydata.com/crunchydata/crunchy-postgres-gis:ubi9-17.6-3.4-2534"
value: "registry.developers.crunchydata.com/crunchydata/crunchy-postgres-gis:ubi9-17.6-3.4-2542"
- name: RELATED_IMAGE_POSTGRES_17_GIS_3.5
value: "registry.developers.crunchydata.com/crunchydata/crunchy-postgres-gis:ubi9-17.6-3.5-2534"
value: "registry.developers.crunchydata.com/crunchydata/crunchy-postgres-gis:ubi9-17.6-3.5-2542"
- name: RELATED_IMAGE_POSTGRES_17_GIS_3.6
value: "registry.developers.crunchydata.com/crunchydata/crunchy-postgres-gis:ubi9-17.6-3.5-2542"
- name: RELATED_IMAGE_POSTGRES_18
value: "registry.developers.crunchydata.com/crunchydata/crunchy-postgres:ubi9-18.0-2542"
- name: RELATED_IMAGE_POSTGRES_18_GIS_3.6
value: "registry.developers.crunchydata.com/crunchydata/crunchy-postgres-gis:ubi9-18.0-3.6-2542"
- name: RELATED_IMAGE_PGBACKREST
value: "registry.developers.crunchydata.com/crunchydata/crunchy-pgbackrest:ubi9-2.56.0-2534"
value: "registry.developers.crunchydata.com/crunchydata/crunchy-pgbackrest:ubi9-2.56.0-2542"
- name: RELATED_IMAGE_PGBOUNCER
value: "registry.developers.crunchydata.com/crunchydata/crunchy-pgbouncer:ubi9-1.24-2534"
value: "registry.developers.crunchydata.com/crunchydata/crunchy-pgbouncer:ubi9-1.24-2542"
- name: RELATED_IMAGE_PGEXPORTER
value: "registry.developers.crunchydata.com/crunchydata/crunchy-postgres-exporter:ubi9-0.17.1-2534"
value: "registry.developers.crunchydata.com/crunchydata/crunchy-postgres-exporter:ubi9-0.17.1-2542"
- name: RELATED_IMAGE_PGUPGRADE
value: "registry.developers.crunchydata.com/crunchydata/crunchy-upgrade:ubi9-17.6-2534"
value: "registry.developers.crunchydata.com/crunchydata/crunchy-upgrade:ubi9-18.0-2542"
- name: RELATED_IMAGE_STANDALONE_PGADMIN
value: "registry.developers.crunchydata.com/crunchydata/crunchy-pgadmin4:ubi9-9.2-2534"
value: "registry.developers.crunchydata.com/crunchydata/crunchy-pgadmin4:ubi9-9.8-2542"
- name: RELATED_IMAGE_COLLECTOR
value: "registry.developers.crunchydata.com/crunchydata/postgres-operator:ubi9-5.8.3-0"
value: "registry.developers.crunchydata.com/crunchydata/postgres-operator:ubi9-5.8.4-0"
securityContext:
allowPrivilegeEscalation: false
capabilities: { drop: [ALL] }
Expand Down
56 changes: 43 additions & 13 deletions internal/controller/postgrescluster/pgmonitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ func (r *Reconciler) reconcilePGMonitorExporter(ctx context.Context,
monitoringSecret *corev1.Secret) error {

var (
err error
writableInstance *Instance
writablePod *corev1.Pod
setup string
Expand All @@ -64,23 +65,11 @@ func (r *Reconciler) reconcilePGMonitorExporter(ctx context.Context,
// that function against an updated and running pod.

if pgmonitor.ExporterEnabled(ctx, cluster) || collector.OpenTelemetryMetricsEnabled(ctx, cluster) {
sql, err := os.ReadFile(fmt.Sprintf("%s/pg%d/setup.sql", pgmonitor.GetQueriesConfigDir(ctx), cluster.Spec.PostgresVersion))
setup, err = r.reconcileExporterSqlSetup(ctx, cluster)
if err != nil {
return err
}

if collector.OpenTelemetryMetricsEnabled(ctx, cluster) {
setup = metricsSetupForOTelCollector
} else {
// TODO: Revisit how pgbackrest_info.sh is used with pgMonitor.
// pgMonitor queries expect a path to a script that runs pgBackRest
// info and provides json output. In the queries yaml for pgBackRest
// the default path is `/usr/bin/pgbackrest-info.sh`. We update
// the path to point to the script in our database image.
setup = strings.ReplaceAll(string(sql), "/usr/bin/pgbackrest-info.sh",
"/opt/crunchy/bin/postgres/pgbackrest_info.sh")
}

for _, containerStatus := range writablePod.Status.ContainerStatuses {
if containerStatus.Name == naming.ContainerDatabase {
pgImageSHA = containerStatus.ImageID
Expand Down Expand Up @@ -145,6 +134,47 @@ func (r *Reconciler) reconcilePGMonitorExporter(ctx context.Context,
return err
}

// reconcileExporterSqlSetup generates the setup.sql string based on
// whether the OTel metrics feature is enabled or not and the postgres
// version being used. This function assumes that at least one of
// OTel metrics or postgres_exporter are enabled.
func (r *Reconciler) reconcileExporterSqlSetup(ctx context.Context,
cluster *v1beta1.PostgresCluster) (string, error) {

// If OTel Metrics is enabled we always want to use it. Otherwise,
// we can assume that postgres_exporter is enabled and we should
// use that
if collector.OpenTelemetryMetricsEnabled(ctx, cluster) {
return metricsSetupForOTelCollector, nil
}

// pgMonitor will not be adding support for postgres_exporter for postgres
// versions past 17. If using postgres 18 or later with the postgres_exporter,
// create a warning event and set the sql setup to an empty string
pgVersion := cluster.Spec.PostgresVersion
if pgVersion > 17 {
r.Recorder.Eventf(cluster, corev1.EventTypeWarning, "ExporterNotSupportedForPostgresVersion",
"postgres_exporter not supported for pg%d; use OTel for postgres 18 and later",
pgVersion)
return "", nil
}

// OTel Metrics is not enabled and postgres is version 17 or less,
// go ahead and read the appropriate sql file, format the string,
// and return it
sql, err := os.ReadFile(fmt.Sprintf("%s/pg%d/setup.sql", pgmonitor.GetQueriesConfigDir(ctx), pgVersion))
if err != nil {
return "", err
}
// TODO: Revisit how pgbackrest_info.sh is used with pgMonitor.
// pgMonitor queries expect a path to a script that runs pgBackRest
// info and provides json output. In the queries yaml for pgBackRest
// the default path is `/usr/bin/pgbackrest-info.sh`. We update
// the path to point to the script in our database image.
return strings.ReplaceAll(string(sql), "/usr/bin/pgbackrest-info.sh",
"/opt/crunchy/bin/postgres/pgbackrest_info.sh"), nil
}

// reconcileMonitoringSecret reconciles the secret containing authentication
// for monitoring tools
func (r *Reconciler) reconcileMonitoringSecret(
Expand Down
Loading
Loading