-
Notifications
You must be signed in to change notification settings - Fork 35
feat: add pg_cron container image
#143
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
Open
ardentperf
wants to merge
4
commits into
cloudnative-pg:main
Choose a base branch
from
ardentperf:pr-cron
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| # 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 | ||
|
|
||
| # Install extension via `apt-get` | ||
| RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
| "postgresql-${PG_MAJOR}-cron=${EXT_VERSION}" | ||
|
|
||
| FROM scratch | ||
| ARG PG_MAJOR | ||
|
|
||
| # Licenses | ||
| COPY --from=builder /usr/share/doc/postgresql-${PG_MAJOR}-cron/copyright /licenses/postgresql-${PG_MAJOR}-cron/ | ||
|
|
||
| # Libraries | ||
| COPY --from=builder /usr/lib/postgresql/${PG_MAJOR}/lib/pg_cron* /lib/ | ||
| COPY --from=builder /usr/lib/postgresql/${PG_MAJOR}/lib/bitcode/ /lib/bitcode/ | ||
|
|
||
| # Share | ||
| COPY --from=builder /usr/share/postgresql/${PG_MAJOR}/extension/pg_cron* /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,104 @@ | ||
| # pg_cron | ||
| <!-- | ||
| SPDX-FileCopyrightText: Copyright © contributors to CloudNativePG, established as CloudNativePG a Series of LF Projects, LLC. | ||
| SPDX-License-Identifier: Apache-2.0 | ||
| --> | ||
|
|
||
| [pg_cron](https://github.com/citusdata/pg_cron) is an open-source extension | ||
| that provides a simple cron-based job scheduler for PostgreSQL, allowing you | ||
| to schedule PostgreSQL commands directly from the database. | ||
|
|
||
| ## Usage | ||
|
|
||
| ### 1. Add the cron extension image to your Cluster | ||
|
|
||
| Define the `pg_cron` extension under the `postgresql.extensions` section of | ||
| your `Cluster` resource. For example: | ||
|
|
||
| ```yaml | ||
| apiVersion: postgresql.cnpg.io/v1 | ||
| kind: Cluster | ||
| metadata: | ||
| name: cluster-pg-cron | ||
| spec: | ||
| imageName: ghcr.io/cloudnative-pg/postgresql:18-minimal-trixie | ||
| instances: 1 | ||
|
|
||
| storage: | ||
| size: 1Gi | ||
|
|
||
| postgresql: | ||
| parameters: | ||
| cron.database_name: app | ||
| cron.use_background_workers: "on" | ||
|
|
||
| shared_preload_libraries: | ||
| - "pg_cron" | ||
|
|
||
| extensions: | ||
| - name: pg_cron | ||
| image: | ||
| # renovate: suite=trixie-pgdg depName=postgresql-18-cron | ||
| reference: ghcr.io/cloudnative-pg/pg-cron:1.6.7-18-trixie | ||
| ``` | ||
|
|
||
| ### 2. Enable the extension in a database | ||
|
|
||
| You can install `cron` 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-cron-app | ||
| spec: | ||
| name: app | ||
| owner: app | ||
| cluster: | ||
| name: cluster-pg-cron | ||
| extensions: | ||
| - name: pg_cron | ||
| # renovate: suite=trixie-pgdg depName=postgresql-18-cron extractVersion=^(?<version>\d+\.\d+) | ||
| version: '1.6' | ||
| ``` | ||
|
|
||
| ### 3. Verify installation | ||
|
|
||
| Once the database is ready, connect to it with `psql` and run: | ||
|
|
||
| ```sql | ||
| \dx | ||
| ``` | ||
|
|
||
| You should see `pg_cron` listed among the installed extensions. | ||
|
|
||
| ## Contributors | ||
|
|
||
| This extension is maintained by: | ||
|
|
||
| - Jeremy Schneider (@ardentperf) | ||
|
|
||
| The maintainers are responsible for: | ||
|
|
||
| - Monitoring upstream releases and security vulnerabilities. | ||
| - Ensuring compatibility with supported PostgreSQL versions. | ||
| - Reviewing and merging contributions specific to this extension's container | ||
| image and lifecycle. | ||
|
|
||
| --- | ||
|
|
||
| ## Licenses and Copyright | ||
|
|
||
| This container image contains software that may be licensed under various | ||
| open-source licenses. | ||
|
|
||
| All relevant license and copyright information for the `pg_cron` 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. |
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,40 @@ | ||
| # SPDX-FileCopyrightText: Copyright © contributors to CloudNativePG, established as CloudNativePG a Series of LF Projects, LLC. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| metadata = { | ||
| name = "pg-cron" | ||
| image_name = "pg-cron" | ||
|
|
||
| licenses = ["PostgreSQL"] | ||
|
|
||
| sql_name = "pg_cron" | ||
| shared_preload_libraries = ["pg_cron"] | ||
| # cron.database_name must match the database where CREATE EXTENSION is run | ||
| postgresql_parameters = { "cron.database_name" = "app" } | ||
| extension_control_path = [] | ||
| dynamic_library_path = [] | ||
| ld_library_path = [] | ||
| bin_path = [] | ||
| env = {} | ||
| auto_update_os_libs = false | ||
| required_extensions = [] | ||
| create_extension = true | ||
|
|
||
| versions = { | ||
| bookworm = { | ||
| "18" = { | ||
| // renovate: suite=bookworm-pgdg depName=postgresql-18-cron | ||
| package = "1.6.7-2.pgdg12+1" | ||
| // renovate: suite=bookworm-pgdg depName=postgresql-18-cron extractVersion=^(?<version>\d+\.\d+) | ||
| sql = "1.6" | ||
| } | ||
| } | ||
| trixie = { | ||
| "18" = { | ||
| // renovate: suite=trixie-pgdg depName=postgresql-18-cron | ||
| package = "1.6.7-2.pgdg13+1" | ||
| // renovate: suite=trixie-pgdg depName=postgresql-18-cron extractVersion=^(?<version>\d+\.\d+) | ||
| sql = "1.6" | ||
| } | ||
| } | ||
| } | ||
| } | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I can see, the package is not distributed under
PostgreSQLlicense but undercitusandcronlicenses, which have slightly different restrictions:I think the actual SPDX license here is Vixie-Cron
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The "citus" license is the PostgreSQL license. It's exactly the same, except that "University of California" is changed to "Citus Data" which is the normal process when the Postgres License is being used by someone other than the University of California.
https://www.postgresql.org/about/licence/
I missed the Vixie-Cron license, you're right that it also needs to be added for those two files. I'll update the PR
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm afraid this might go against one of the latest requirement that was added for new extensions proposals, which is that each listed license must fall into the CNCF Allowlist in order to be accepted.
https://github.com/cloudnative-pg/postgres-extensions-containers/blob/90ecbbad1a1923419de1419d0fa571a2c7ae8be0/README.md#extension-requirements
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I agree with @GabriFedi97. Unfortunately, we must comply with that list. As I said with other extensions, that doesn't prevent anyone from distributing that extension image, but it cannot be done through the official CNPG project for licensing reasons.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CNCF rejecting code under the Vixie-Cron license seems... pretty astounding... (that license should be compatible)
But I guess they would want to pay a lawyer to sign off on it, and maybe not worth legal fees and all the time sending emails to coordinate for two small files (?)
Probably need some non-CNCF place to host extensions sooner than later
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, we are unable to request exceptions for each extension or obtain a waiver for the Vixie-Cron license, which I believe should be acceptable (but it is not in that list, and that's what matters now).
Regarding the non-CNCF host, the PostgreSQL community could be a good place for that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm, afaik pg community has never yet done official, authoritative hosting on GH and there's a strong bias toward own infra for historical reasons. I think hosting on GH is ideal for CNPG extensions, so that the build and test and distribution processes can be as close as possible to the CNCF-compliant, CNPG-hosted extensions.
We almost need an equivalent of debian nonfree or ubuntu restricted/multiverse. One you get into the extension space, Postgres needs to solve distribution-style problems.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I presume there will be no extra test coverage within CNPG repo for these extensions. So then the only convenience is the GH hosting of the images itself? With the reoccuring supply chain attacks that has happened (npm, GH), pulling any image not built by yourself / your trusted security domain should be done with care and thought anyhow. That's 2 cent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CI and integrations - GH actions, unit tests, security scans, renovate integration
are we rewriting everything for jenkins then trying to keep it all in sync as CNPG extensions repo gets additions over time?
and even with hosting - would community want to run their own container registry? many questions here
it's a lot easier to just have another GH org that's not CNCF, which functions as a popular place for non-CNCF-license-friendly postgres extensions. who knows maybe i'll set something up myself for fun
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had an AI agent check licenses for all extensions currently packaged for Debian
PostgreSQL Debian Team Extensions — CNCF License Audit
Audit of all extensions in the Debian Salsa PostgreSQL group
against the CNCF Allowed Third-Party License Policy.
Date: 2026-06-11
Method: Debian
copyrightfiles fetched from Salsa; runtime dependencies checked viaapt-cacheinsideghcr.io/cloudnative-pg/postgresql:18-minimal-trixie.Officially packaged by upstream CNPG (cloudnative-pg/postgres-extensions-containers) and excluded from this audit:
pgaudit,pg-crash,pgvector,postgis,timescaledb-oss,wal2jsonThe following extensions were worked on by ardentperf but are not yet in upstream CNPG and are therefore included in this audit:
hll,hypopg,pg-cron,pg-hint-plan,pgnodemx,pg-partman,pg-repack,pgsentinel✅ Clean — 69 extensions (PG18+ only)
All licenses (extension + runtime dependencies) are on the CNCF allowlist.
Extensions marked with (ardentperf) are worked on by ardentperf but not yet in upstream CNPG.
Note: Many extensions use a custom license label (e.g. "cybertec", "PLJS", "PostgreSQL-EDB") that is
word-for-word identical to the PostgreSQL License with only the copyright holder name substituted.
These are treated as equivalent to the PostgreSQL License.
❌ Blocked — 20 extensions
Extensions marked with (ardentperf) are worked on by ardentperf but not yet in upstream CNPG.
Notes
scripts (
debian/*). These scripts are never redistributed in container images and do notaffect compliance.
version. Individual project-specific LGPL exceptions exist (e.g. paramiko for oscal-compass)
but do not apply here.
Consul, etc.) but no general MPL-2.0 blanket exception.
and "dependencies" and does not explicitly address container base images (cncf/foundation #362).
This audit applies the same standard to runtime library dependencies shipped in the image.