Skip to content

Commit c78f5a7

Browse files
armrumnenciaNiccoloFei
authored
feat(configuration): allow customizing DefaultPgbouncerImage (cloudnative-pg#9232)
This change introduces a new operator configuration parameter `PGBOUNCER_IMAGE_NAME` (and `pgbouncerImageName` in the config map) to allow users to override the default PgBouncer image used by the operator. This is useful for air-gapped environments or when using internal registries. Closes cloudnative-pg#9231 --------- Signed-off-by: Armando Ruocco <armando.ruocco@enterprisedb.com> Signed-off-by: Marco Nenciarini <marco.nenciarini@enterprisedb.com> Signed-off-by: Niccolò Fei <niccolo.fei@enterprisedb.com> Co-authored-by: Marco Nenciarini <marco.nenciarini@enterprisedb.com> Co-authored-by: Niccolò Fei <niccolo.fei@enterprisedb.com>
1 parent 0c81024 commit c78f5a7

File tree

12 files changed

+28
-11
lines changed

12 files changed

+28
-11
lines changed

.github/renovate.json5

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
'contribute/**',
2121
'licenses/**',
2222
'pkg/versions/**',
23-
'pkg/specs/pgbouncer/',
2423
],
2524
postUpdateOptions: [
2625
'gomodTidy',
@@ -90,7 +89,6 @@
9089
customType: 'regex',
9190
managerFilePatterns: [
9291
'/^pkg\\/versions\\/versions\\.go$/',
93-
'/^pkg\\/specs\\/pgbouncer\\/deployments\\.go$/',
9492
],
9593
matchStrings: [
9694
'DefaultImageName = "(?<depName>.+?):(?<currentValue>.*?)"\\n',

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ LOCALBIN ?= $(shell pwd)/bin
5151

5252
BUILD_IMAGE ?= true
5353
POSTGRES_IMAGE_NAME ?= $(shell grep 'DefaultImageName.*=' "pkg/versions/versions.go" | cut -f 2 -d \")
54+
PGBOUNCER_IMAGE_NAME ?= $(shell grep 'DefaultPgbouncerImage.*=' "pkg/versions/versions.go" | cut -f 2 -d \")
5455
# renovate: datasource=github-releases depName=kubernetes-sigs/kustomize versioning=loose
5556
KUSTOMIZE_VERSION ?= v5.6.0
5657
# renovate: datasource=go depName=sigs.k8s.io/controller-tools
@@ -74,6 +75,7 @@ ARCH ?= amd64
7475
export CONTROLLER_IMG
7576
export BUILD_IMAGE
7677
export POSTGRES_IMAGE_NAME
78+
export PGBOUNCER_IMAGE_NAME
7779
export OPERATOR_MANIFEST_PATH
7880
# We don't need `trivialVersions=true` anymore, with `crd` it's ok for multi versions
7981
CRD_OPTIONS ?= "crd"
@@ -233,7 +235,8 @@ generate-manifest: manifests kustomize ## Generate manifest used for deployment.
233235
$(KUSTOMIZE) edit set image controller="${CONTROLLER_IMG_WITH_DIGEST}" ;\
234236
$(KUSTOMIZE) edit add patch --path env_override.yaml ;\
235237
$(KUSTOMIZE) edit add configmap controller-manager-env \
236-
--from-literal="POSTGRES_IMAGE_NAME=${POSTGRES_IMAGE_NAME}" ;\
238+
--from-literal="POSTGRES_IMAGE_NAME=${POSTGRES_IMAGE_NAME}" \
239+
--from-literal="PGBOUNCER_IMAGE_NAME=${PGBOUNCER_IMAGE_NAME}" ;\
237240
} ;\
238241
mkdir -p ${DIST_PATH} ;\
239242
$(KUSTOMIZE) build $$CONFIG_TMP_DIR/default > ${OPERATOR_MANIFEST_PATH} ;\

docs/src/operator_conf.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ Name | Description
5050
`MONITORING_QUERIES_CONFIGMAP` | The name of a ConfigMap in the operator's namespace with a set of default queries (to be specified under the key `queries`) to be applied to all created Clusters
5151
`MONITORING_QUERIES_SECRET` | The name of a Secret in the operator's namespace with a set of default queries (to be specified under the key `queries`) to be applied to all created Clusters
5252
`OPERATOR_IMAGE_NAME` | The name of the operator image used to bootstrap Pods. Defaults to the image specified during installation.
53+
`PGBOUNCER_IMAGE_NAME` | The name of the PgBouncer image used by default for new poolers. Defaults to the version specified in the operator.
5354
`POSTGRES_IMAGE_NAME` | The name of the PostgreSQL image used by default for new clusters. Defaults to the version specified in the operator.
5455
`PULL_SECRET_NAME` | Name of an additional pull secret to be defined in the operator's namespace and to be used to download images
5556
`STANDBY_TCP_USER_TIMEOUT` | Defines the [`TCP_USER_TIMEOUT` socket option](https://www.postgresql.org/docs/current/runtime-config-connection.html#GUC-TCP-USER-TIMEOUT) for replication connections from standby instances to the primary. Default is 0 (system's default).

hack/e2e/run-e2e-kind.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export LOG_DIR=${LOG_DIR:-$ROOT_DIR/_logs/}
4242
export ENABLE_APISERVER_AUDIT=${ENABLE_APISERVER_AUDIT:-false}
4343

4444
export POSTGRES_IMG=${POSTGRES_IMG:-$(grep 'DefaultImageName.*=' "${ROOT_DIR}/pkg/versions/versions.go" | cut -f 2 -d \")}
45+
export PGBOUNCER_IMG=${PGBOUNCER_IMG:-$(grep 'DefaultPgbouncerImage.*=' "${ROOT_DIR}/pkg/versions/versions.go" | cut -f 2 -d \")}
4546
export E2E_PRE_ROLLING_UPDATE_IMG=${E2E_PRE_ROLLING_UPDATE_IMG:-${POSTGRES_IMG%.*}}
4647
export E2E_DEFAULT_STORAGE_CLASS=${E2E_DEFAULT_STORAGE_CLASS:-standard}
4748
export E2E_CSI_STORAGE_CLASS=${E2E_CSI_STORAGE_CLASS:-csi-hostpath-sc}

hack/e2e/run-e2e-local.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,15 @@ function get_postgres_image() {
5454
grep 'DefaultImageName.*=' "${ROOT_DIR}/pkg/versions/versions.go" | cut -f 2 -d \"
5555
}
5656

57+
function get_pgbouncer_image() {
58+
grep 'DefaultPgbouncerImage.*=' "${ROOT_DIR}/pkg/versions/versions.go" | cut -f 2 -d \"
59+
}
60+
5761
export E2E_DEFAULT_STORAGE_CLASS=${E2E_DEFAULT_STORAGE_CLASS:-$(get_default_storage_class)}
5862
export E2E_CSI_STORAGE_CLASS=${E2E_CSI_STORAGE_CLASS:-csi-hostpath-sc}
5963
export E2E_DEFAULT_VOLUMESNAPSHOT_CLASS=${E2E_DEFAULT_VOLUMESNAPSHOT_CLASS:-$(get_default_snapshot_class "$E2E_CSI_STORAGE_CLASS")}
6064
export POSTGRES_IMG=${POSTGRES_IMG:-$(get_postgres_image)}
65+
export PGBOUNCER_IMG=${PGBOUNCER_IMG:-$(get_pgbouncer_image)}
6166
export E2E_PRE_ROLLING_UPDATE_IMG=${E2E_PRE_ROLLING_UPDATE_IMG:-${POSTGRES_IMG%.*}}
6267

6368
# Ensure GOBIN is in path, we'll use this to install and execute ginkgo

hack/e2e/run-e2e-ocp.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ function retry {
7676
ROOT_DIR=$(realpath "$(dirname "$0")/../../")
7777
# we need to export ENVs defined in the workflow and used in run-e2e.sh script
7878
export POSTGRES_IMG=${POSTGRES_IMG:-$(grep 'DefaultImageName.*=' "${ROOT_DIR}/pkg/versions/versions.go" | cut -f 2 -d \")}
79+
export PGBOUNCER_IMG=${PGBOUNCER_IMG:-$(grep 'DefaultPgbouncerImage.*=' "${ROOT_DIR}/pkg/versions/versions.go" | cut -f 2 -d \")}
7980
export E2E_PRE_ROLLING_UPDATE_IMG=${E2E_PRE_ROLLING_UPDATE_IMG:-${POSTGRES_IMG%.*}}
8081
export E2E_DEFAULT_STORAGE_CLASS=${E2E_DEFAULT_STORAGE_CLASS:-standard}
8182
export E2E_CSI_STORAGE_CLASS=${E2E_CSI_STORAGE_CLASS:-}

hack/e2e/run-e2e.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ CONTROLLER_IMG_DIGEST=${CONTROLLER_IMG_DIGEST:-""}
3232
CONTROLLER_IMG_PRIME_DIGEST=${CONTROLLER_IMG_PRIME_DIGEST:-""}
3333
TEST_UPGRADE_TO_V1=${TEST_UPGRADE_TO_V1:-true}
3434
POSTGRES_IMG=${POSTGRES_IMG:-$(grep 'DefaultImageName.*=' "${ROOT_DIR}/pkg/versions/versions.go" | cut -f 2 -d \")}
35+
PGBOUNCER_IMG=${PGBOUNCER_IMG:-$(grep 'DefaultPgbouncerImage.*=' "${ROOT_DIR}/pkg/versions/versions.go" | cut -f 2 -d \")}
36+
3537
# variable need export otherwise be invisible in e2e test case
3638
export DOCKER_SERVER=${DOCKER_SERVER:-${REGISTRY:-}}
3739
export DOCKER_USERNAME=${DOCKER_USERNAME:-${REGISTRY_USER:-}}
@@ -89,6 +91,7 @@ if [[ "${TEST_UPGRADE_TO_V1}" != "false" ]] && [[ "${TEST_CLOUD_VENDOR}" != "ocp
8991
# - built and pushed to nodes or the local registry (by setup-cluster.sh)
9092
# - built by the `buildx` step in continuous delivery and pushed to the test registry
9193
make CONTROLLER_IMG="${CONTROLLER_IMG}" POSTGRES_IMG="${POSTGRES_IMG}" \
94+
PGBOUNCER_IMG="${PGBOUNCER_IMG}" \
9295
CONTROLLER_IMG_DIGEST="${CONTROLLER_IMG_DIGEST}" \
9396
OPERATOR_MANIFEST_PATH="${ROOT_DIR}/tests/e2e/fixtures/upgrade/current-manifest.yaml" \
9497
generate-manifest
@@ -104,6 +107,7 @@ if [[ "${TEST_UPGRADE_TO_V1}" != "false" ]] && [[ "${TEST_CLOUD_VENDOR}" != "ocp
104107
# added to the tag by convention, which assumes the image is in place.
105108
# This manifest is used to upgrade into in the upgrade_test E2E.
106109
make CONTROLLER_IMG="${CONTROLLER_IMG}-prime" POSTGRES_IMG="${POSTGRES_IMG}" \
110+
PGBOUNCER_IMG="${PGBOUNCER_IMG}" \
107111
CONTROLLER_IMG_DIGEST="${CONTROLLER_IMG_PRIME_DIGEST}" \
108112
OPERATOR_MANIFEST_PATH="${ROOT_DIR}/tests/e2e/fixtures/upgrade/current-manifest-prime.yaml" \
109113
generate-manifest
@@ -130,6 +134,7 @@ if [[ "${TEST_CLOUD_VENDOR}" != "ocp" ]]; then
130134

131135
CONTROLLER_IMG="${CONTROLLER_IMG}" \
132136
POSTGRES_IMAGE_NAME="${POSTGRES_IMG}" \
137+
PGBOUNCER_IMAGE_NAME="${PGBOUNCER_IMG}" \
133138
make -C "${ROOT_DIR}" deploy
134139
kubectl wait --for=condition=Available --timeout=2m \
135140
-n cnpg-system deployments \

hack/setup-cluster.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ builder_name=cnpg-builder
8989
# #########################################################################
9090
POSTGRES_IMG=${POSTGRES_IMG:-$(grep 'DefaultImageName.*=' "${ROOT_DIR}/pkg/versions/versions.go" | cut -f 2 -d \")}
9191
E2E_PRE_ROLLING_UPDATE_IMG=${E2E_PRE_ROLLING_UPDATE_IMG:-${POSTGRES_IMG%.*}}
92-
PGBOUNCER_IMG=${PGBOUNCER_IMG:-$(grep 'DefaultPgbouncerImage.*=' "${ROOT_DIR}/pkg/specs/pgbouncer/deployments.go" | cut -f 2 -d \")}
92+
PGBOUNCER_IMG=${PGBOUNCER_IMG:-$(grep 'DefaultPgbouncerImage.*=' "${ROOT_DIR}/pkg/versions/versions.go" | cut -f 2 -d \")}
9393
MINIO_IMG=${MINIO_IMG:-$(grep 'minioImage.*=' "${ROOT_DIR}/tests/utils/minio/minio.go" | cut -f 2 -d \")}
9494
APACHE_IMG=${APACHE_IMG:-"httpd"}
9595

internal/configuration/configuration.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ type Data struct {
108108
// used by default for new clusters
109109
PostgresImageName string `json:"postgresImageName" env:"POSTGRES_IMAGE_NAME"`
110110

111+
// PgbouncerImageName is the name of the image of PgBouncer that is
112+
// used by default for new poolers
113+
PgbouncerImageName string `json:"pgbouncerImageName" env:"PGBOUNCER_IMAGE_NAME"`
114+
111115
// InheritedAnnotations is a list of annotations that every resource could inherit from
112116
// the owning Cluster
113117
InheritedAnnotations []string `json:"inheritedAnnotations" env:"INHERITED_ANNOTATIONS"`
@@ -180,6 +184,7 @@ func newDefaultConfig() *Data {
180184
OperatorPullSecretName: DefaultOperatorPullSecretName,
181185
OperatorImageName: versions.DefaultOperatorImageName,
182186
PostgresImageName: versions.DefaultImageName,
187+
PgbouncerImageName: versions.DefaultPgbouncerImage,
183188
PluginSocketDir: DefaultPluginSocketDir,
184189
CreateAnyService: false,
185190
CertificateDuration: CertificateDuration,

pkg/specs/pgbouncer/deployments.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,6 @@ import (
4040
"github.com/cloudnative-pg/cloudnative-pg/pkg/utils/hash"
4141
)
4242

43-
const (
44-
// DefaultPgbouncerImage is the name of the pgbouncer image used by default
45-
DefaultPgbouncerImage = "ghcr.io/cloudnative-pg/pgbouncer:1.24.1"
46-
)
47-
4843
// Deployment create the deployment of pgbouncer, given
4944
// the configurations we have in the pooler specifications
5045
func Deployment(pooler *apiv1.Pooler, cluster *apiv1.Cluster) (*appsv1.Deployment, error) {
@@ -80,7 +75,7 @@ func Deployment(pooler *apiv1.Pooler, cluster *apiv1.Cluster) (*appsv1.Deploymen
8075
},
8176
}).
8277
WithSecurityContext(createPodSecurityContext(cluster.GetSeccompProfile(), 998, 996), true).
83-
WithContainerImage("pgbouncer", DefaultPgbouncerImage, false).
78+
WithContainerImage("pgbouncer", config.Current.PgbouncerImageName, false).
8479
WithContainerCommand("pgbouncer", []string{
8580
"/controller/manager",
8681
"pgbouncer",

0 commit comments

Comments
 (0)