Helm chart for deploying CloudNativePG clusters and related resources. Ships with a default CiliumNetworkPolicy allowing the CNPG operator to reach cluster pods.
About this chart
cnpg-cluster
Helm chart for deploying CloudNativePG clusters and related resources. Ships with a default CiliumNetworkPolicy allowing the CNPG operator to reach cluster pods.
Global values propagated to all chart dependencies.
global.objectStore.configuration.endpointURL
string
""
S3-compatible endpoint URL. Mirrors objectStore.configuration.endpointURL and is accessible to subchart dependencies (e.g. CiliumNetworkPolicy egress rules).
Cluster
Key
Type
Default
Description
nameOverride
string
Release name
Override the Cluster name.
metadata
object
{}
Metadata overrides for the Cluster resource.
instances
int
1
Number of PostgreSQL instances in the cluster.
enablePDB
string
auto
Manage the PodDisruptionBudget for the cluster. When null (default), the chart automatically sets this to false for single-instance clusters (instances=1) and leaves it unset (operator default: true) for multi-instance clusters. Set explicitly to true or false to override this behaviour.
clusterSpec
object
{}
Passthrough for any ClusterSpec fields not explicitly exposed by chart values. Fields here are appended to the Cluster spec as-is. Do not duplicate keys already managed by other values.
imageName
string
""
Container image for PostgreSQL. Takes precedence over imageCatalogRef.
imageCatalogRef
object
{}
Reference to an ImageCatalog or ClusterImageCatalog resource.
pg_hba.conf rules appended after the operator-managed entries.
postgresql.pg_ident
list
[]
pg_ident.conf rules.
postgresql.shared_preload_libraries
list
[]
Libraries added to shared_preload_libraries.
Bootstrap
Key
Type
Default
Description
initdb
object
{}
initdb bootstrap config. Maps to spec.bootstrap.initdb.
recovery
object
{}
Recovery bootstrap config. Maps to spec.bootstrap.recovery.
pgBaseBackup
object
{}
pg_basebackup bootstrap config. Maps to spec.bootstrap.pg_basebackup.
externalClusters
list
[]
External cluster definitions used for recovery or replica sources. Maps to spec.externalClusters.
Replication
Key
Type
Default
Description
replica
object
{}
Replica cluster configuration. Maps to spec.replica.
replicationSlots
object
{}
Replication slot configuration. Maps to spec.replicationSlots.
Roles & Databases
Key
Type
Default
Description
roles
list
[]
Declarative role management. Maps to spec.managed.roles. See example and the RoleConfiguration API.
databases
list
[]
List of Database CRD resources to create. Each entry requires a name field. The cluster reference is auto-injected. All other fields map directly to the Database spec. See example and the Database API.
Backup
Key
Type
Default
Description
backup
object
see values.yaml
VolumeSnapshot backup, scheduled backups, and WAL settings.
backup.target
string
prefer-standby
Which instance to take backups from. prefer-standby avoids load on the primary.
backup.retentionPolicy
string
"30d"
Backup retention policy (e.g. "30d", "10" for 10 backups).
backup.volumeSnapshot.enabled
bool
false
Set to true to enable VolumeSnapshot-based backups.
backup.volumeSnapshot.className
string
""
VolumeSnapshotClass for the data volume snapshot.
backup.volumeSnapshot.walClassName
string
""
VolumeSnapshotClass for the WAL volume snapshot.
backup.volumeSnapshot.online
bool
true
Take the snapshot while the instance is running (online snapshot).
backup.volumeSnapshot.snapshotOwnerReference
string
cluster
Which resource owns the snapshots (cluster or none).
backup.scheduledBackups
list
[]
List of ScheduledBackup resources to create for this cluster. See the ScheduledBackup API.
Plugins
Key
Type
Default
Description
plugins
list
[]
Additional plugins to inject into the Cluster spec. The barman-cloud plugin entry is auto-injected when objectStore.enabled is true.
Monitoring
Key
Type
Default
Description
monitoring
object
see values.yaml
Monitoring configuration including PodMonitor and custom queries.
monitoring.enabled
bool
false
Set to true to enable monitoring.
monitoring.enablePodMonitor
bool
true
Set to true to create a PodMonitor resource.
monitoring.podMonitorRelabelings
list
[]
Relabeling rules applied to scraped metrics.
monitoring.podMonitorMetricRelabelings
list
[]
Metric relabeling rules applied after scraping.
monitoring.disableDefaultQueries
bool
false
Disable the default Prometheus queries shipped by CNPG.
monitoring.customQueriesSecret
list
[]
References to secrets containing custom Prometheus queries (ConfigMap key: custom-queries.yaml).
monitoring.prometheusRule
object
see values.yaml
PrometheusRule configuration for alerting.
monitoring.prometheusRule.enabled
bool
false
Set to true to create a PrometheusRule with CNPG alerting rules. Requires monitoring.enabled: true and the monitoring.coreos.com/v1 CRD.
monitoring.prometheusRule.excludeRules
list
[]
List of alert names to exclude from the PrometheusRule. Useful for silencing alerts that are expected or not applicable to your setup. CNPGClusterHACritical is only rendered when instances >= 2 and CNPGClusterHAWarning only when instances >= 3, since they would otherwise fire permanently. CNPGClusterZoneSpreadWarning is only rendered when the instances are spread on topology.kubernetes.io/zone, through topologySpreadConstraints or affinity.topologyKey. It also needs kube-state-metrics to export that node label. Clusters without logical replication can exclude all CNPGClusterLogicalReplication* alerts. Example - exclude all logical replication alerts: excludeRules: - CNPGClusterLogicalReplicationErrors - CNPGClusterLogicalReplicationErrorsCritical - CNPGClusterLogicalReplicationLagging - CNPGClusterLogicalReplicationLaggingCritical - CNPGClusterLogicalReplicationStopped - CNPGClusterLogicalReplicationStoppedCritical
Resources & Scheduling
Key
Type
Default
Description
resources
object
{}
CPU and memory resource requests/limits for the PostgreSQL container.
priorityClassName
string
""
PriorityClass for the PostgreSQL pods.
nodeSelector
object
{}
Node selector for the PostgreSQL pods.
tolerations
list
[]
Tolerations for the PostgreSQL pods.
topologySpreadConstraints
list
[]
Topology spread constraints for the PostgreSQL pods.
affinity
object
{}
Affinity rules for the PostgreSQL pods.
Access & Security
Key
Type
Default
Description
enableSuperuserAccess
bool
true
Allow direct connections to the postgres superuser.
superuserSecret
string
""
Name of an existing secret containing the superuser password.
Lifecycle
Key
Type
Default
Description
primaryUpdateMethod
string
switchover
Method used to perform a controlled switchover (switchover or restart).
primaryUpdateStrategy
string
unsupervised
When to apply updates: unsupervised applies them automatically.
Metadata & Volumes
Key
Type
Default
Description
env
list
[]
Extra environment variables for the PostgreSQL container.
envFrom
list
[]
Extra environment variables sourced from ConfigMaps or Secrets.
Poolers
Key
Type
Default
Description
poolers
list
[]
List of Pooler (PgBouncer) resources to create for this cluster.
Object Store
Key
Type
Default
Description
objectStore
object
see values.yaml
ObjectStore resource for the barman-cloud plugin. Enabling this automatically injects the plugin entry into the Cluster spec.
objectStore.enabled
bool
false
Set to true to create an ObjectStore resource and enable the barman-cloud plugin.
objectStore.retentionPolicy
string
"30d"
Backup retention policy.
objectStore.configuration
object
see values.yaml
ObjectStore configuration. Set destinationPath and s3Credentials at minimum. Note: endpointURL is set under global.objectStore.configuration.endpointURL (not here), so it propagates to subchart dependencies such as the CiliumNetworkPolicy egress template. Setting it here instead will produce a validation error at render time.
objectStore.configuration.destinationPath
string
""
S3 destination path for backups (e.g. s3://my-bucket/my-cluster). Required.
CiliumNetworkPolicy resources. Each entry is rendered by the templates chart helper with root set to this chart's context, so template strings (e.g. include "cnpg-cluster.fullname") resolve correctly. The map key is used as a name suffix; the cluster fullname is prepended automatically. Set enabled: false on any entry to suppress it.
networkPolicies
object
see values.yaml
Standard NetworkPolicy resources for pod-to-pod traffic that does not require Cilium-specific features. Rendered with the same iterator pattern as ciliumNetworkPolicies.
Usage
This is a Helm chart for deploying CloudNativePG clusters and related resources.
Configure the sections below to deploy a cluster and additional resources.
Network policies
The chart ships with network policies enabled by default. When Cilium is present (cilium.io/v2 CRD available), CiliumNetworkPolicy resources are rendered; otherwise standard NetworkPolicy resources are used as a fallback.
The following policies are rendered by default:
Policy
Type
Purpose
<name>-cnpg-cluster
Cilium / fallback
Allows all cluster pods to
Deploy cnpg-cluster with OpenTenant
Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has cnpg-cluster 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-cluster is pinned at v0.5.3 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