cnpg-stack
by QuenchWorks
Operator-managed HA PostgreSQL in one install: the CloudNativePG operator + a replicated Cluster (streaming replication, automated failover, built-in metrics) + a PgBouncer Pooler in front of the primary. Every image is QuenchWorks-hardened, nonroot, CVE-gated, pinned by digest and cosign-signed.
About this chart
Quenchworks cnpg-stack
Operator-managed HA PostgreSQL in one install:
- the CloudNativePG operator,
- a
Cluster: a primary plus streaming replicas, automated failover, metrics on port 9187 of every instance, - a PgBouncer
Poolerin front of the primary, running the catalogpgbouncerimage.
Every image is minimal, nonroot, CVE-gated, cosign-signed and pinned by digest. For HA without an operator, see postgres-ha-stack (Patroni).
Install
The operator's CRDs, ClusterRole and webhooks are cluster-wide: one operator per cluster.
helm install pg oci://ghcr.io/quenchworks/charts/cnpg-stack -n db --create-namespace
kubectl -n db get cluster pg-pg
kubectl -n db get secret pg-pg-app -o jsonpath='{.data.uri}' | base64 -d; echo
Apps connect to pg-pg-pooler-rw:5432 (PgBouncer to the primary), or directly to
pg-pg-rw (primary), pg-pg-ro (replicas) and pg-pg-r (any instance).
The Cluster and Pooler are applied by a post-install/upgrade hook Job, because the
operator's admission webhook is not serving yet when Helm applies the release. They are
not release objects, so helm uninstall keeps the database and its volumes. Remove them
with kubectl delete cluster pg-pg and kubectl delete pooler pg-pg-pooler-rw.
Configuration
| Key | Default | Meaning |
|---|---|---|
cluster.enabled | true | Create the Cluster |
cluster.instances | 3 | Primary plus replicas |
cluster.storage.size | 8Gi | Per instance |
cluster.storage.storageClass | "" | Default class when empty |
cluster.database, cluster.owner | app | Created at bootstrap; password in <release>-pg-app |
cluster.extraSpec | {} | Merged into the Cluster spec (parameters, backup, affinity) |
pooler.enabled | true | Create the PgBouncer Pooler |
pooler.instances | 2 | Pooler replicas |
pooler.poolMode | session | session or transaction |
pooler.parameters | {} | PgBouncer parameters |
cloudnative-pg.* | Passed to the cloudnative-pg chart (its postgresImage is the database image) |
Deploy cnpg-stack with OpenTenant
Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has cnpg-stack on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.
- Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
- Place the chartcnpg-stack is pinned at v0.0.32 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
- ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below opentenant validate opentenant.yaml terraform init && terraform apply