-
Notifications
You must be signed in to change notification settings - Fork 33
feat: add timescaledb-oss container image
#73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 16 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
8d35103
feat: added timescaledb
shusaan 77d1c79
update metadata.hcl
shusaan e91602f
Implement TimescaleDB extension following scaffolding procedure
shusaan a4ff288
chore: initial review
gbartolini 1766a0d
chore: add @shusaan as CODEOWNER
gbartolini 4cbcd21
chore: renamed the image name as `timescaledb-oss`
gbartolini b34c315
chore(timescaledb-oss): update package source and versions
shusaan 17f3bd0
chore: add licenses annotation
gbartolini f57eaa2
chore: review tests and docs
NiccoloFei a12a0a4
chore: add missing variables in metadata
gbartolini 688fe09
fix: metadata.hcl syntax and missing renovate lines
NiccoloFei 66d06db
test: make smoke-test idempotent
NiccoloFei 023da2c
chore: bump to v2.26.1
NiccoloFei 7ae3fd9
test: use new create_hypertable() api style
NiccoloFei 6b5b0aa
Merge branch 'main' into timescaledb
gbartolini e1d40db
chore: update to version 2.26.4
gbartolini 7b88171
chore: apply suggestions from code review
gbartolini f0bd8cd
chore: update to version 2.27.1
gbartolini f4df5a4
Merge branch 'main' into timescaledb
NiccoloFei 747326f
Merge branch 'main' into timescaledb
gbartolini File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| # SPDX-FileCopyrightText: Copyright © contributors to CloudNativePG, established as CloudNativePG a Series of LF Projects, LLC. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| ARG BASE=ghcr.io/cloudnative-pg/postgresql:18-minimal-trixie | ||
| FROM $BASE AS builder | ||
|
|
||
| ARG PG_MAJOR | ||
| ARG EXT_VERSION | ||
|
|
||
| USER 0 | ||
|
|
||
| RUN apt-get update && \ | ||
| apt-get install -y --no-install-recommends "postgresql-${PG_MAJOR}-timescaledb=${EXT_VERSION}" | ||
|
|
||
| FROM scratch | ||
| ARG PG_MAJOR | ||
|
|
||
| # Licenses | ||
| COPY --from=builder /usr/share/doc/postgresql-${PG_MAJOR}-timescaledb/copyright /licenses/postgresql-${PG_MAJOR}-timescaledb/ | ||
|
|
||
| # Libraries | ||
| COPY --from=builder /usr/lib/postgresql/${PG_MAJOR}/lib/timescaledb* /lib/ | ||
|
|
||
| # Share | ||
| COPY --from=builder /usr/share/postgresql/${PG_MAJOR}/extension/timescaledb* /share/extension/ | ||
|
|
||
| USER 65532:65532 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,125 @@ | ||
| # `TimescaleDB` (Apache 2.0 Edition) | ||
| <!-- | ||
| SPDX-FileCopyrightText: Copyright © contributors to CloudNativePG, established as CloudNativePG a Series of LF Projects, LLC. | ||
| SPDX-License-Identifier: Apache-2.0 | ||
| --> | ||
|
|
||
| [TimescaleDB](https://github.com/timescale/timescaledb) is an open-source | ||
| time-series database built on PostgreSQL. It enables fast analytics, efficient | ||
| storage, and powerful querying for time-series workloads. | ||
|
|
||
| > [!NOTE] | ||
| > This image contains only the Apache 2.0 licensed components of TimescaleDB | ||
| > (known as "TimescaleDB Apache-2 Edition") to ensure CNCF licensing | ||
| > compliance. Advanced features requiring the Timescale License (TSL) are not | ||
| > included. | ||
|
|
||
| This image provides a convenient way to deploy and manage the open-source core | ||
| of TimescaleDB with [CloudNativePG](https://cloudnative-pg.io/). | ||
|
|
||
| ## Usage | ||
|
|
||
| ### 1. Add the TimescaleDB extension image to your Cluster | ||
|
|
||
| Define the `timescaledb` extension under the `postgresql.extensions` section of | ||
| your `Cluster` resource. For example: | ||
|
|
||
| ```yaml | ||
| apiVersion: postgresql.cnpg.io/v1 | ||
| kind: Cluster | ||
| metadata: | ||
| name: cluster-timescaledb | ||
| spec: | ||
| imageName: ghcr.io/cloudnative-pg/postgresql:18-minimal-trixie | ||
| instances: 1 | ||
|
|
||
| storage: | ||
| size: 1Gi | ||
|
|
||
| postgresql: | ||
| shared_preload_libraries: | ||
| - "timescaledb" | ||
| parameters: | ||
| timescaledb.telemetry_level: 'off' | ||
| max_locks_per_transaction: '128' | ||
|
|
||
| extensions: | ||
| - name: timescaledb | ||
| image: | ||
| # renovate: suite=trixie-pgdg depName=postgresql-18-timescaledb | ||
| reference: ghcr.io/cloudnative-pg/timescaledb-oss:2.26.4-18-trixie | ||
| ``` | ||
|
|
||
| ### 2. Enable the extension in a database | ||
|
|
||
| You can install `timescaledb` in a specific database by creating or updating a | ||
| `Database` resource. For example, to enable it in the `app` database: | ||
|
|
||
| ```yaml | ||
| apiVersion: postgresql.cnpg.io/v1 | ||
| kind: Database | ||
| metadata: | ||
| name: cluster-timescaledb-app | ||
| spec: | ||
| name: app | ||
| owner: app | ||
| cluster: | ||
| name: cluster-timescaledb | ||
| extensions: | ||
| - name: timescaledb | ||
| # renovate: suite=trixie-pgdg depName=postgresql-18-timescaledb extractVersion=^(?<version>\d+\.\d+\.\d+) | ||
| version: '2.26.4' | ||
| ``` | ||
|
|
||
| ### 3. Verify installation | ||
|
|
||
| Once the database is ready, connect to it with `psql` and run: | ||
|
|
||
| ```sql | ||
| \dx | ||
| ``` | ||
|
|
||
| You should see `timescaledb` listed among the installed extensions. | ||
|
|
||
| ### 4. Create a hypertable | ||
|
|
||
| To use TimescaleDB's time-series features, create a hypertable: | ||
|
|
||
| ```sql | ||
| -- Create a regular table | ||
| CREATE TABLE sensor_data ( | ||
| time TIMESTAMPTZ NOT NULL, | ||
| sensor_id INTEGER, | ||
| temperature DOUBLE PRECISION, | ||
| humidity DOUBLE PRECISION | ||
| ); | ||
|
|
||
| -- Convert it to a hypertable | ||
| SELECT create_hypertable('sensor_data', 'time'); | ||
|
|
||
| -- Insert some data | ||
| INSERT INTO sensor_data VALUES (NOW(), 1, 21.5, 45.0); | ||
| ``` | ||
|
|
||
| ## Maintainers | ||
|
|
||
| This container image is maintained by @shuusan. | ||
|
|
||
| ## License | ||
|
|
||
| This image contains only the Apache 2.0 licensed components of TimescaleDB. | ||
| Features requiring the Timescale License (TSL) are not included to ensure | ||
| compliance with CNCF licensing requirements. | ||
|
|
||
| All relevant license and copyright information for the `timescaledb-oss` extension | ||
| and its dependencies are bundled within the image at: | ||
|
|
||
| ```text | ||
| /licenses/ | ||
| ``` | ||
|
|
||
| By using this image, you agree to comply with the terms of the licenses | ||
| contained therein. | ||
|
|
||
| For further information, refer to | ||
| [Software Licensing: Timescale License (TSL)](https://www.tigerdata.com/legal/licenses). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| # SPDX-FileCopyrightText: Copyright © contributors to CloudNativePG, established as CloudNativePG a Series of LF Projects, LLC. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| metadata = { | ||
| name = "timescaledb-oss" | ||
| sql_name = "timescaledb" | ||
| image_name = "timescaledb-oss" | ||
| licenses = ["Apache-2.0"] | ||
| shared_preload_libraries = ["timescaledb"] | ||
| postgresql_parameters = {} | ||
| extension_control_path = [] | ||
| dynamic_library_path = [] | ||
| ld_library_path = [] | ||
| bin_path = [] | ||
| env = {} | ||
| auto_update_os_libs = false | ||
| required_extensions = [] | ||
| create_extension = true | ||
|
|
||
| versions = { | ||
| trixie = { | ||
| "18" = { | ||
| // renovate: suite=trixie-pgdg depName=postgresql-18-timescaledb | ||
| package = "2.26.4+dfsg-1.pgdg13+1" | ||
|
gbartolini marked this conversation as resolved.
Outdated
|
||
| // renovate: suite=trixie-pgdg depName=postgresql-18-timescaledb extractVersion=^(?<version>\d+\.\d+\.\d+) | ||
| sql = "2.26.4" | ||
| } | ||
| } | ||
| bookworm = { | ||
| "18" = { | ||
| // renovate: suite=bookworm-pgdg depName=postgresql-18-timescaledb | ||
| package = "2.26.4+dfsg-1.pgdg12+1" | ||
| // renovate: suite=bookworm-pgdg depName=postgresql-18-timescaledb extractVersion=^(?<version>\d+\.\d+\.\d+) | ||
| sql = "2.26.4" | ||
| } | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| apiVersion: chainsaw.kyverno.io/v1alpha1 | ||
| kind: Test | ||
| metadata: | ||
| name: verify-timescaledb-extension | ||
| spec: | ||
| timeouts: | ||
| apply: 5s | ||
| assert: 3m | ||
| delete: 30s | ||
| description: Verify TimescaleDB extension is properly installed | ||
| steps: | ||
| - name: Create a Cluster with the extension | ||
| try: | ||
| - apply: | ||
| file: cluster.yaml | ||
| - apply: | ||
| file: database.yaml | ||
| - assert: | ||
| file: cluster-assert.yaml | ||
| - assert: | ||
| file: database-assert.yaml | ||
|
|
||
| - name: Verify extension is installed | ||
| try: | ||
| - apply: | ||
| file: check-extension.yaml | ||
| - assert: | ||
| file: check-extension-assert.yaml |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| apiVersion: batch/v1 | ||
| kind: Job | ||
| metadata: | ||
| name: extension-installed | ||
| status: | ||
| succeeded: 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| apiVersion: batch/v1 | ||
| kind: Job | ||
| metadata: | ||
| name: extension-installed | ||
| spec: | ||
| template: | ||
| spec: | ||
| restartPolicy: OnFailure | ||
| containers: | ||
| - name: data-test | ||
| env: | ||
| - name: EXT_VERSION | ||
| value: ($values.version) | ||
| - name: DB_URI | ||
| valueFrom: | ||
| secretKeyRef: | ||
| name: (join('-', [$values.name, 'app'])) | ||
| key: uri | ||
| image: alpine/psql:latest | ||
|
gbartolini marked this conversation as resolved.
Outdated
|
||
| command: ['sh', '-c'] | ||
| args: | ||
| - | | ||
| set -e | ||
| DB_URI=$(echo $DB_URI | sed "s|/\*|/|") | ||
| test "$(psql "$DB_URI" -tAc "SELECT EXISTS (SELECT FROM pg_catalog.pg_extension WHERE extname = 'timescaledb' AND extversion = '${EXT_VERSION}')" -q)" = "t" | ||
| psql "$DB_URI" -c "DROP TABLE IF EXISTS test_hypertable CASCADE;" | ||
| psql "$DB_URI" -c "CREATE TABLE test_hypertable (time TIMESTAMPTZ NOT NULL, value DOUBLE PRECISION);" | ||
| psql "$DB_URI" -c "SELECT create_hypertable('test_hypertable', by_range('time'));" | ||
| psql "$DB_URI" -c "INSERT INTO test_hypertable VALUES (NOW(), 1.0);" | ||
| test "$(psql "$DB_URI" -tAc "SELECT COUNT(*) FROM test_hypertable" -q)" = "1" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| apiVersion: postgresql.cnpg.io/v1 | ||
| kind: Cluster | ||
| metadata: | ||
| name: ($values.name) | ||
| status: | ||
| readyInstances: 1 | ||
| phase: Cluster in healthy state | ||
| image: ($values.pg_image) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| apiVersion: postgresql.cnpg.io/v1 | ||
| kind: Cluster | ||
| metadata: | ||
| name: ($values.name) | ||
| spec: | ||
| imageName: ($values.pg_image) | ||
| instances: 1 | ||
|
|
||
| storage: | ||
| size: 1Gi | ||
|
|
||
| postgresql: | ||
| parameters: | ||
| timescaledb.telemetry_level: 'off' | ||
| shared_preload_libraries: ($values.shared_preload_libraries) | ||
| extensions: ($values.extensions) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| apiVersion: postgresql.cnpg.io/v1 | ||
| kind: Database | ||
| metadata: | ||
| name: (join('-', [$values.name, 'app'])) | ||
| status: ($values.database_assert_status) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| apiVersion: postgresql.cnpg.io/v1 | ||
| kind: Database | ||
| metadata: | ||
| name: (join('-', [$values.name, 'app'])) | ||
| spec: | ||
| name: app | ||
| owner: app | ||
| cluster: | ||
| name: ($values.name) | ||
| extensions: ($values.database_config.extensions_spec) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.