Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Implement TimescaleDB extension following scaffolding procedure
Includes smoke tests for hypertable functionality and uses Apache 2.0-only packages from TimescaleDB repository

Signed-off-by: Husn E Rabbi <shussan@gmail.com>
  • Loading branch information
shusaan authored and NiccoloFei committed Apr 23, 2026
commit dfbd5725c5cf8dd4c28a10d10345b327b0341bfd
3 changes: 2 additions & 1 deletion timescaledb/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# 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
Expand All @@ -15,7 +17,6 @@ RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends \
timescaledb-2-oss-postgresql-${PG_MAJOR}=${EXT_VERSION}*

######################################################################
# Final SCRATCH image
######################################################################
Expand Down
43 changes: 39 additions & 4 deletions timescaledb/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# TimescaleDB (Apache 2.0 Edition) with CloudNativePG
# TimescaleDB (Apache 2.0 Edition)

[TimescaleDB](https://github.com/timescale/timescaledb) is the leading open-source time-series database, built on PostgreSQL. It enables fast analytics, efficient storage, and powerful querying for time-series workloads.
[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 to ensure CNCF licensing compliance. Advanced features requiring the Timescale License (TSL) are not included.

Expand All @@ -9,7 +9,7 @@ This image provides a convenient way to deploy and manage the open-source core o

## Usage

### 1. Add the timescaledb extension image to your Cluster
### 1. Add the TimescaleDB extension image to your Cluster

Define the `timescaledb` extension under the `postgresql.extensions` section of
your `Cluster` resource. For example:
Expand All @@ -36,7 +36,7 @@ spec:
extensions:
- name: timescaledb
image:
reference: ghcr.io/cloudnative-pg/timescaledb:2.23.1-18-trixie
reference: ghcr.io/cloudnative-pg/timescaledb:2.24.0-18-trixie
```

### 2. Enable the extension in a database
Expand All @@ -56,6 +56,7 @@ spec:
name: cluster-timescaledb
extensions:
- name: timescaledb
version: '2.24.0'
```

### 3. Verify installation
Expand All @@ -67,3 +68,37 @@ Once the database is ready, connect to it with `psql` and run:
```

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);
```

## 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` 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.
17 changes: 10 additions & 7 deletions timescaledb/metadata.hcl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# SPDX-FileCopyrightText: Copyright © contributors to CloudNativePG, established as CloudNativePG a Series of LF Projects, LLC.
# SPDX-License-Identifier: Apache-2.0
metadata = {
name = "timescaledb"
sql_name = "timescaledb"
Expand All @@ -7,15 +9,16 @@ metadata = {
dynamic_library_path = []
ld_library_path = []
auto_update_os_libs = false

required_extensions = []
create_extension = true
versions = {
bookworm = {
// renovate: datasource=postgresql depName=timescaledb-2-oss-postgresql-18 versioning=deb
"18" = "2.24.0~debian12-1801"
}
trixie = {
// renovate: datasource=postgresql depName=timescaledb-2-oss-postgresql-18 versioning=deb
"18" = "2.24.0~debian13-1801"
// renovate: datasource=postgresql depName=timescaledb-2-oss-postgresql-18 versioning=deb
"18" = "2.24.0~debian13-1801"
}
bookworm = {
// renovate: datasource=postgresql depName=timescaledb-2-oss-postgresql-18 versioning=deb
"18" = "2.24.0~debian12-1801"
}
}
}
28 changes: 28 additions & 0 deletions timescaledb/test/chainsaw-test.yaml
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
6 changes: 6 additions & 0 deletions timescaledb/test/check-extension-assert.yaml
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
29 changes: 29 additions & 0 deletions timescaledb/test/check-extension.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
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
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 "CREATE TABLE test_hypertable (time TIMESTAMPTZ NOT NULL, value DOUBLE PRECISION);"
psql "$DB_URI" -c "SELECT create_hypertable('test_hypertable', '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"
8 changes: 8 additions & 0 deletions timescaledb/test/cluster-assert.yaml
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)
14 changes: 14 additions & 0 deletions timescaledb/test/cluster.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
name: ($values.name)
spec:
imageName: ($values.pg_image)
instances: 1

storage:
size: 1Gi

postgresql:
shared_preload_libraries: ($values.shared_preload_libraries)
extensions: ($values.extensions)
10 changes: 10 additions & 0 deletions timescaledb/test/database-assert.yaml
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']))
status:
applied: true
extensions:
- applied: true
name: ($values.sql_name)
observedGeneration: 1
12 changes: 12 additions & 0 deletions timescaledb/test/database.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: postgresql.cnpg.io/v1
kind: Database
metadata:
name: (join('-', [$values.name, 'app']))
spec:
name: app
owner: app
cluster:
name: ($values.name)
extensions:
- name: ($values.sql_name)
version: ($values.version)