kadet-hub logokadet-hub

Recipes / postgresql

PostgreSQL on Kubernetes: CloudNativePG clusters from Kapitan

A recipe is packed cargo for one app: inventory classes, ready to load.

One CloudNativePG Cluster running PostgreSQL 18.6, rendered by the kadet-hub cloudnative-pg generator 1.1.0 from CloudNativePG’s Helm chart cluster 0.9.0.

1.1.1proof level deploys

  • Latest version: 1.1.1, published
  • Source chart: oci://ghcr.io/cloudnative-pg/charts/cluster:0.9.0@sha256:c8130c6573ab59e7629390ee5c468e5bc3d8536e6ec4ca8deea1aee792c4a9e5
  • Proof level: deploys, compared with the chart by the kadet-hub/recipes CI
  • renders passed in the release run of with check 0.18.0, kind v0.33.0
  • Output capabilities: none
  • Inventory backends: omegaconf
  • Prerequisites, installed once per cluster before the recipe: cnpg
  • Generators: cloudnative-pg 1.1.0 sha256:99320e83917d99190c45efa8f8e1dc4e732c65619ebf9c70151a0d96b4f5dca9, kubernetes 1.14.0 sha256:787129e1eaed6b9bc868fe4c4aec58d40de6a89fc3cc08424a4cb5822b855080
  • Image security: grade F 677 findings, one per advisory and package, in the 1 image of version 1.1.1: CRITICAL 1, HIGH 159, MEDIUM 292, LOW 205, UNKNOWN 20. Scanned 2026-12-03 04:38 UTC. Full report
    The grade rates the upstream images the recipe pins, not the recipe: ghcr.io/cloudnative-pg/postgresql.

Replaces

This recipe replaces the postgresql recipe of kadet-hub/examples, which stood in for Bitnami’s postgresql and postgresql-ha charts. The examples class named the Cluster app-db. A target that moves from it keeps that name and the size of its volumes, so the Cluster keeps its claims app-db-<n> and with them its data. Clients keep the Secret app-db-app and the Service app-db-rw.

parameters:
  namespace: databases
  applications:
    postgresql:
      cluster: app-db
      storage: 10Gi

Moving changes these objects:

kadet-hub/examples This recipe
CloudNativePG operator in the class, from its chart through a helm compile entry the recipe cnpg in a target of its own, with the same object names in cnpg-system. Replace it as the cnpg README describes under “Replacing a Helm release”. The examples class left no Helm secrets.
Namespace databases, rendered by the class no Namespace. Keep the Namespace when the examples class goes, because deleting it deletes the claims.
Pooler app-db-pooler-rw in transaction mode not rendered. A target whose clients connect through it sets the examples class’s entry generators.cloudnative-pg.poolers.app-db-pooler-rw.
Cluster settings the chart’s: enableSuperuserAccess: true, which adds the Secret app-db-superuser, primaryUpdateMethod: switchover and anti-affinity across zones, topologyKey: topology.kubernetes.io/zone
no ConfigMap postgresql-cluster-monitoring-logical-replication, the chart’s logical replication queries

The move is not tested.

What it deploys

  • recipes.postgresql (init.yml)
  • recipes.postgresql.cluster (cluster.yml)
  • recipes.postgresql.pgvector (pgvector.yml), an option
  • recipes.postgresql.earthdistance (earthdistance.yml), an option

Required parameters

No parameter has to be set.

Include

A target includes the recipe and its options as classes and can override anything the recipe sets:

classes:
  - recipes.postgresql
  - recipes.postgresql.pgvector         # the extension vector in the database
  - recipes.postgresql.earthdistance    # the extensions cube and earthdistance
parameters:
  namespace: <namespace>
  kapitan:
    vars:
      target: <target>

Fetching it

The quickstart goes through these steps on a kind cluster with the uptime-kuma recipe, from installing Kapitan to the running app.

A separate fetch inventory pins the recipe by version and digest. This is fetch/targets/recipes.yml for version 1.1.1:

parameters:
  kapitan:
    dependencies:
      - type: oci
        source: ghcr.io/kadet-hub/recipes/postgresql:1.1.1@sha256:1e8465058c256cc86995dc8d6f1eb2f095df244fadcaf756935599f4d9ead6a9
        output_path: inventory/classes/recipes/postgresql

The first command fetches the recipe into inventory/classes/recipes/postgresql, the second the generators and compiles:

kapitan compile --inventory-path fetch --fetch --output-path .
kapitan compile --fetch

The first command exits with status 1 because the fetch target compiles nothing. Kapitan's --fetch checks neither the digest nor the attestation. This verifies the attestation of the recipe:

gh attestation verify \
  oci://ghcr.io/kadet-hub/recipes/postgresql@sha256:1e8465058c256cc86995dc8d6f1eb2f095df244fadcaf756935599f4d9ead6a9 \
  --owner kadet-hub \
  --cert-identity https://github.com/kadet-hub/registry/.github/workflows/release.yml@refs/heads/main

The attested index must also list each digest under its recipe with the pinned version, and not as yanked. Verifying by hand shows how to read it.

Settings

Chart value Inventory
fullnameOverride, the Cluster’s name, postgresql-cluster applications.postgresql.cluster
cluster.initdb.database, app applications.postgresql.database
cluster.initdb.owner, app applications.postgresql.owner
cluster.storage.size, 8Gi applications.postgresql.storage
cluster.instances, 3 applications.postgresql.instances
cluster.imageName generators.cloudnative-pg.clusters.postgresql.image_name, tag and digest

The database and owner take effect only when the Cluster is created. The logical replication queries are the chart’s, Apache-2.0, with the license in cluster.yml.LICENSE.

Left out

Job/postgresql-cluster-ping-test, the chart’s Helm test.

Proof

check postgresql --level deploys with tests/values.yaml and tests/target.yml, on kind for each Kubernetes minor CI tests, with cnpg installed first. tests/values.yaml sets the database and owner that CloudNativePG gives an empty initdb, so the chart renders them like the recipe. tests/target.yml includes the options pgvector and earthdistance, whose statements tests/values.yaml sets as cluster.initdb.postInitApplicationSQL. tests/smoke checks what the chart’s ping test and the kadet-hub/examples recipe checked: the Cluster is ready, and the owner reaches its database through postgresql-cluster-rw with the credentials of postgresql-cluster-app. As the owner it then reads the version of vector from pg_extension and computes a distance between two vectors, and it requires cube and earthdistance in pg_extension and computes the length of one degree of longitude on the equator with earth_distance.

Used in stacks

Versions

  • 1.1.1, : sha256:1e8465058c256cc86995dc8d6f1eb2f095df244fadcaf756935599f4d9ead6a9
  • 1.1.0, : sha256:4af1be4c0e95e21fdc5f4029a9509364df93e995be83b8673e15a71dc08abf27
  • 1.0.1, : sha256:32c3af2cef6414e9dd57589bf984975b12c525b7c3136615fd5ac2ea7b1f688e
  • 1.0.0, : sha256:fc33441f62e05bd029b5f2e69c8589290275d759ccf4f6889a287103dd7466ff

The recipe's files are in kadet-hub/recipes. All recipes