From 506ddc17330749ecdc3951d6e16b54e23131466c Mon Sep 17 00:00:00 2001 From: Itay Grudev Date: Tue, 10 Sep 2024 02:10:32 +0300 Subject: [PATCH] ParadeDB Support (#1) 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> Co-authored-by: Philippe Noël <21990816+philippemnoel@users.noreply.github.com> ci: AWS EKS LocalStack Tests (#14) Co-authored-by: Itay Grudev Co-authored-by: Itay Grudev Updated documentation workflows and cleanup (#18) Revert "Add postgresql default to tests" This reverts commit a9f340d28944ce6a194c23d36c75f4125a902409. Add repository_dispatch Signed-off-by: Philippe Noël <21990816+philippemnoel@users.noreply.github.com> chore: Configure repository for ParadeDB (#15) Co-authored-by: Itay Grudev chore: Create artifacthub-repo.yml (#20) Signed-off-by: Philippe Noël <21990816+philippemnoel@users.noreply.github.com> Put artifacthub-repo.yml in the right location Bug Fix: Tests (#21) Renamed chart to `paradedb-cluster` (#22) Co-authored-by: Philippe Noël Rm .DS_Store Remove extra HTML tag Signed-off-by: Philippe Noël <21990816+philippemnoel@users.noreply.github.com> Remove repository_dispatch Signed-off-by: Philippe Noël <21990816+philippemnoel@users.noreply.github.com> chore: Rename paradedb-cluster to paradedb (#28) chore: Try with adding missing -cluster (#33) chore: Final Cleanup (#34) chore: Remove PostGIS and Timescale (#35) Using the default UID/GID 999 from the postgres docker image (#26) Co-authored-by: Philippe Noël chore: Update README and Schema (#37) Signed-off-by: Philippe Noël <21990816+philippemnoel@users.noreply.github.com> chore(deps): pin sigstore/cosign-installer action to 4959ce0 (#403) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Rm pgvectorscale (#39) Signed-off-by: Philippe Noël <21990816+philippemnoel@users.noreply.github.com> feat: Add GitHub Actions Workflow to check for typos (#40) Signed-off-by: Philippe Noël <21990816+philippemnoel@users.noreply.github.com> Co-authored-by: Philippe Noël <21990816+philippemnoel@users.noreply.github.com> chore(deps): update kyverno/action-install-chainsaw action to v0.2.11 (#410) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Rename the default database from app to paradedb (#41) Co-authored-by: Philippe Noël docs: Clarify the docs (#42) Update Depot Revert "Update Depot" This reverts commit cb85b818e72793888b1a3a1e799a18cfaf8b04b3. feat: Add `pg_cron` and Postgis (#44) Signed-off-by: Philippe Noël <21990816+philippemnoel@users.noreply.github.com> chore: Use the new 0.11.0 release (#47) feat: Enable monitoring via Prometheus and Grafana (rebased) (#48) Rm extra files Remove duplicate block in README --- .github/workflows/tests-cluster-chainsaw.yaml | 23 +++ charts/paradedb/README.md | 4 +- .../00-minio_cleanup-assert.yaml | 6 + .../00-minio_cleanup.yaml | 16 ++ .../01-standalone_cluster-assert.yaml | 6 + .../01-standalone_cluster.yaml | 29 ++++ .../02-data_write-assert.yaml | 6 + .../02-data_write.yaml | 23 +++ .../03-backup.yaml | 8 + .../03-backup_completed-assert.yaml | 10 ++ .../03-backup_running-assert.yaml | 10 ++ .../03-checkpoint.yaml | 27 ++++ .../04-post_backup_data_write-assert.yaml | 6 + .../04-post_backup_data_write.yaml | 57 +++++++ .../05-recovery_backup_cluster-assert.yaml | 6 + .../05-recovery_backup_cluster.yaml | 48 ++++++ .../06-data_test-assert.yaml | 6 + .../06-data_test.yaml | 24 +++ ...-recovery_object_store_cluster-assert.yaml | 6 + .../07-recovery_object_store_cluster.yaml | 48 ++++++ .../08-data_test-assert.yaml | 6 + .../08-data_test.yaml | 24 +++ ...9-recovery_backup_pitr_cluster-assert.yaml | 6 + .../09-recovery_backup_pitr_cluster.yaml | 48 ++++++ .../10-data_test-assert.yaml | 6 + .../10-data_test.yaml | 27 ++++ .../chainsaw-test.yaml | 148 ++++++++++++++++++ .../00-minio_cleanup-assert.yaml | 6 + .../scheduledbackups/00-minio_cleanup.yaml | 16 ++ .../01-scheduledbackups_cluster-assert.yaml | 37 +++++ .../01-scheduledbackups_cluster.yaml | 35 +++++ .../test/scheduledbackups/chainsaw-test.yaml | 27 ++++ charts/paradedb/values.yaml | 4 +- 33 files changed, 756 insertions(+), 3 deletions(-) create mode 100644 charts/paradedb/test/postgresql-minio-backup-restore/00-minio_cleanup-assert.yaml create mode 100644 charts/paradedb/test/postgresql-minio-backup-restore/00-minio_cleanup.yaml create mode 100644 charts/paradedb/test/postgresql-minio-backup-restore/01-standalone_cluster-assert.yaml create mode 100644 charts/paradedb/test/postgresql-minio-backup-restore/01-standalone_cluster.yaml create mode 100644 charts/paradedb/test/postgresql-minio-backup-restore/02-data_write-assert.yaml create mode 100644 charts/paradedb/test/postgresql-minio-backup-restore/02-data_write.yaml create mode 100644 charts/paradedb/test/postgresql-minio-backup-restore/03-backup.yaml create mode 100644 charts/paradedb/test/postgresql-minio-backup-restore/03-backup_completed-assert.yaml create mode 100644 charts/paradedb/test/postgresql-minio-backup-restore/03-backup_running-assert.yaml create mode 100644 charts/paradedb/test/postgresql-minio-backup-restore/03-checkpoint.yaml create mode 100644 charts/paradedb/test/postgresql-minio-backup-restore/04-post_backup_data_write-assert.yaml create mode 100644 charts/paradedb/test/postgresql-minio-backup-restore/04-post_backup_data_write.yaml create mode 100644 charts/paradedb/test/postgresql-minio-backup-restore/05-recovery_backup_cluster-assert.yaml create mode 100644 charts/paradedb/test/postgresql-minio-backup-restore/05-recovery_backup_cluster.yaml create mode 100644 charts/paradedb/test/postgresql-minio-backup-restore/06-data_test-assert.yaml create mode 100644 charts/paradedb/test/postgresql-minio-backup-restore/06-data_test.yaml create mode 100644 charts/paradedb/test/postgresql-minio-backup-restore/07-recovery_object_store_cluster-assert.yaml create mode 100644 charts/paradedb/test/postgresql-minio-backup-restore/07-recovery_object_store_cluster.yaml create mode 100644 charts/paradedb/test/postgresql-minio-backup-restore/08-data_test-assert.yaml create mode 100644 charts/paradedb/test/postgresql-minio-backup-restore/08-data_test.yaml create mode 100644 charts/paradedb/test/postgresql-minio-backup-restore/09-recovery_backup_pitr_cluster-assert.yaml create mode 100644 charts/paradedb/test/postgresql-minio-backup-restore/09-recovery_backup_pitr_cluster.yaml create mode 100644 charts/paradedb/test/postgresql-minio-backup-restore/10-data_test-assert.yaml create mode 100644 charts/paradedb/test/postgresql-minio-backup-restore/10-data_test.yaml create mode 100644 charts/paradedb/test/postgresql-minio-backup-restore/chainsaw-test.yaml create mode 100644 charts/paradedb/test/scheduledbackups/00-minio_cleanup-assert.yaml create mode 100644 charts/paradedb/test/scheduledbackups/00-minio_cleanup.yaml create mode 100644 charts/paradedb/test/scheduledbackups/01-scheduledbackups_cluster-assert.yaml create mode 100644 charts/paradedb/test/scheduledbackups/01-scheduledbackups_cluster.yaml create mode 100644 charts/paradedb/test/scheduledbackups/chainsaw-test.yaml diff --git a/.github/workflows/tests-cluster-chainsaw.yaml b/.github/workflows/tests-cluster-chainsaw.yaml index af27270f1..15e02743b 100644 --- a/.github/workflows/tests-cluster-chainsaw.yaml +++ b/.github/workflows/tests-cluster-chainsaw.yaml @@ -59,6 +59,29 @@ jobs: echo "Chart.yaml:" cat Chart.yaml + # Added by ParadeDB: Authenticate to Docker Hub to avoid rate limits + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }} + + # Added by ParadeDB: Always pull the latest version of paradedb/paradedb + - name: Set ParadeDB Version to Latest + working-directory: charts/paradedb/ + env: + GH_TOKEN: ${{ secrets.GHA_CREATE_RELEASE_PAT }} + run: | + LATEST_TAG=$(curl -s https://api.github.com/repos/paradedb/paradedb/tags | jq -r '.[0].name') + APP_VERSION=${LATEST_TAG#v} + sed -i "s/^[[:space:]]*paradedb: .*/ paradedb: \"$APP_VERSION\"/" values.yaml + sed -i "s/^version: .*/version: ${{ vars.CHART_VERSION_MAJOR }}.${{ vars.CHART_VERSION_MINOR }}.${{ vars.CHART_VERSION_PATCH }}/" Chart.yaml + echo "values.yaml:" + cat values.yaml + echo "----------------------------------------" + echo "Chart.yaml:" + cat Chart.yaml + - name: Setup kind uses: ./.github/actions/setup-kind diff --git a/charts/paradedb/README.md b/charts/paradedb/README.md index 8d161740d..748364ba6 100644 --- a/charts/paradedb/README.md +++ b/charts/paradedb/README.md @@ -211,7 +211,7 @@ refer to the [CloudNativePG Documentation](https://cloudnative-pg.io/documentat | cluster.monitoring.customQueries | list | `[]` | Custom Prometheus metrics Will be stored in the ConfigMap | | cluster.monitoring.customQueriesSecret | list | `[]` | The list of secrets containing the custom queries | | cluster.monitoring.disableDefaultQueries | bool | `false` | Whether the default queries should be injected. Set it to true if you don't want to inject default queries into the cluster. | -| cluster.monitoring.enabled | bool | `false` | Whether to enable monitoring | +| cluster.monitoring.enabled | bool | `true` | Whether to enable monitoring | | cluster.monitoring.podMonitor.enabled | bool | `true` | Whether to enable the PodMonitor | | cluster.monitoring.podMonitor.metricRelabelings | list | `[]` | The list of metric relabelings for the PodMonitor. Applied to samples before ingestion. | | cluster.monitoring.podMonitor.relabelings | list | `[]` | The list of relabelings for the PodMonitor. Applied to samples before scraping. | @@ -219,7 +219,7 @@ refer to the [CloudNativePG Documentation](https://cloudnative-pg.io/documentat | cluster.monitoring.prometheusRule.excludeRules | list | `[]` | Exclude specified rules | | cluster.postgresGID | int | `-1` | The GID of the postgres user inside the image, defaults to 26 | | cluster.postgresUID | int | `-1` | The UID of the postgres user inside the image, defaults to 26 | -| cluster.postgresql.parameters | object | `{}` | PostgreSQL configuration options (postgresql.conf) | +| cluster.postgresql.parameters | object | `{"cron.database_name":"postgres"}` | PostgreSQL configuration options (postgresql.conf) | | cluster.postgresql.pg_hba | list | `[]` | PostgreSQL Host Based Authentication rules (lines to be appended to the pg_hba.conf file) | | cluster.postgresql.pg_ident | list | `[]` | PostgreSQL User Name Maps rules (lines to be appended to the pg_ident.conf file) | | cluster.postgresql.shared_preload_libraries | list | `[]` | Lists of shared preload libraries to add to the default ones | diff --git a/charts/paradedb/test/postgresql-minio-backup-restore/00-minio_cleanup-assert.yaml b/charts/paradedb/test/postgresql-minio-backup-restore/00-minio_cleanup-assert.yaml new file mode 100644 index 000000000..04df941e4 --- /dev/null +++ b/charts/paradedb/test/postgresql-minio-backup-restore/00-minio_cleanup-assert.yaml @@ -0,0 +1,6 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: data-test +status: + succeeded: 1 diff --git a/charts/paradedb/test/postgresql-minio-backup-restore/00-minio_cleanup.yaml b/charts/paradedb/test/postgresql-minio-backup-restore/00-minio_cleanup.yaml new file mode 100644 index 000000000..19d550162 --- /dev/null +++ b/charts/paradedb/test/postgresql-minio-backup-restore/00-minio_cleanup.yaml @@ -0,0 +1,16 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: minio-cleanup +spec: + template: + spec: + restartPolicy: OnFailure + containers: + - name: minio-cleanup + image: minio/mc + command: ['sh', '-c'] + args: + - | + mc alias set myminio https://minio.minio.svc.cluster.local minio minio123 + mc rm --recursive --force myminio/mybucket/paradedb diff --git a/charts/paradedb/test/postgresql-minio-backup-restore/01-standalone_cluster-assert.yaml b/charts/paradedb/test/postgresql-minio-backup-restore/01-standalone_cluster-assert.yaml new file mode 100644 index 000000000..86d37e690 --- /dev/null +++ b/charts/paradedb/test/postgresql-minio-backup-restore/01-standalone_cluster-assert.yaml @@ -0,0 +1,6 @@ +apiVersion: postgresql.cnpg.io/v1 +kind: Cluster +metadata: + name: import-paradedb +status: + readyInstances: 2 diff --git a/charts/paradedb/test/postgresql-minio-backup-restore/01-standalone_cluster.yaml b/charts/paradedb/test/postgresql-minio-backup-restore/01-standalone_cluster.yaml new file mode 100644 index 000000000..a2e87e1d9 --- /dev/null +++ b/charts/paradedb/test/postgresql-minio-backup-restore/01-standalone_cluster.yaml @@ -0,0 +1,29 @@ +type: paradedb +mode: standalone +version: + major: "17" + paradedb: "0.14.0" +cluster: + instances: 2 + storage: + size: 256Mi + +backups: + enabled: true + provider: s3 + endpointURL: "https://minio.minio.svc.cluster.local" + endpointCA: + name: kube-root-ca.crt + key: ca.crt + wal: + encryption: "" + data: + encryption: "" + s3: + bucket: "mybucket" + path: "/paradedb/v1" + accessKey: "minio" + secretKey: "minio123" + region: "local" + scheduledBackups: [] + retentionPolicy: "30d" diff --git a/charts/paradedb/test/postgresql-minio-backup-restore/02-data_write-assert.yaml b/charts/paradedb/test/postgresql-minio-backup-restore/02-data_write-assert.yaml new file mode 100644 index 000000000..831f963d9 --- /dev/null +++ b/charts/paradedb/test/postgresql-minio-backup-restore/02-data_write-assert.yaml @@ -0,0 +1,6 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: data-write +status: + succeeded: 1 diff --git a/charts/paradedb/test/postgresql-minio-backup-restore/02-data_write.yaml b/charts/paradedb/test/postgresql-minio-backup-restore/02-data_write.yaml new file mode 100644 index 000000000..34a3d2371 --- /dev/null +++ b/charts/paradedb/test/postgresql-minio-backup-restore/02-data_write.yaml @@ -0,0 +1,23 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: data-write +spec: + template: + spec: + restartPolicy: OnFailure + containers: + - name: data-write + env: + - name: DB_URI + valueFrom: + secretKeyRef: + name: standalone-paradedb-superuser + key: uri + image: alpine:3.19 + command: ['sh', '-c'] + args: + - | + apk --no-cache add postgresql-client + DB_URI=$(echo $DB_URI | sed "s|/\*|/|" ) + psql "$DB_URI" -c "CREATE TABLE mygoodtable (id serial PRIMARY KEY);" diff --git a/charts/paradedb/test/postgresql-minio-backup-restore/03-backup.yaml b/charts/paradedb/test/postgresql-minio-backup-restore/03-backup.yaml new file mode 100644 index 000000000..8fe8c4686 --- /dev/null +++ b/charts/paradedb/test/postgresql-minio-backup-restore/03-backup.yaml @@ -0,0 +1,8 @@ +apiVersion: postgresql.cnpg.io/v1 +kind: Backup +metadata: + name: post-init-backup +spec: + method: barmanObjectStore + cluster: + name: standalone-paradedb diff --git a/charts/paradedb/test/postgresql-minio-backup-restore/03-backup_completed-assert.yaml b/charts/paradedb/test/postgresql-minio-backup-restore/03-backup_completed-assert.yaml new file mode 100644 index 000000000..efffadd46 --- /dev/null +++ b/charts/paradedb/test/postgresql-minio-backup-restore/03-backup_completed-assert.yaml @@ -0,0 +1,10 @@ +apiVersion: postgresql.cnpg.io/v1 +kind: Backup +metadata: + name: post-init-backup +spec: + cluster: + name: standalone-paradedb + method: barmanObjectStore +status: + phase: completed diff --git a/charts/paradedb/test/postgresql-minio-backup-restore/03-backup_running-assert.yaml b/charts/paradedb/test/postgresql-minio-backup-restore/03-backup_running-assert.yaml new file mode 100644 index 000000000..ab709ada9 --- /dev/null +++ b/charts/paradedb/test/postgresql-minio-backup-restore/03-backup_running-assert.yaml @@ -0,0 +1,10 @@ +apiVersion: postgresql.cnpg.io/v1 +kind: Backup +metadata: + name: post-init-backup +spec: + cluster: + name: standalone-paradedb + method: barmanObjectStore +status: + phase: running diff --git a/charts/paradedb/test/postgresql-minio-backup-restore/03-checkpoint.yaml b/charts/paradedb/test/postgresql-minio-backup-restore/03-checkpoint.yaml new file mode 100644 index 000000000..680ba1b2d --- /dev/null +++ b/charts/paradedb/test/postgresql-minio-backup-restore/03-checkpoint.yaml @@ -0,0 +1,27 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: backup-checkpoint +spec: + template: + spec: + restartPolicy: OnFailure + containers: + - name: create-checkpoint + env: + - name: DB_URI + valueFrom: + secretKeyRef: + name: standalone-paradedb-superuser + key: uri + image: alpine:3.19 + command: ['sh', '-c'] + args: + - | + apk --no-cache add postgresql-client + DB_URI=$(echo $DB_URI | sed "s|/\*|/|" ) + END_TIME=$(( $(date +%s) + 30 )) + while [ $(date +%s) -lt $END_TIME ]; do + psql "$DB_URI" -c "SELECT pg_switch_wal();CHECKPOINT;" + sleep 5 + done diff --git a/charts/paradedb/test/postgresql-minio-backup-restore/04-post_backup_data_write-assert.yaml b/charts/paradedb/test/postgresql-minio-backup-restore/04-post_backup_data_write-assert.yaml new file mode 100644 index 000000000..b3c0ba678 --- /dev/null +++ b/charts/paradedb/test/postgresql-minio-backup-restore/04-post_backup_data_write-assert.yaml @@ -0,0 +1,6 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: paradedb-enterprise-index-test +status: + succeeded: 1 diff --git a/charts/paradedb/test/postgresql-minio-backup-restore/04-post_backup_data_write.yaml b/charts/paradedb/test/postgresql-minio-backup-restore/04-post_backup_data_write.yaml new file mode 100644 index 000000000..50c7ab6a2 --- /dev/null +++ b/charts/paradedb/test/postgresql-minio-backup-restore/04-post_backup_data_write.yaml @@ -0,0 +1,57 @@ +apiVersion: v1 +kind: ServiceAccount +metadata: + name: configmap-creator-sa +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + name: configmap-creator +rules: +- apiGroups: [""] + resources: ["configmaps"] + verbs: ["create"] +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: configmap-creator-binding +subjects: +- kind: ServiceAccount + name: configmap-creator-sa +roleRef: + kind: Role + name: configmap-creator + apiGroup: rbac.authorization.k8s.io +--- +apiVersion: batch/v1 +kind: Job +metadata: + name: data-write-post-backup +spec: + template: + spec: + serviceAccountName: configmap-creator-sa + restartPolicy: OnFailure + containers: + - name: data-write + env: + - name: DB_URI + valueFrom: + secretKeyRef: + name: standalone-paradedb-superuser + key: uri + - name: NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + image: alpine:3.19 + command: ['sh', '-c'] + args: + - | + apk --no-cache add postgresql-client kubectl coreutils + DB_URI=$(echo $DB_URI | sed "s|/\*|/|" ) + DATE_NO_BAD_TABLE=$(date --rfc-3339=ns) + sleep 30 + psql "$DB_URI" -c "CREATE TABLE mybadtable (id serial PRIMARY KEY);" + kubectl create configmap date-no-bad-table --from-literal=date="$DATE_NO_BAD_TABLE" diff --git a/charts/paradedb/test/postgresql-minio-backup-restore/05-recovery_backup_cluster-assert.yaml b/charts/paradedb/test/postgresql-minio-backup-restore/05-recovery_backup_cluster-assert.yaml new file mode 100644 index 000000000..511de6837 --- /dev/null +++ b/charts/paradedb/test/postgresql-minio-backup-restore/05-recovery_backup_cluster-assert.yaml @@ -0,0 +1,6 @@ +apiVersion: postgresql.cnpg.io/v1 +kind: Cluster +metadata: + name: pg-basebackup-paradedb +status: + readyInstances: 2 diff --git a/charts/paradedb/test/postgresql-minio-backup-restore/05-recovery_backup_cluster.yaml b/charts/paradedb/test/postgresql-minio-backup-restore/05-recovery_backup_cluster.yaml new file mode 100644 index 000000000..c2731b3bf --- /dev/null +++ b/charts/paradedb/test/postgresql-minio-backup-restore/05-recovery_backup_cluster.yaml @@ -0,0 +1,48 @@ +type: postgresql +mode: recovery + +cluster: + instances: 2 + storage: + size: 256Mi + +recovery: + method: backup + backupName: "post-init-backup" + provider: s3 + endpointURL: "https://minio.minio.svc.cluster.local" + endpointCA: + name: kube-root-ca.crt + key: ca.crt + wal: + encryption: "" + data: + encryption: "" + s3: + bucket: "mybucket" + path: "/postgresql-minio-backup-restore/v1" + accessKey: "minio" + secretKey: "minio123" + region: "local" + scheduledBackups: [] + retentionPolicy: "30d" + +backups: + enabled: true + provider: s3 + endpointURL: "https://minio.minio.svc.cluster.local" + endpointCA: + name: kube-root-ca.crt + key: ca.crt + wal: + encryption: "" + data: + encryption: "" + s3: + bucket: "mybucket" + path: "/postgresql-minio-backup-restore/v2" + accessKey: "minio" + secretKey: "minio123" + region: "local" + scheduledBackups: [] + retentionPolicy: "30d" diff --git a/charts/paradedb/test/postgresql-minio-backup-restore/06-data_test-assert.yaml b/charts/paradedb/test/postgresql-minio-backup-restore/06-data_test-assert.yaml new file mode 100644 index 000000000..b29534fcc --- /dev/null +++ b/charts/paradedb/test/postgresql-minio-backup-restore/06-data_test-assert.yaml @@ -0,0 +1,6 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: data-test-schemaonly +status: + succeeded: 1 diff --git a/charts/paradedb/test/postgresql-minio-backup-restore/06-data_test.yaml b/charts/paradedb/test/postgresql-minio-backup-restore/06-data_test.yaml new file mode 100644 index 000000000..5e1f05f6e --- /dev/null +++ b/charts/paradedb/test/postgresql-minio-backup-restore/06-data_test.yaml @@ -0,0 +1,24 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: data-test-schemaonly +spec: + template: + spec: + restartPolicy: OnFailure + containers: + - name: data-test + env: + - name: DB_URI + valueFrom: + secretKeyRef: + name: import-schemaonly-paradedb-superuser + key: uri + image: alpine:3.19 + command: ['sh', '-c'] + args: + - | + apk --no-cache add postgresql-client + DB_URI=$(echo $DB_URI | sed "s|/\*|/|" ) + test "$(psql "${DB_URI}mygooddb" -t -c 'SELECT EXISTS (SELECT FROM information_schema.tables WHERE table_name = $$mygoodtable$$)' --csv -q 2>/dev/null)" = "t" + test "$(psql "${DB_URI}mygooddb" -t -c 'SELECT EXISTS (SELECT FROM mygoodtable WHERE id = 314159265)' --csv -q 2>/dev/null)" = "f" diff --git a/charts/paradedb/test/postgresql-minio-backup-restore/07-recovery_object_store_cluster-assert.yaml b/charts/paradedb/test/postgresql-minio-backup-restore/07-recovery_object_store_cluster-assert.yaml new file mode 100644 index 000000000..d9895f17c --- /dev/null +++ b/charts/paradedb/test/postgresql-minio-backup-restore/07-recovery_object_store_cluster-assert.yaml @@ -0,0 +1,6 @@ +apiVersion: postgresql.cnpg.io/v1 +kind: Cluster +metadata: + name: recovery-object-store-paradedb +status: + readyInstances: 2 diff --git a/charts/paradedb/test/postgresql-minio-backup-restore/07-recovery_object_store_cluster.yaml b/charts/paradedb/test/postgresql-minio-backup-restore/07-recovery_object_store_cluster.yaml new file mode 100644 index 000000000..07f5dbc53 --- /dev/null +++ b/charts/paradedb/test/postgresql-minio-backup-restore/07-recovery_object_store_cluster.yaml @@ -0,0 +1,48 @@ +type: postgresql +mode: recovery + +cluster: + instances: 2 + storage: + size: 256Mi + +recovery: + method: object_store + clusterName: "standalone-paradedb" + provider: s3 + endpointURL: "https://minio.minio.svc.cluster.local" + endpointCA: + name: kube-root-ca.crt + key: ca.crt + wal: + encryption: "" + data: + encryption: "" + s3: + bucket: "mybucket" + path: "/postgresql-minio-backup-restore/v1" + accessKey: "minio" + secretKey: "minio123" + region: "local" + scheduledBackups: [] + retentionPolicy: "30d" + +backups: + enabled: true + provider: s3 + endpointURL: "https://minio.minio.svc.cluster.local" + endpointCA: + name: kube-root-ca.crt + key: ca.crt + wal: + encryption: "" + data: + encryption: "" + s3: + bucket: "mybucket" + path: "/postgresql-minio-backup-restore/v2" + accessKey: "minio" + secretKey: "minio123" + region: "local" + scheduledBackups: [] + retentionPolicy: "30d" diff --git a/charts/paradedb/test/postgresql-minio-backup-restore/08-data_test-assert.yaml b/charts/paradedb/test/postgresql-minio-backup-restore/08-data_test-assert.yaml new file mode 100644 index 000000000..36eb4ff81 --- /dev/null +++ b/charts/paradedb/test/postgresql-minio-backup-restore/08-data_test-assert.yaml @@ -0,0 +1,6 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: data-test-object-store +status: + succeeded: 1 diff --git a/charts/paradedb/test/postgresql-minio-backup-restore/08-data_test.yaml b/charts/paradedb/test/postgresql-minio-backup-restore/08-data_test.yaml new file mode 100644 index 000000000..716f6e4b8 --- /dev/null +++ b/charts/paradedb/test/postgresql-minio-backup-restore/08-data_test.yaml @@ -0,0 +1,24 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: data-test +spec: + template: + spec: + restartPolicy: OnFailure + containers: + - name: data-test + env: + - name: DB_URI + valueFrom: + secretKeyRef: + name: import-paradedb-superuser + key: uri + image: alpine:3.19 + command: ['sh', '-c'] + args: + - | + apk --no-cache add postgresql-client + DB_URI=$(echo $DB_URI | sed "s|/\*|/|" ) + test "$(psql "${DB_URI}mygooddb" -t -c 'SELECT EXISTS (SELECT FROM information_schema.tables WHERE table_name = $$mygoodtable$$)' --csv -q 2>/dev/null)" = "t" + test "$(psql "${DB_URI}mygooddb" -t -c 'SELECT EXISTS (SELECT FROM mygoodtable WHERE id = 314159265)' --csv -q 2>/dev/null)" = "t" diff --git a/charts/paradedb/test/postgresql-minio-backup-restore/09-recovery_backup_pitr_cluster-assert.yaml b/charts/paradedb/test/postgresql-minio-backup-restore/09-recovery_backup_pitr_cluster-assert.yaml new file mode 100644 index 000000000..640223c16 --- /dev/null +++ b/charts/paradedb/test/postgresql-minio-backup-restore/09-recovery_backup_pitr_cluster-assert.yaml @@ -0,0 +1,6 @@ +apiVersion: postgresql.cnpg.io/v1 +kind: Cluster +metadata: + name: recovery-backup-pitr-paradedb +status: + readyInstances: 2 diff --git a/charts/paradedb/test/postgresql-minio-backup-restore/09-recovery_backup_pitr_cluster.yaml b/charts/paradedb/test/postgresql-minio-backup-restore/09-recovery_backup_pitr_cluster.yaml new file mode 100644 index 000000000..c2731b3bf --- /dev/null +++ b/charts/paradedb/test/postgresql-minio-backup-restore/09-recovery_backup_pitr_cluster.yaml @@ -0,0 +1,48 @@ +type: postgresql +mode: recovery + +cluster: + instances: 2 + storage: + size: 256Mi + +recovery: + method: backup + backupName: "post-init-backup" + provider: s3 + endpointURL: "https://minio.minio.svc.cluster.local" + endpointCA: + name: kube-root-ca.crt + key: ca.crt + wal: + encryption: "" + data: + encryption: "" + s3: + bucket: "mybucket" + path: "/postgresql-minio-backup-restore/v1" + accessKey: "minio" + secretKey: "minio123" + region: "local" + scheduledBackups: [] + retentionPolicy: "30d" + +backups: + enabled: true + provider: s3 + endpointURL: "https://minio.minio.svc.cluster.local" + endpointCA: + name: kube-root-ca.crt + key: ca.crt + wal: + encryption: "" + data: + encryption: "" + s3: + bucket: "mybucket" + path: "/postgresql-minio-backup-restore/v2" + accessKey: "minio" + secretKey: "minio123" + region: "local" + scheduledBackups: [] + retentionPolicy: "30d" diff --git a/charts/paradedb/test/postgresql-minio-backup-restore/10-data_test-assert.yaml b/charts/paradedb/test/postgresql-minio-backup-restore/10-data_test-assert.yaml new file mode 100644 index 000000000..34cf73f0c --- /dev/null +++ b/charts/paradedb/test/postgresql-minio-backup-restore/10-data_test-assert.yaml @@ -0,0 +1,6 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: paradedb-enterprise-test +status: + succeeded: 1 diff --git a/charts/paradedb/test/postgresql-minio-backup-restore/10-data_test.yaml b/charts/paradedb/test/postgresql-minio-backup-restore/10-data_test.yaml new file mode 100644 index 000000000..412852502 --- /dev/null +++ b/charts/paradedb/test/postgresql-minio-backup-restore/10-data_test.yaml @@ -0,0 +1,27 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: data-test-backup-pitr +spec: + template: + spec: + restartPolicy: OnFailure + containers: + - name: data-test + env: + - name: DB_URI + valueFrom: + secretKeyRef: + name: recovery-backup-pitr-paradedb-superuser + key: uri + image: alpine:3.19 + command: ['sh', '-c'] + args: + - | + apk --no-cache add postgresql-client + DB_URI=$(echo $DB_URI | sed "s|/\*|/|" ) + set -e + test "$(psql $DB_URI -t -c 'SELECT EXISTS (SELECT FROM information_schema.tables WHERE table_name = $$mygoodtable$$)' --csv -q 2>/dev/null)" = "t" + echo "Good table exists" + test "$(psql $DB_URI -t -c 'SELECT EXISTS (SELECT FROM information_schema.tables WHERE table_name = $$mybadtable$$)' --csv -q 2>/dev/null)" = "f" + echo "Bad table does not exist" diff --git a/charts/paradedb/test/postgresql-minio-backup-restore/chainsaw-test.yaml b/charts/paradedb/test/postgresql-minio-backup-restore/chainsaw-test.yaml new file mode 100644 index 000000000..79a7d2d76 --- /dev/null +++ b/charts/paradedb/test/postgresql-minio-backup-restore/chainsaw-test.yaml @@ -0,0 +1,148 @@ +## +# This test sets up a CNPG cluster with MinIO backups and then restores the cluster from the backup using backup, +# object store, and object store with PITR recovery. +apiVersion: chainsaw.kyverno.io/v1alpha1 +kind: Test +metadata: + name: postgresql-minio-backup-restore +spec: + timeouts: + apply: 1s + assert: 2m + cleanup: 1m + steps: + - name: Clear the MinIO bucket + try: + - apply: + file: ./00-minio_cleanup.yaml + - assert: + file: ./00-minio_cleanup-assert.yaml + catch: + - describe: + apiVersion: batch/v1 + kind: Job + - podLogs: + selector: batch.kubernetes.io/job-name=minio_cleanup + - name: Install the standalone cluster + try: + - script: + content: | + kubectl -n $NAMESPACE create secret generic kube-root-ca.crt --from-literal=ca.crt="$(kubectl -n kube-system get configmaps kube-root-ca.crt -o jsonpath='{.data.ca\.crt}')" --dry-run=client -o yaml | kubectl apply -f - + helm upgrade \ + --install \ + --namespace $NAMESPACE \ + --values ./01-standalone_cluster.yaml \ + --wait \ + standalone ../../ + - assert: + file: 01-standalone_cluster-assert.yaml + catch: + - describe: + apiVersion: postgresql.cnpg.io/v1 + kind: Cluster + - name: Write some data to the cluster + try: + - apply: + file: ./02-data_write.yaml + - assert: + file: ./02-data_write-assert.yaml + catch: + - describe: + apiVersion: batch/v1 + kind: Job + - podLogs: + selector: batch.kubernetes.io/job-name=data-write + - name: Create a backup + try: + - apply: + file: ./03-backup.yaml + - assert: + file: ./03-backup_running-assert.yaml + - apply: + file: ./03-checkpoint.yaml + - assert: + file: ./03-backup_completed-assert.yaml + - name: Write more data to the database after the backup + try: + - apply: + file: ./04-post_backup_data_write.yaml + - assert: + file: ./04-post_backup_data_write-assert.yaml + timeouts: + apply: 1s + assert: 10m + catch: + - describe: + apiVersion: postgresql.cnpg.io/v1 + kind: Backup + - name: Create a recovery cluster from backup + try: + - script: + content: | + helm upgrade \ + --install \ + --namespace $NAMESPACE \ + --values ./05-recovery_backup_cluster.yaml \ + --wait \ + recovery-backup ../../ + - assert: + file: ./05-recovery_backup_cluster-assert.yaml + - name: Verify the data on the backup recovery cluster exists + try: + - apply: + file: 06-data_test.yaml + - assert: + file: 06-data_test-assert.yaml + - name: Create a recovery cluster from object store + try: + - script: + content: | + helm upgrade \ + --install \ + --namespace $NAMESPACE \ + --values ./07-recovery_object_store_cluster.yaml \ + --wait \ + recovery-object-store ../../ + - assert: + file: ./07-recovery_object_store_cluster-assert.yaml + - name: Verify the data on the object store recovery cluster exists + try: + - apply: + file: 08-data_test.yaml + - assert: + file: 08-data_test-assert.yaml + - name: Create a recovery cluster from backup with a PITR target + try: + - script: + content: | + DATE_NO_BAD_TABLE=$(kubectl -n $NAMESPACE get configmap date-no-bad-table -o 'jsonpath={.data.date}') + helm upgrade \ + --install \ + --namespace $NAMESPACE \ + --values ./09-recovery_backup_pitr_cluster.yaml \ + --set recovery.pitrTarget.time="$DATE_NO_BAD_TABLE" \ + --wait \ + recovery-backup-pitr ../../ + - assert: + file: ./09-recovery_backup_pitr_cluster-assert.yaml + - name: Verify the pre-backup data on the recovery cluster exists but not the post-backup data + try: + - apply: + file: 10-data_test.yaml + - assert: + file: 10-data_test-assert.yaml + catch: + - describe: + apiVersion: batch/v1 + kind: Job + selector: batch.kubernetes.io/job-name=data-test-backup-pitr + - podLogs: + selector: batch.kubernetes.io/job-name=data-test-backup-pitr + - name: Cleanup + try: + - script: + content: | + helm uninstall --namespace $NAMESPACE standalone + helm uninstall --namespace $NAMESPACE recovery-backup + helm uninstall --namespace $NAMESPACE recovery-object-store + helm uninstall --namespace $NAMESPACE recovery-backup-pitr diff --git a/charts/paradedb/test/scheduledbackups/00-minio_cleanup-assert.yaml b/charts/paradedb/test/scheduledbackups/00-minio_cleanup-assert.yaml new file mode 100644 index 000000000..678c11c9b --- /dev/null +++ b/charts/paradedb/test/scheduledbackups/00-minio_cleanup-assert.yaml @@ -0,0 +1,6 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: paradedb-test +status: + succeeded: 1 diff --git a/charts/paradedb/test/scheduledbackups/00-minio_cleanup.yaml b/charts/paradedb/test/scheduledbackups/00-minio_cleanup.yaml new file mode 100644 index 000000000..90151a964 --- /dev/null +++ b/charts/paradedb/test/scheduledbackups/00-minio_cleanup.yaml @@ -0,0 +1,16 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: minio-cleanup +spec: + template: + spec: + restartPolicy: OnFailure + containers: + - name: minio-cleanup + image: minio/mc + command: ['sh', '-c'] + args: + - | + mc alias set myminio https://minio.minio.svc.cluster.local minio minio123 + mc rm --recursive --force myminio/mybucket/scheduledbackups diff --git a/charts/paradedb/test/scheduledbackups/01-scheduledbackups_cluster-assert.yaml b/charts/paradedb/test/scheduledbackups/01-scheduledbackups_cluster-assert.yaml new file mode 100644 index 000000000..a3af1a25b --- /dev/null +++ b/charts/paradedb/test/scheduledbackups/01-scheduledbackups_cluster-assert.yaml @@ -0,0 +1,37 @@ +apiVersion: postgresql.cnpg.io/v1 +kind: Cluster +metadata: + name: scheduledbackups-cluster +status: + readyInstances: 1 +--- +apiVersion: postgresql.cnpg.io/v1 +kind: ScheduledBackup +metadata: + name: scheduledbackups-cluster-daily-backup +spec: + immediate: true + schedule: "0 0 0 * * *" + method: barmanObjectStore + backupOwnerReference: self + cluster: + name: scheduledbackups-cluster +--- +apiVersion: postgresql.cnpg.io/v1 +kind: ScheduledBackup +metadata: + name: scheduledbackups-cluster-weekly-backup +spec: + immediate: true + schedule: "0 0 0 * * 1" + method: barmanObjectStore + backupOwnerReference: self + cluster: + name: scheduledbackups-cluster +--- +apiVersion: postgresql.cnpg.io/v1 +kind: Backup +spec: + method: barmanObjectStore + cluster: + name: scheduledbackups-cluster diff --git a/charts/paradedb/test/scheduledbackups/01-scheduledbackups_cluster.yaml b/charts/paradedb/test/scheduledbackups/01-scheduledbackups_cluster.yaml new file mode 100644 index 000000000..94f6015c4 --- /dev/null +++ b/charts/paradedb/test/scheduledbackups/01-scheduledbackups_cluster.yaml @@ -0,0 +1,35 @@ +type: postgresql +mode: standalone + +cluster: + instances: 1 + storage: + size: 256Mi + +backups: + enabled: true + provider: s3 + endpointURL: "https://minio.minio.svc.cluster.local" + endpointCA: + name: kube-root-ca.crt + key: ca.crt + wal: + encryption: "" + data: + encryption: "" + s3: + bucket: "mybucket" + path: "/scheduledbackups/v1" + accessKey: "minio" + secretKey: "minio123" + region: "local" + retentionPolicy: "30d" + scheduledBackups: + - name: daily-backup + schedule: "0 0 0 * * *" + backupOwnerReference: self + method: barmanObjectStore + - name: weekly-backup + schedule: "0 0 0 * * 1" + backupOwnerReference: self + method: barmanObjectStore diff --git a/charts/paradedb/test/scheduledbackups/chainsaw-test.yaml b/charts/paradedb/test/scheduledbackups/chainsaw-test.yaml new file mode 100644 index 000000000..c1409ce46 --- /dev/null +++ b/charts/paradedb/test/scheduledbackups/chainsaw-test.yaml @@ -0,0 +1,27 @@ +apiVersion: chainsaw.kyverno.io/v1alpha1 +kind: Test +metadata: + name: scheduledbackups +spec: + timeouts: + apply: 1s + assert: 1m + cleanup: 1m + steps: + - name: Install a cluster with ScheduledBackups + try: + - script: + content: | + helm upgrade \ + --install \ + --namespace $NAMESPACE \ + --values ./01-scheduledbackups_cluster.yaml \ + --wait \ + scheduledbackups ../../ + - assert: + file: ./01-scheduledbackups_cluster-assert.yaml + - name: Cleanup + try: + - script: + content: | + helm uninstall --namespace $NAMESPACE scheduledbackups diff --git a/charts/paradedb/values.yaml b/charts/paradedb/values.yaml index ad82b805a..e23a3ddd1 100644 --- a/charts/paradedb/values.yaml +++ b/charts/paradedb/values.yaml @@ -299,7 +299,9 @@ cluster: postgresql: # -- PostgreSQL configuration options (postgresql.conf) - parameters: {} + parameters: + # Required by pg_cron + cron.database_name: postgres # max_connections: 300 # -- Quorum-based Synchronous Replication synchronous: {}