Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
25 changes: 25 additions & 0 deletions pg_partman/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
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}-partman=${EXT_VERSION}"

FROM scratch
ARG PG_MAJOR

# Licenses
COPY --from=builder /usr/share/doc/postgresql-${PG_MAJOR}-partman/copyright /licenses/postgresql-${PG_MAJOR}-partman/

# Libraries
COPY --from=builder /usr/lib/postgresql/${PG_MAJOR}/lib/pg_partman* /lib/
COPY --from=builder /usr/lib/postgresql/${PG_MAJOR}/lib/bitcode/ /lib/bitcode/

# Share
COPY --from=builder /usr/share/postgresql/${PG_MAJOR}/extension/pg_partman* /share/extension/

USER 65532:65532
62 changes: 62 additions & 0 deletions pg_partman/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# pg\_partman

[pg\_partman](https://github.com/pgpartman/pg_partman) is an open-source extension
that enables **automatic partition management** in PostgreSQL.

This image provides a convenient way to deploy and manage `pg_partman` with
[CloudNativePG](https://cloudnative-pg.io/).

## Usage

### 1. Add the pg\_partman extension image to your Cluster

Define the `pg_partman` extension under the `postgresql.extensions` section of
your `Cluster` resource. For example:

```yaml
apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
name: cluster-pgvector
spec:
imageName: ghcr.io/cloudnative-pg/postgresql:18-minimal-trixie
instances: 1

storage:
size: 1Gi

postgresql:
extensions:
- name: pg_partman
image:
reference: ghcr.io/cloudnative-pg/pg_partman:5.3.1-2-trixie
```

### 2. Enable the extension in a database

You can install `pg_partman` 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-pg_partman-app
spec:
name: app
owner: app
cluster:
name: cluster-pg_partman
extensions:
- name: pg_partman
```

### 3. Verify installation

Once the database is ready, connect to it with `psql` and run:

```sql
\dx
```

You should see `pg_partman` listed among the installed extensions.
18 changes: 18 additions & 0 deletions pg_partman/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"metadata": {
"name": "pg_partman",
"sql_name": "pg_partman",
"shared_preload_libraries": ["pg_partman_bgw"],
"extension_control_path": [],
"dynamic_library_path": [],
"ld_library_path": [],
"versions": {
"bookworm": {
"18": "5.3.1-2.pgdg13+1"
},
"trixie": {
"18": "5.3.1-2.pgdg13+1"
}
}
}
}