From e818f936efc74ac5c6dd48331142365f821750fd Mon Sep 17 00:00:00 2001 From: Boemeltrein <130394941+Boemeltrein@users.noreply.github.com> Date: Sat, 18 Oct 2025 00:05:13 +0200 Subject: [PATCH] feat(common): Add CNPG Vectorchord extension (#40702) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit **Description** https://github.com/tensorchord/cloudnative-pgvecto.rs Is depricated and VectorChord serves as the successor to [pgvecto.rs](https://github.com/tensorchord/pgvecto.rs) with better stability and performance. https://github.com/tensorchord/cloudnative-vectorchord Also needed when you want to use for example immich with this database extension type. ⚒️ Fixes # **⚙️ Type of change** - [x] ⚙️ Feature/App addition - [ ] 🪛 Bugfix - [ ] ⚠️ Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] 🔃 Refactor of current code - [ ] 📜 Documentation Changes **🧪 How Has This Been Tested?** Added the tests in the common. **📃 Notes:** **✔️ Checklist:** - [ ] ⚖️ My code follows the style guidelines of this project - [x] 👀 I have performed a self-review of my own code - [ ] #️⃣ I have commented my code, particularly in hard-to-understand areas - [ ] 📄 I have made changes to the documentation - [ ] 🧪 I have added tests to this description that prove my fix is effective or that my feature works - [ ] ⬆️ I increased versions for any altered app according to semantic versioning - [x] I made sure the title starts with `feat(chart-name):`, `fix(chart-name):`, `chore(chart-name):`, `docs(chart-name):` or `fix(docs):` **➕ App addition** If this PR is an app addition please make sure you have done the following. - [ ] 🖼️ I have added an icon in the Chart's root directory called `icon.png` --- _Please don't blindly check all the boxes. Read them and only check those that apply. Those checkboxes are there for the reviewer to see what is this all about and the status of this PR with a quick glance._ --- .../tests/cnpg/cluster_spec_test.yaml | 49 +++++++++++++++++++ .../tests/cnpg/cluster_validation_test.yaml | 2 +- .../common/templates/class/cnpg/_cluster.tpl | 3 ++ .../lib/cnpg/cluster/_bootstrapStandalone.tpl | 5 ++ .../lib/cnpg/cluster/_validation.tpl | 2 +- charts/library/common/values.yaml | 11 +++++ 6 files changed, 70 insertions(+), 2 deletions(-) diff --git a/charts/library/common-test/tests/cnpg/cluster_spec_test.yaml b/charts/library/common-test/tests/cnpg/cluster_spec_test.yaml index 6aa20d266f9..60d05496c41 100644 --- a/charts/library/common-test/tests/cnpg/cluster_spec_test.yaml +++ b/charts/library/common-test/tests/cnpg/cluster_spec_test.yaml @@ -572,6 +572,55 @@ tests: - CREATE EXTENSION IF NOT EXISTS vectors; - CREATE EXTENSION IF NOT EXISTS some-extension; + - it: should pass with vectorchord + set: + postgresVectorchord16Image: + repository: docker.io/vectorchord/vectorchord + tag: "some-tag" + cnpg: + my-pg: + enabled: true + user: app + database: app + password: test-password + type: vectorchord + cluster: + initdb: + postInitApplicationSQL: + - CREATE EXTENSION IF NOT EXISTS some-extension; + postgresql: + key1: value1 + key2: '{{ printf "test-tpl" }}' + preloadLibraries: + - pg_stat_statements + - pg_cron + asserts: + - documentIndex: *clusterDoc + isKind: + of: Cluster + - documentIndex: *clusterDoc + isSubset: + path: spec + content: + postgresql: + parameters: + key1: value1 + key2: test-tpl + shared_preload_libraries: + - pg_stat_statements + - pg_cron + - vchord.so + bootstrap: + initdb: + secret: + name: test-release-name-common-test-cnpg-my-pg-user + database: app + owner: app + dataChecksums: true + postInitApplicationSQL: + - CREATE EXTENSION IF NOT EXISTS vchord CASCADE; + - CREATE EXTENSION IF NOT EXISTS some-extension; + - it: should pass with enabled monitoring set: postgresTimescaledb16Image: diff --git a/charts/library/common-test/tests/cnpg/cluster_validation_test.yaml b/charts/library/common-test/tests/cnpg/cluster_validation_test.yaml index 0b3981ec361..8b648777b88 100644 --- a/charts/library/common-test/tests/cnpg/cluster_validation_test.yaml +++ b/charts/library/common-test/tests/cnpg/cluster_validation_test.yaml @@ -88,7 +88,7 @@ tests: type: invalid asserts: - failedTemplate: - errorMessage: CNPG Cluster - Expected [type] to be one of [postgres, postgis, timescaledb, vectors], but got [invalid] + errorMessage: CNPG Cluster - Expected [type] to be one of [postgres, postgis, timescaledb, vectors, vectorchord], but got [invalid] - it: should fail with invalid log level set: diff --git a/charts/library/common/templates/class/cnpg/_cluster.tpl b/charts/library/common/templates/class/cnpg/_cluster.tpl index 2c3dfe27ad3..e6ebfea5476 100644 --- a/charts/library/common/templates/class/cnpg/_cluster.tpl +++ b/charts/library/common/templates/class/cnpg/_cluster.tpl @@ -123,6 +123,9 @@ {{- if eq $objectData.type "vectors" -}} {{- $preloadLibraries = mustAppend $preloadLibraries "vectors.so" -}} {{- end -}} + {{- if eq $objectData.type "vectorchord" -}} + {{- $preloadLibraries = mustAppend $preloadLibraries "vchord.so" -}} + {{- end -}} {{/* Storage */}} {{- with $objectData.cluster.storage.size -}} diff --git a/charts/library/common/templates/lib/cnpg/cluster/_bootstrapStandalone.tpl b/charts/library/common/templates/lib/cnpg/cluster/_bootstrapStandalone.tpl index 99eb2408a62..fef02716c95 100644 --- a/charts/library/common/templates/lib/cnpg/cluster/_bootstrapStandalone.tpl +++ b/charts/library/common/templates/lib/cnpg/cluster/_bootstrapStandalone.tpl @@ -33,6 +33,11 @@ "CREATE EXTENSION IF NOT EXISTS vectors;") -}} {{- end -}} + {{- if eq $objectData.type "vectorchord" -}} + {{- $postInitApplicationSQL = concat $postInitApplicationSQL (list + "CREATE EXTENSION IF NOT EXISTS vchord CASCADE;") -}} + {{- end -}} + {{- if $objectData.cluster.initdb -}} {{- $postInitApplicationSQL = concat $postInitApplicationSQL ( $objectData.cluster.initdb.postInitApplicationSQL | default list ) -}} {{- $postInitSQL = concat $postInitSQL ( $objectData.cluster.initdb.postInitSQL | default list ) -}} diff --git a/charts/library/common/templates/lib/cnpg/cluster/_validation.tpl b/charts/library/common/templates/lib/cnpg/cluster/_validation.tpl index b0ea878daac..eac1e3342dc 100644 --- a/charts/library/common/templates/lib/cnpg/cluster/_validation.tpl +++ b/charts/library/common/templates/lib/cnpg/cluster/_validation.tpl @@ -39,7 +39,7 @@ {{- end -}} {{- if (hasKey $objectData "type") -}} - {{- $validTypes := (list "postgres" "postgis" "timescaledb" "vectors") -}} + {{- $validTypes := (list "postgres" "postgis" "timescaledb" "vectors" "vectorchord") -}} {{- if not (mustHas $objectData.type $validTypes) -}} {{- fail (printf "CNPG Cluster - Expected [type] to be one of [%s], but got [%s]" (join ", " $validTypes) $objectData.type) -}} {{- end -}} diff --git a/charts/library/common/values.yaml b/charts/library/common/values.yaml index 6dd6b367259..3bada8fdcfb 100644 --- a/charts/library/common/values.yaml +++ b/charts/library/common/values.yaml @@ -662,6 +662,16 @@ postgresVectors16Image: tag: "16.3-v0.2.1" pullPolicy: IfNotPresent +postgresVectorchord15Image: + repository: ghcr.io/tensorchord/cloudnative-vectorchord + tag: "15.14-0.5.3" + pullPolicy: IfNotPresent + +postgresVectorchord16Image: + repository: ghcr.io/tensorchord/cloudnative-vectorchord + tag: "16.10-0.5.3" + pullPolicy: IfNotPresent + # -- OpenVPN specific configuration # @default -- See below openvpnImage: @@ -1139,6 +1149,7 @@ cnpg: # * `postgis` # * `timescaledb` # * `vectors` + # * `vectorchord` type: postgres # Version of Postgresql to use, changes cluster naming scheme