Skip to main content

CloudNativePG

CloudNativePG is the Kubernetes operator that covers the full lifecycle of a highly available PostgreSQL database cluster with a primary/standby architecture, using native streaming replication.

CloudNativePG (CNPG) is an open-source operator designed to manage PostgreSQL workloads on any supported Kubernetes cluster. It fosters cloud-neutrality through seamless deployment in private, public, hybrid, and multi-cloud environments via its distributed topology feature. More information: https://cloudnative-pg.io

Within HavenPlus we standardise on PostgreSQL for workloads which require databases. We make use of CNPG to deploy PostgreSQL databases for components like Grafana and Keycloak. However, you can use CNPG for any of your workloads which requires a PostgreSQL database.

About PostgreSQL

PostgreSQL is a powerful, open source object-relational database system with over 35 years of active development that has earned it a strong reputation for reliability, feature robustness, and performance. Official documentation: https://www.postgresql.org/docs

Operator Deployment

The operator is installed via the official helm-chart https://cloudnative-pg.github.io/charts. Upgrading the operator is done by helm-chart version upgrade and additional upgrade steps may be needed. Always read the CNPG release notes before upgrading and verify upgrades on a non-production environment first.

Please note: Upgrading the operator will initiate a rolling update of every deployed PostgreSQL cluster, upgrading one instance at a time to use the new operator.

CNPG Cluster Deployment

The Operator listens for cluster.postgresql.cnpg.io custom resources. The following example will deploy a simple CNPG cluster with 3 instances (1 primary instance, 2 standby instances):

apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
name: example-pg-cluster
spec:
instances: 3
storage:
size: 10Gi

You can use Flux to deploy custom resources like the one above.

For the HavenPlus components using CNPG, we are using default values for PostgreSQL parameters. It is however possible to tune postgres specific parameters, e.g. when you need it to support a heavy workload. Please see this guide for more information.