cnpg-cluster

by KvalitetsIT

Helm chartv0.5.3App 0.5.3Verified publisher

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.

Homepage: https://github.com/KvalitetsIT

Maintainers

NameEmailUrl
KvalitetsIT[email protected]https://github.com/KvalitetsIT/helm-repo

Source Code

Requirements

RepositoryNameVersion
https://raw.githubusercontent.com/KvalitetsIT/helm-repo/master/templates2.2.0

Values

Global

KeyTypeDefaultDescription
globalobjectsee values.yamlGlobal values propagated to all chart dependencies.
global.objectStore.configuration.endpointURLstring""S3-compatible endpoint URL. Mirrors objectStore.configuration.endpointURL and is accessible to subchart dependencies (e.g. CiliumNetworkPolicy egress rules).

Cluster

KeyTypeDefaultDescription
nameOverridestringRelease nameOverride the Cluster name.
metadataobject{}Metadata overrides for the Cluster resource.
instancesint1Number of PostgreSQL instances in the cluster.
enablePDBstringautoManage 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.
clusterSpecobject{}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.
imageNamestring""Container image for PostgreSQL. Takes precedence over imageCatalogRef.
imageCatalogRefobject{}Reference to an ImageCatalog or ClusterImageCatalog resource.
imagePullPolicystringIfNotPresentImage pull policy for the PostgreSQL container.
imagePullSecretslist[]Image pull secrets for private registries.

Storage

KeyTypeDefaultDescription
storageobjectsee values.yamlPVC storage configuration for PostgreSQL data.
storage.sizestring8GiSize of the PVC for PostgreSQL data.
storage.storageClassstringcluster defaultStorage class for the data PVC.

WAL Storage

KeyTypeDefaultDescription
walStorageobjectsee values.yamlSeparate PVC configuration for WAL files.
walStorage.enabledboolfalseSet to true to use a separate PVC for WAL files.
walStorage.sizestring1GiSize of the WAL PVC.
walStorage.storageClassstringcluster defaultStorage class for the WAL PVC.

PostgreSQL

KeyTypeDefaultDescription
postgresqlobjectsee values.yamlPostgreSQL engine configuration.
postgresql.parametersobject{}PostgreSQL configuration parameters (postgresql.conf knobs).
postgresql.pg_hbalist[]pg_hba.conf rules appended after the operator-managed entries.
postgresql.pg_identlist[]pg_ident.conf rules.
postgresql.shared_preload_librarieslist[]Libraries added to shared_preload_libraries.

Bootstrap

KeyTypeDefaultDescription
initdbobject{}initdb bootstrap config. Maps to spec.bootstrap.initdb.
recoveryobject{}Recovery bootstrap config. Maps to spec.bootstrap.recovery.
pgBaseBackupobject{}pg_basebackup bootstrap config. Maps to spec.bootstrap.pg_basebackup.
externalClusterslist[]External cluster definitions used for recovery or replica sources. Maps to spec.externalClusters.

Replication

KeyTypeDefaultDescription
replicaobject{}Replica cluster configuration. Maps to spec.replica.
replicationSlotsobject{}Replication slot configuration. Maps to spec.replicationSlots.

Roles & Databases

KeyTypeDefaultDescription
roleslist[]Declarative role management. Maps to spec.managed.roles. See example and the RoleConfiguration API.
databaseslist[]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

KeyTypeDefaultDescription
backupobjectsee values.yamlVolumeSnapshot backup, scheduled backups, and WAL settings.
backup.targetstringprefer-standbyWhich instance to take backups from. prefer-standby avoids load on the primary.
backup.retentionPolicystring"30d"Backup retention policy (e.g. "30d", "10" for 10 backups).
backup.volumeSnapshot.enabledboolfalseSet to true to enable VolumeSnapshot-based backups.
backup.volumeSnapshot.classNamestring""VolumeSnapshotClass for the data volume snapshot.
backup.volumeSnapshot.walClassNamestring""VolumeSnapshotClass for the WAL volume snapshot.
backup.volumeSnapshot.onlinebooltrueTake the snapshot while the instance is running (online snapshot).
backup.volumeSnapshot.snapshotOwnerReferencestringclusterWhich resource owns the snapshots (cluster or none).
backup.scheduledBackupslist[]List of ScheduledBackup resources to create for this cluster. See the ScheduledBackup API.

Plugins

KeyTypeDefaultDescription
pluginslist[]Additional plugins to inject into the Cluster spec. The barman-cloud plugin entry is auto-injected when objectStore.enabled is true.

Monitoring

KeyTypeDefaultDescription
monitoringobjectsee values.yamlMonitoring configuration including PodMonitor and custom queries.
monitoring.enabledboolfalseSet to true to enable monitoring.
monitoring.enablePodMonitorbooltrueSet to true to create a PodMonitor resource.
monitoring.podMonitorRelabelingslist[]Relabeling rules applied to scraped metrics.
monitoring.podMonitorMetricRelabelingslist[]Metric relabeling rules applied after scraping.
monitoring.disableDefaultQueriesboolfalseDisable the default Prometheus queries shipped by CNPG.
monitoring.customQueriesSecretlist[]References to secrets containing custom Prometheus queries (ConfigMap key: custom-queries.yaml).
monitoring.prometheusRuleobjectsee values.yamlPrometheusRule configuration for alerting.
monitoring.prometheusRule.enabledboolfalseSet to true to create a PrometheusRule with CNPG alerting rules. Requires monitoring.enabled: true and the monitoring.coreos.com/v1 CRD.
monitoring.prometheusRule.excludeRuleslist[]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

KeyTypeDefaultDescription
resourcesobject{}CPU and memory resource requests/limits for the PostgreSQL container.
priorityClassNamestring""PriorityClass for the PostgreSQL pods.
nodeSelectorobject{}Node selector for the PostgreSQL pods.
tolerationslist[]Tolerations for the PostgreSQL pods.
topologySpreadConstraintslist[]Topology spread constraints for the PostgreSQL pods.
affinityobject{}Affinity rules for the PostgreSQL pods.

Access & Security

KeyTypeDefaultDescription
enableSuperuserAccessbooltrueAllow direct connections to the postgres superuser.
superuserSecretstring""Name of an existing secret containing the superuser password.

Lifecycle

KeyTypeDefaultDescription
primaryUpdateMethodstringswitchoverMethod used to perform a controlled switchover (switchover or restart).
primaryUpdateStrategystringunsupervisedWhen to apply updates: unsupervised applies them automatically.

Metadata & Volumes

KeyTypeDefaultDescription
envlist[]Extra environment variables for the PostgreSQL container.
envFromlist[]Extra environment variables sourced from ConfigMaps or Secrets.

Poolers

KeyTypeDefaultDescription
poolerslist[]List of Pooler (PgBouncer) resources to create for this cluster.

Object Store

KeyTypeDefaultDescription
objectStoreobjectsee values.yamlObjectStore resource for the barman-cloud plugin. Enabling this automatically injects the plugin entry into the Cluster spec.
objectStore.enabledboolfalseSet to true to create an ObjectStore resource and enable the barman-cloud plugin.
objectStore.retentionPolicystring"30d"Backup retention policy.
objectStore.configurationobjectsee values.yamlObjectStore 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.destinationPathstring""S3 destination path for backups (e.g. s3://my-bucket/my-cluster). Required.
objectStore.configuration.s3Credentialsobject{}S3 credentials referencing Kubernetes secret keys.
objectStore.configuration.s3Credentials.accessKeyIdobject{}Secret key reference for the S3 access key ID.
objectStore.configuration.s3Credentials.secretAccessKeyobject{}Secret key reference for the S3 secret access key.
objectStore.configuration.wal.compressionstringzstdCompression algorithm for WAL files (bzip2, gzip, lz4, snappy, xz, zstd).
objectStore.configuration.wal.maxParallelint8Number of parallel WAL upload workers.
objectStore.configuration.data.compressionstringzstdCompression algorithm for base backup data files (bzip2, gzip, lz4, snappy, zstd). zstd needs plugin-barman-cloud v0.16.0 or later.
objectStore.configuration.data.jobsint8Number of parallel data upload workers.
objectStore.instanceSidecarConfigurationobjectsee values.yamlSidecar container configuration for the barman-cloud plugin.
objectStore.instanceSidecarConfiguration.resources.limits.memorystring512MiMemory limit for the barman-cloud sidecar.
objectStore.instanceSidecarConfiguration.resources.requests.memorystring256MiMemory request for the barman-cloud sidecar.
objectStore.instanceSidecarConfiguration.resources.requests.cpustring250mCPU request for the barman-cloud sidecar.

Network Policies

KeyTypeDefaultDescription
ciliumNetworkPoliciesobjectsee values.yamlCiliumNetworkPolicy 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.
networkPoliciesobjectsee values.yamlStandard 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:

PolicyTypePurpose
<name>-cnpg-clusterCilium / fallbackAllows 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.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartcnpg-cluster is pinned at v0.5.3 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. 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