cloudnative-pg
Renders CloudNativePG Clusters, Databases, Poolers, ScheduledBackups and Backups and Barman Cloud Plugin ObjectStores from inventory parameters.
- Latest
- 1.0.1 ·
- License
- Apache-2.0
- Owners
- Moep90
- Source
- github.com/kadet-hub/generators · 0 repo stars, shared by 35 generators
- Thumbs up
- 👍 0 on GitHub Discussions
- Popularity
- 17 · 339 pulls
Request a feature Report a problem
Badge
Show the latest listed version in your README. shields.io draws the badge from this page's badge.json, which every catalog build updates; once no version is listed, it reads "not listed".
[](https://kadet-hub.org/generators/cloudnative-pg/)
cloudnative-pg Generator
Published on kadet-hub: pin a released version by digest from its catalog page.
Kapitan kadet generator for CloudNativePG PostgreSQL clusters. Built for CloudNativePG 1.30.1 and the Barman Cloud Plugin 0.15.1. It renders Cluster, Database, Pooler, ScheduledBackup and Backup (postgresql.cnpg.io/v1) and the plugin’s ObjectStore (barmancloud.cnpg.io/v1). PodMonitors come from the prometheus-operator generator, see Monitoring. Backups go through the Barman Cloud Plugin, which replaces the in-tree barmanObjectStore deprecated since CloudNativePG 1.26. The operator, the plugin and the Secrets with object store credentials are installed separately.
Usage
Kapitan Configuration
parameters:
kapitan:
dependencies:
- type: oci
source: ghcr.io/kadet-hub/cloudnative-pg@sha256:<digest>
output_path: lib/cloudnative-pg
compile:
- output_path: manifests/cloudnative-pg/
input_type: kadet
output_type: yml
input_paths:
- lib/cloudnative-pgExample
parameters:
generators:
cloudnative-pg:
namespace: databases
object_stores:
app-db-store:
configuration:
destinationPath: s3://pg-backups/app-db
endpointURL: https://s3.example.com
s3Credentials:
accessKeyId:
name: app-db-s3
key: ACCESS_KEY_ID
secretAccessKey:
name: app-db-s3
key: ACCESS_SECRET_KEY
wal:
compression: gzip
retention_policy: 30d
clusters:
app-db:
image_name: ghcr.io/cloudnative-pg/postgresql:18.6-system-trixie
storage: 50Gi
backup:
object_store: app-db-store
databases:
app:
cluster: app-db
owner: app
poolers:
app-db-pooler-rw:
cluster: app-db
pool_mode: transaction
scheduled_backups:
app-db-daily:
cluster: app-db
schedule: 0 3 * * *This yields a three-instance Cluster that archives WAL to app-db-store, the app database, a PgBouncer pooler in transaction mode on the -rw service, and a daily plugin backup at 03:00:00.
Inventory Contract
All keys live under parameters.generators.cloudnative-pg. Each entry becomes one resource named after its key. The namespace resolves from the entry’s namespace, then parameters.generators.cloudnative-pg.namespace, then parameters.namespace, then default.
| Key | Kind |
|---|---|
clusters.<name> |
Cluster |
databases.<name> |
Database |
poolers.<name> |
Pooler |
scheduled_backups.<name> |
ScheduledBackup |
backups.<name> |
Backup |
object_stores.<name> |
ObjectStore |
Every entry accepts labels, annotations and spec, the raw CRD spec for fields without a flat key. Precedence is generator defaults, then spec, then flat keys and shorthands; a flat key replaces the whole spec field of the same name and logs a warning.
Flat keys are the snake_case spelling of top-level CRD spec fields; their values pass through unchanged, in CRD camelCase:
| Kind | Flat keys |
|---|---|
| Cluster | instances, image_name, image_catalog_ref, storage, wal_storage, postgresql, bootstrap, resources, affinity, monitoring, managed, plugins, replica, external_clusters, certificates |
| Database | cluster, database_name (spec.name), owner, ensure, database_reclaim_policy, encoding, locale, template, extensions, schemas |
| Pooler | cluster, instances, type, pgbouncer, template, service_template |
| ScheduledBackup | cluster, schedule, method, plugin_configuration, target, online, immediate, suspend, backup_owner_reference |
| Backup | cluster, method, plugin_configuration, target, online |
| ObjectStore | configuration, retention_policy, instance_sidecar_configuration |
Shorthands:
| Input | Result |
|---|---|
cluster: <name> |
cluster: {name: <name>} |
Cluster storage: <size>, wal_storage: <size> |
storage: {size: <size>}, walStorage: {size: <size>} |
Cluster backup: {object_store: <store>, server_name: <name>} |
a plugins entry barman-cloud.cloudnative-pg.io with isWALArchiver: true and the parameters barmanObjectName and, if set, serverName, as in the plugin’s usage guide; other plugins stay |
Pooler pool_mode: <mode> |
pgbouncer.poolMode: <mode> |
ScheduledBackup five-field schedule |
a leading 0 seconds field; CloudNativePG uses a six-field cron (backup.md) |
When a major PostgreSQL upgrade changes image_name, change backup.server_name with it, so the new major version archives to a new path (postgres_upgrades.md).
Defaults
The generator fills these only where the inventory leaves them unset:
| Kind | Default | Why |
|---|---|---|
| Cluster | instances: 3 |
A primary and two standbys, as in cluster-example.yaml; the CRD default of 1 has no failover. |
| Database | name: <entry key> |
spec.name, the PostgreSQL database name, is required by the CRD. |
| Pooler | pgbouncer: {} |
Required by the CRD, which defaults poolMode to session (connection_pooling.md). |
| ScheduledBackup, Backup | method: plugin, pluginConfiguration: {name: barman-cloud.cloudnative-pg.io} |
The CRD default barmanObjectStore is deprecated since 1.26 (backup.md); pluginConfiguration is set only for method: plugin. |
| ScheduledBackup | backupOwnerReference: self |
The Backups it creates are deleted with it; the CRD default none is the legacy behaviour (backup.md). |
A Cluster without storage size or a pvcTemplate storage request fails the compile, since the operator’s admission rejects it. A backup without object_store fails, and so does an ObjectStore with configuration.serverName, which the plugin requires empty (parameters.md). A Pooler named like its Cluster or the Cluster’s -rw, -ro or -r Service fails, since the Pooler’s Service of the same name would patch the Cluster’s; name it like the upstream pooler-example-rw. A Cluster whose backup.object_store is an ObjectStore of this inventory in another namespace fails, since the plugin reads it from the Cluster’s namespace. A Backup or ScheduledBackup using the Barman Cloud Plugin for a Cluster of this inventory without the plugin fails, and so does backup together with spec.backup.barmanObjectStore, which the webhook rejects. The in-tree barmanObjectStore, removed in CloudNativePG 1.31.0 (release notes), and monitoring.enablePodMonitor still pass through, with a warning. Database owner, ObjectStore configuration.destinationPath and ScheduledBackup schedule have no default and fail schema validation when missing.
Pooler instances stays at the CRD default of 1. Nothing grants access or exposure by default: enableSuperuserAccess stays at the CRD default false, the Cluster and Pooler Services stay ClusterIP, and a LoadBalancer or extra service is set through managed.services or service_template. Without image_name the operator picks its default image, ghcr.io/cloudnative-pg/postgresql:18.6-system-trixie at 1.30.1, and an operator upgrade can change it. ObjectStore retention_policy has no default, so backups are kept until you set one. A Backup is an immutable one-shot request; keep it in the inventory only until it has run.
Monitoring
CloudNativePG 1.30 deprecates monitoring.enablePodMonitor in favour of a PodMonitor you own (monitoring.md). Render it with the prometheus-operator generator in the Cluster’s namespace; it must select cnpg.io/cluster: <name> and scrape port metrics. For app-db:
parameters:
generators:
prometheus_operator:
pod_monitors:
app-db:
namespace: databases
selector:
cnpg.io/cluster: app-db
pod_metrics_endpoints:
- metricsWith monitoring.tls.enabled: true on the Cluster, the endpoint scrapes over HTTPS with the cluster CA (app-db-ca, or the Secret in certificates.serverCASecret) and the server name app-db-rw:
parameters:
generators:
prometheus_operator:
pod_monitors:
app-db:
namespace: databases
selector:
cnpg.io/cluster: app-db
pod_metrics_endpoints:
- port: metrics
scheme: https
tlsConfig:
ca:
secret:
name: app-db-ca
key: ca.crt
serverName: app-db-rwOutput Files
| Output key | Kind |
|---|---|
<namespace>/<name>-cluster |
postgresql.cnpg.io/v1 Cluster |
<namespace>/<name>-database |
postgresql.cnpg.io/v1 Database |
<namespace>/<name>-pooler |
postgresql.cnpg.io/v1 Pooler |
<namespace>/<name>-scheduledbackup |
postgresql.cnpg.io/v1 ScheduledBackup |
<namespace>/<name>-backup |
postgresql.cnpg.io/v1 Backup |
<namespace>/<name>-objectstore |
barmancloud.cnpg.io/v1 ObjectStore |
v1 is the only served version and the storage version of every kind at CloudNativePG 1.30.1 and the Barman Cloud Plugin 0.15.1; none is deprecated. The compiled output is validated against the upstream CRD schemas in schemas/.
Versions
Add a version's inventory entry, then compile with the consumer workflow, which verifies the artifact and runs Kapitan in the sandbox.
Free of charge, as is and on a best-effort basis: use at your own risk, and review the compiled output before you apply it. Terms
This catalog was built from index serial 47. Set index_serial: 47 in .kapitan-sandbox.yaml and the consumer workflow refuses any older index, so a rolled-back index cannot bring back a yanked version.
Checks find known patterns; they do not prove a generator safe. What a listing covers
| Version | Built for (schema-checked) |
|---|---|
| 1.0.1 | Barman Cloud Plugin 0.15.1 CloudNativePG 1.30.1 |
| 1.0.0 | Barman Cloud Plugin 0.15.1 CloudNativePG 1.30.1 |
1.0.1#
Inventory
parameters:
kapitan:
dependencies:
- type: oci
source: ghcr.io/kadet-hub/cloudnative-pg:1.0.1@sha256:281417a421b0053070fbdc552f9032a3f8d564c0ca2047ec500842a0d060a8f7
output_path: lib/cloudnative-pg
Verify
gh attestation verify \
oci://ghcr.io/kadet-hub/cloudnative-pg@sha256:281417a421b0053070fbdc552f9032a3f8d564c0ca2047ec500842a0d060a8f7 \
--owner kadet-hub \
--cert-identity https://github.com/kadet-hub/registry/.github/workflows/release.yml@refs/heads/main
Transparency log: Rekor entry 3249981079, in Sigstore's public, append-only log, so the attestation stays checkable independent of this site.
- Kapitan declared
- >=0.36.3,<0.37
- Kapitan checked
- 0.36.3
- Backends checked
- not recorded
- With --cache
- not recorded
- krab
- compatible
- Built for (schema-checked)
- Barman Cloud Plugin 0.15.1
CloudNativePG 1.30.1 - Source
- cloudnative-pg-v1.0.1 ·
e4891e8fd85ca0a19ebf361e8b54fd6473fd8a2f· cloudnative-pg - Binaries
- none
- Output capabilities
- none
- Digest
sha256:281417a421b0053070fbdc552f9032a3f8d564c0ca2047ec500842a0d060a8f7
Checks
Checked by the release run on , gate at 6f0242aa6a3c.
- Secrets gitleaks 8.30.1
No secret matched the marketplace's gitleaks rules. - Malware ClamAV 1.5.4
No file matched a ClamAV signature. - Malicious package heuristics GuardDog 3.2.0
No GuardDog threat rule matched. - Dangerous code Semgrep 1.180.0
No marketplace Semgrep rule matched, such as eval, subprocess or network calls. - Python errors Ruff 0.17.0
No syntax error or undefined name (Ruff, error rules only). - File tree tree_check.py
No symlink, executable or banned file; imports within the allowlist. - Sandboxed compile gVisor 20261005, Kapitan 0.36.3
The fixture compiled without network, with decoy credentials; no undeclared program ran, no decoy was read. - Output capabilities Conftest 0.71.1
The compiled output uses only the capabilities the manifest declares. - CI detection Kapitan 0.36.3
The output is the same with CI variables set.
Output diff
No output diff recorded: this version was published before the release run recorded one.
1.0.0#
Inventory
parameters:
kapitan:
dependencies:
- type: oci
source: ghcr.io/kadet-hub/cloudnative-pg:1.0.0@sha256:e9c500eca116f100abc1646daff1fa187e3d2561be32116be209cfc4a0521d86
output_path: lib/cloudnative-pg
Verify
gh attestation verify \
oci://ghcr.io/kadet-hub/cloudnative-pg@sha256:e9c500eca116f100abc1646daff1fa187e3d2561be32116be209cfc4a0521d86 \
--owner kadet-hub \
--cert-identity https://github.com/kadet-hub/registry/.github/workflows/release.yml@refs/heads/main
Transparency log: Rekor entry 3241129547, in Sigstore's public, append-only log, so the attestation stays checkable independent of this site.
- Kapitan declared
- >=0.36.3,<0.37
- Kapitan checked
- 0.36.3
- Backends checked
- not recorded
- With --cache
- not recorded
- krab
- compatible
- Built for (schema-checked)
- Barman Cloud Plugin 0.15.1
CloudNativePG 1.30.1 - Source
- cloudnative-pg-v1.0.0 ·
572dda58b592673020f4a8d97142d1cdd2125440· cloudnative-pg - Binaries
- none
- Output capabilities
- none
- Digest
sha256:e9c500eca116f100abc1646daff1fa187e3d2561be32116be209cfc4a0521d86
Checks
Checked by the release run on , gate at 461ba3b3c507.
- Secrets gitleaks 8.30.1
No secret matched the marketplace's gitleaks rules. - Malware ClamAV 1.5.4
No file matched a ClamAV signature. - Malicious package heuristics GuardDog 3.2.0
No GuardDog threat rule matched. - Dangerous code Semgrep 1.180.0
No marketplace Semgrep rule matched, such as eval, subprocess or network calls. - Python errors Ruff 0.17.0
No syntax error or undefined name (Ruff, error rules only). - File tree tree_check.py
No symlink, executable or banned file; imports within the allowlist. - Sandboxed compile gVisor 20261005, Kapitan 0.36.3
The fixture compiled without network, with decoy credentials; no undeclared program ran, no decoy was read. - Output capabilities Conftest 0.71.1
The compiled output uses only the capabilities the manifest declares. - CI detection Kapitan 0.36.3
The output is the same with CI variables set.
Output diff
No output diff recorded: this version was published before the release run recorded one.