diff --git a/common/zarf.yaml b/common/zarf.yaml index b454be0..ee28a74 100644 --- a/common/zarf.yaml +++ b/common/zarf.yaml @@ -57,3 +57,33 @@ components: if ./zarf tools kubectl get postgresql pg-cluster -n postgres; then ./zarf tools wait-for postgresql pg-cluster -n postgres '{.status.PostgresClusterStatus}'=Running fi + + - name: connection-pooler + required: true + only: + flavor: unicorn + actions: + onDeploy: + after: + - description: Configure unicorn connection pooler image + maxTotalSeconds: 300 + cmd: | + CLUSTER_NAME=$(./zarf tools kubectl get postgresql -n postgres -o jsonpath='{.items[0].metadata.name}') + + if [[ -z "$CLUSTER_NAME" ]]; then + echo "No Postgres cluster found in 'postgres' namespace. Skipping..." + exit 0 + fi + + POOLER_ENABLED=$(./zarf tools kubectl get postgresql -n postgres $CLUSTER_NAME -o jsonpath='{.spec.enableConnectionPooler}') + + if [[ "$POOLER_ENABLED" == "true" ]]; then + echo "Configuring connection-pooler" + ./zarf tools wait-for deployment "$CLUSTER_NAME-pooler" -n postgres exists + ./zarf tools kubectl set env -n postgres deployment "$CLUSTER_NAME-pooler" DATABASES_HOST="$CLUSTER_NAME" PGBOUNCER_LISTEN_PORT=5432 + ./zarf tools kubectl patch deployment "$CLUSTER_NAME-pooler" -n postgres -p \ + '{"spec":{"template":{"metadata":{"labels":{"uds/user":"70","uds/group":"70","uds/fsgroup":"70"}}}}}' + ./zarf tools wait-for deployment "$CLUSTER_NAME-pooler" -n postgres + else + echo "Connection pooler not enabled." + fi diff --git a/releaser.yaml b/releaser.yaml index f7f95fd..6a81ece 100644 --- a/releaser.yaml +++ b/releaser.yaml @@ -4,10 +4,10 @@ flavors: - name: upstream # renovate-uds: datasource=docker depName=ghcr.io/zalando/postgres-operator extractVersion=^v?(?\d+\.\d+\.\d+)$ - version: 1.15.1-uds.1 + version: 1.15.1-uds.2 - name: registry1 # renovate-uds: datasource=docker depName=registry1.dso.mil/ironbank/opensource/zalando/postgres-operator extractVersion=^v?(?\d+\.\d+\.\d+)$ - version: 1.15.0-uds.1 + version: 1.15.0-uds.2 - name: unicorn # renovate-uds: datasource=docker depName=quay.io/rfcurated/zalando/postgres-operator extractVersion=^v?(?\d+\.\d+\.\d+)$ - version: 1.15.0-uds.1 + version: 1.15.0-uds.2 diff --git a/zarf.yaml b/zarf.yaml index 2058697..11d4990 100644 --- a/zarf.yaml +++ b/zarf.yaml @@ -92,3 +92,10 @@ components: - quay.io/rfcurated/zalando/spilo-17:4.0-p3-jammy-fips-rfcurated # Container image that provides the postgres-exporter sidecar to create a metrics endpoint - quay.io/rfcurated/prometheuscommunity/postgres-exporter:0.19-jammy-scratch-bnt-fips-rfcurated + + - name: connection-pooler + required: true + only: + flavor: unicorn + import: + path: common