From ab0dbe3a09f5cdb581f97423cca60e8790f6bb51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20No=C3=ABl?= <21990816+philippemnoel@users.noreply.github.com> Date: Sun, 13 Oct 2024 15:28:38 -0400 Subject: [PATCH] feat: Add `pg_cron` and Postgis (#44) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Philippe Noël <21990816+philippemnoel@users.noreply.github.com> --- .github/workflows/paradedb-test-eks.yml | 4 ++-- README.md | 8 ++++++++ charts/paradedb/README.md | 12 ++++++++++++ charts/paradedb/templates/_bootstrap.tpl | 19 ++++++++++++++++++- ..._default_configuration_cluster-assert.yaml | 3 +++ .../01-non_default_configuration_cluster.yaml | 3 +++ charts/paradedb/values.yaml | 7 ++++--- 7 files changed, 50 insertions(+), 6 deletions(-) diff --git a/.github/workflows/paradedb-test-eks.yml b/.github/workflows/paradedb-test-eks.yml index 901c98572..8148e3f86 100644 --- a/.github/workflows/paradedb-test-eks.yml +++ b/.github/workflows/paradedb-test-eks.yml @@ -21,7 +21,7 @@ concurrency: jobs: paradedb-test-eks: name: Test ParadeDB Helm Chart on AWS EKS via LocalStack - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 # As of October 2024, the LocalStack GitHub Action is not compatible with Ubuntu 24.04 if: github.event.pull_request.draft == false steps: @@ -35,7 +35,7 @@ jobs: uses: azure/setup-helm@v4 - name: Start LocalStack - uses: LocalStack/setup-localstack@v0.2.2 + uses: LocalStack/setup-localstack@v0.2.3 with: image-tag: "latest" install-awslocal: "true" diff --git a/README.md b/README.md index 984d23e3c..ceef6acf0 100644 --- a/README.md +++ b/README.md @@ -91,6 +91,14 @@ This will launch a shell inside the instance. You can connect via `psql` with: psql -d paradedb ``` +## Development + +To test changes to the Chart on a local Minikube cluster, follow the instructions from [Getting Started](#getting-started), replacing the `helm upgrade` step by the path to the directory of the modified `Chart.yaml`. + +```bash +helm upgrade --install paradedb --namespace paradedb-database --create-namespace ./charts/paradedb +``` + ## License ParadeDB is licensed under the [GNU Affero General Public License v3.0](LICENSE) and as commercial software. For commercial licensing, please contact us at [sales@paradedb.com](mailto:sales@paradedb.com). diff --git a/charts/paradedb/README.md b/charts/paradedb/README.md index 2d5c9fef4..90c16adfd 100644 --- a/charts/paradedb/README.md +++ b/charts/paradedb/README.md @@ -65,6 +65,14 @@ This will launch a shell inside the instance. You can connect via `psql` with: psql -d paradedb ``` +## Development + +To test changes to the Chart on a local Minikube cluster, follow the instructions from [Getting Started](#getting-started), replacing the `helm upgrade` step by the path to the directory of the modified `Chart.yaml`. + +```bash +helm upgrade --install paradedb --namespace paradedb-database --create-namespace ./charts/paradedb +``` + Cluster Configuration --------------------- @@ -258,3 +266,7 @@ refer to the [CloudNativePG Documentation](https://cloudnative-pg.io/documentat | Name | Email | Url | | ---- | ------ | --- | | ParadeDB | | | + +## License + +ParadeDB is licensed under the [GNU Affero General Public License v3.0](LICENSE) and as commercial software. For commercial licensing, please contact us at [sales@paradedb.com](mailto:sales@paradedb.com). diff --git a/charts/paradedb/templates/_bootstrap.tpl b/charts/paradedb/templates/_bootstrap.tpl index 3cd2afa78..8aa1fa290 100644 --- a/charts/paradedb/templates/_bootstrap.tpl +++ b/charts/paradedb/templates/_bootstrap.tpl @@ -3,19 +3,32 @@ bootstrap: initdb: {{- with .Values.cluster.initdb }} - {{- with (omit . "postInitApplicationSQL" "postInitTemplateSQL" "owner") }} + {{- with (omit . "postInitSQL" "postInitApplicationSQL" "postInitTemplateSQL" "owner") }} {{- . | toYaml | nindent 4 }} {{- end }} {{- end }} {{- if .Values.cluster.initdb.owner }} owner: {{ tpl .Values.cluster.initdb.owner . }} {{- end }} + postInitSQL: + {{- if eq .Values.type "paradedb" }} + - CREATE EXTENSION IF NOT EXISTS pg_cron; + {{- end }} + {{- with .Values.cluster.initdb }} + {{- range .postInitSQL }} + {{- printf "- %s" . | nindent 6 }} + {{- end -}} + {{- end }} postInitApplicationSQL: {{- if eq .Values.type "paradedb" }} - CREATE EXTENSION IF NOT EXISTS pg_search; - CREATE EXTENSION IF NOT EXISTS pg_analytics; - CREATE EXTENSION IF NOT EXISTS pg_ivm; - CREATE EXTENSION IF NOT EXISTS vector; + - CREATE EXTENSION IF NOT EXISTS postgis; + - CREATE EXTENSION IF NOT EXISTS postgis_topology; + - CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + - CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; - ALTER DATABASE "{{ default "paradedb" .Values.cluster.initdb.database }}" SET search_path TO public,paradedb; {{- end }} {{- with .Values.cluster.initdb }} @@ -29,6 +42,10 @@ bootstrap: - CREATE EXTENSION IF NOT EXISTS pg_analytics; - CREATE EXTENSION IF NOT EXISTS pg_ivm; - CREATE EXTENSION IF NOT EXISTS vector; + - CREATE EXTENSION IF NOT EXISTS postgis; + - CREATE EXTENSION IF NOT EXISTS postgis_topology; + - CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + - CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; - ALTER DATABASE template1 SET search_path TO public,paradedb; {{- end }} {{- with .Values.cluster.initdb }} diff --git a/charts/paradedb/test/postgresql-cluster-configuration/01-non_default_configuration_cluster-assert.yaml b/charts/paradedb/test/postgresql-cluster-configuration/01-non_default_configuration_cluster-assert.yaml index ef3ce169c..9a2efc44e 100644 --- a/charts/paradedb/test/postgresql-cluster-configuration/01-non_default_configuration_cluster-assert.yaml +++ b/charts/paradedb/test/postgresql-cluster-configuration/01-non_default_configuration_cluster-assert.yaml @@ -15,12 +15,14 @@ spec: postgresql: parameters: max_connections: "42" + cron.database_name: "postgres" pg_hba: - host all 1.2.3.4/32 trust pg_ident: - mymap /^(.*)@mydomain\.com$ \1 shared_preload_libraries: - pgaudit + - pg_cron bootstrap: initdb: database: mydb @@ -32,6 +34,7 @@ spec: postInitTemplateSQL: - CREATE TABLE mytable (id serial PRIMARY KEY, name VARCHAR(255)); postInitSQL: + - CREATE EXTENSION IF NOT EXISTS pg_cron; - CREATE TABLE mytable (id serial PRIMARY KEY, name VARCHAR(255)); superuserSecret: name: supersecret-secret diff --git a/charts/paradedb/test/postgresql-cluster-configuration/01-non_default_configuration_cluster.yaml b/charts/paradedb/test/postgresql-cluster-configuration/01-non_default_configuration_cluster.yaml index 570ea8409..53a534a89 100644 --- a/charts/paradedb/test/postgresql-cluster-configuration/01-non_default_configuration_cluster.yaml +++ b/charts/paradedb/test/postgresql-cluster-configuration/01-non_default_configuration_cluster.yaml @@ -55,12 +55,14 @@ cluster: postgresql: parameters: max_connections: "42" + cron.database_name: "postgres" pg_hba: - host all 1.2.3.4/32 trust pg_ident: - mymap /^(.*)@mydomain\.com$ \1 shared_preload_libraries: - pgaudit + - pg_cron initdb: database: mydb owner: dante @@ -71,6 +73,7 @@ cluster: postInitTemplateSQL: - CREATE TABLE mytable (id serial PRIMARY KEY, name VARCHAR(255)); postInitSQL: + - CREATE EXTENSION IF NOT EXISTS pg_cron; - CREATE TABLE mytable (id serial PRIMARY KEY, name VARCHAR(255)); additionalLabels: foo: bar diff --git a/charts/paradedb/values.yaml b/charts/paradedb/values.yaml index 70e9156b9..25a92e1ae 100644 --- a/charts/paradedb/values.yaml +++ b/charts/paradedb/values.yaml @@ -237,7 +237,9 @@ cluster: postgresql: # -- PostgreSQL configuration options (postgresql.conf) - parameters: {} + parameters: + # Required by pg_cron + cron.database_name: postgres # max_connections: 300 # -- PostgreSQL Host Based Authentication rules (lines to be appended to the pg_hba.conf file) pg_hba: [] @@ -259,8 +261,7 @@ cluster: # name: "" # Name of the secret containing the initial credentials for the owner of the user database. If empty a new secret will be created from scratch # options: [] # encoding: UTF8 - # postInitSQL: - # - CREATE EXTENSION IF NOT EXISTS vector; + # postInitSQL: [] # postInitApplicationSQL: [] # postInitTemplateSQL: []