Skip to content

feat: dynamic loading of PostgreSQL extensions#7991

Merged
gbartolini merged 29 commits intomainfrom
dev/7188
Jul 24, 2025
Merged

feat: dynamic loading of PostgreSQL extensions#7991
gbartolini merged 29 commits intomainfrom
dev/7188

Conversation

@NiccoloFei
Copy link
Copy Markdown
Collaborator

@NiccoloFei NiccoloFei commented Jul 7, 2025

This feature allows you to mount a PostgreSQL extension, packaged as an OCI-compliant container image, as a read-only, immutable volume inside an instance pod.

The new .spec.postgresql.extensions stanza of a Cluster resource accepts an ordered list of extension images to be added to the PostgreSQL cluster. Each item in the extensions stanza is identified by name and provides the following options:

  • extension_control_path: A list of relative paths within the container image to be appended to PostgreSQL’s extension_control_path, allowing it to locate extension control files (default: share).
  • dynamic_library_path: A list of relative paths within the container image to be appended to PostgreSQL’s dynamic_library_path, enabling it to locate shared library files for extensions (default: lib).
  • ld_library_path: A list of relative paths within the container image to be appended to the LD_LIBRARY_PATH environment variable of the instance manager process, allowing PostgreSQL to locate required system libraries at runtime (default: empty).

Each image volume is mounted at /extensions/<EXTENSION_NAME>. By default, CloudNativePG automatically manages the relevant PostgreSQL GUCs, setting:

  • extension_control_path to /extensions/<EXTENSION_NAME>/share, allowing PostgreSQL to locate any extension control file within /extensions/<EXTENSION_NAME>/share/extension
  • dynamic_library_path to /extensions/<EXTENSION_NAME>/lib

These values are appended in the order in which the extensions are defined in the extensions list, ensuring deterministic path resolution within PostgreSQL.

Requirements:

  • PostgreSQL 18 or higher (for the extension_control_path option)
  • Kubernetes 1.33+ with the ImageVolume feature enabled

Closes #7188

@NiccoloFei NiccoloFei requested review from a team and jsilvela as code owners July 7, 2025 12:29
@cnpg-bot cnpg-bot added backport-requested ◀️ This pull request should be backported to all supported releases release-1.22 release-1.25 release-1.26 labels Jul 7, 2025
@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Jul 7, 2025
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jul 7, 2025

❗ By default, the pull request is configured to backport to all release branches.

  • To stop backporting this pr, remove the label: backport-requested ◀️ or add the label 'do not backport'
  • To stop backporting this pr to a certain release branch, remove the specific branch label: release-x.y

@dosubot dosubot bot added documentation 📖 Improvements or additions to documentation enhancement 🪄 New feature or request labels Jul 7, 2025
@NiccoloFei NiccoloFei added do not backport This PR must not be backported - it will be in the next minor release and removed backport-requested ◀️ This pull request should be backported to all supported releases release-1.22 release-1.25 release-1.26 documentation 📖 Improvements or additions to documentation labels Jul 7, 2025
@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Jul 8, 2025
@NiccoloFei NiccoloFei requested a review from litaocdl as a code owner July 14, 2025 15:17
@NiccoloFei NiccoloFei force-pushed the dev/7188 branch 3 times, most recently from 38e8cf4 to 6dcce2d Compare July 15, 2025 15:25
@dosubot dosubot bot added size:XXL This PR changes 1000+ lines, ignoring generated files. and removed size:XL This PR changes 500-999 lines, ignoring generated files. labels Jul 16, 2025
@NiccoloFei NiccoloFei force-pushed the dev/7188 branch 2 times, most recently from 91e9ea7 to 9579952 Compare July 17, 2025 11:49
gbartolini and others added 23 commits July 24, 2025 14:29
Signed-off-by: Gabriele Bartolini <[email protected]>
Signed-off-by: Gabriele Bartolini <[email protected]>
Signed-off-by: Gabriele Bartolini <[email protected]>
Signed-off-by: Gabriele Bartolini <[email protected]>
Signed-off-by: Leonardo Cecchi <[email protected]>
Signed-off-by: Gabriele Bartolini <[email protected]>
Signed-off-by: Leonardo Cecchi <[email protected]>
Signed-off-by: Leonardo Cecchi <[email protected]>
Signed-off-by: Armando Ruocco <[email protected]>
Signed-off-by: Marco Nenciarini <[email protected]>
Signed-off-by: Gabriele Bartolini <[email protected]>
Signed-off-by: Gabriele Bartolini <[email protected]>
Signed-off-by: Gabriele Bartolini <[email protected]>
Signed-off-by: Marco Nenciarini <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not backport This PR must not be backported - it will be in the next minor release enhancement 🪄 New feature or request lgtm This PR has been approved by a maintainer ok to merge 👌 This PR can be merged size:XXL This PR changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Dynamic loading of PostgreSQL extensions

7 participants