CloudNativePG
CloudNativePG
CloudNativePG is an open source operator
- designed to manage PostgreSQL workloads on any supported
Kubernetes cluster running in private, public, hybrid, or multi-cloud
environments. CloudNativePG adheres to DevOps principles and concepts such as declarative configuration and immutable infrastructure.
It defines a new Kubernetes resource called Cluster representing a
PostgreSQL cluster made up of a single primary and an optional number of
replicas that co-exist in a chosen Kubernetes namespace for High
Availability and offloading of read-only queries.
Applications that reside in the same Kubernetes cluster can access the PostgreSQL database using a service which is solely managed by the operator, without having to worry about changes of the primary role following a failover or a switchover. Applications that reside outside the Kubernetes cluster, need to configure a Service or Ingress object to expose the Postgres via TCP. Web applications can take advantage of the native connection pooler based on PgBouncer.
CloudNativePG was originally built by EDB , then released open source under Apache License 2.0 and submitted for CNCF Sandbox in April 2022. The source code repository is in Github .
Note
Based on the Operator Capability Levels model , users can expect a "Level V - Auto Pilot" set of capabilities from the CloudNativePG Operator.
Supported Kubernetes distributions
Each minor release of CloudNativePG is designed to work with a range of Kubernetes versions, usually the ones supported by the CNCF at the time the minor version was first released.
Please refer to the Supported releases page for details.
Container images
The CloudNativePG community maintains container images for both the operator and the operand, that is PostgreSQL.
The CloudNativePG operator container images are distroless
and available on the cloudnative-pg .
- The PostgreSQL operand container images are available for all the
PGDG supported versions of PostgreSQL , on multiple architectures, directly from the postgres-containers .
Additionally, the Community provides images for the PostGIS extension .
Main features
Direct integration with Kubernetes API server for High Availability, without requiring an external tool
Self-Healing capability, through:
failover of the primary instance by promoting the most aligned replica
automated recreation of a replica
Planned switchover of the primary instance by promoting a selected replica
Scale up/down capabilities
Definition of an arbitrary number of instances (minimum 1 - one primary server)
Definition of the read-write service, to connect your applications to the only primary server of the cluster
Definition of the read-only service, to connect your applications to any of the instances for reading workloads
Declarative management of PostgreSQL configuration, including certain popular Postgres extensions through the cluster
spec:pgaudit,auto_explain,pg_stat_statements, andpg_failover_slotsDeclarative management of Postgres roles, users and groups
Support for Local Persistent Volumes with PVC templates
Reuse of Persistent Volumes storage in Pods
Separate volumes for WAL files and tablespaces
Declarative management of Postgres tablespaces, including temporary tablespaces
Rolling updates for PostgreSQL minor versions
In-place or rolling updates for operator upgrades
TLS connections and client certificate authentication
Support for custom TLS certificates (including integration with cert-manager)
Continuous WAL archiving to an object store (AWS S3 and S3-compatible, Azure Blob Storage, and Google Cloud Storage)
Backups on volume snapshots (where supported by the underlying storage classes)
Backups on object stores (AWS S3 and S3-compatible, Azure Blob Storage, and Google Cloud Storage)
Full recovery and Point-In-Time recovery from an existing backup on volume snapshots or object stores
Offline import of existing PostgreSQL databases, including major upgrades of PostgreSQL
Online import of existing PostgreSQL databases, including major upgrades of PostgreSQL, through PostgreSQL native logical replication (imperative, via the
cnpgplugin)Fencing of an entire PostgreSQL cluster, or a subset of the instances in a declarative way
Hibernation of a PostgreSQL cluster in a declarative way
Support for Synchronous Replicas
Support for HA physical replication slots at cluster level
Synchronization of user defined physical replication slots
Backup from a standby
Backup retention policies (based on recovery window, only on object stores)
Parallel WAL archiving and restore to allow the database to keep up with WAL generation on high write systems
Support tagging backup files uploaded to an object store to enable optional retention management at the object store layer
Replica clusters for PostgreSQL deployments across multiple Kubernetes clusters, enabling private, public, hybrid, and multi-cloud architectures
Delayed Replica clusters
Connection pooling with PgBouncer
Support for node affinity via
nodeSelectorNative customizable exporter of user defined metrics for Prometheus through the
metricsport (9187)Standard output logging of PostgreSQL error messages in JSON format
Automatically set
readOnlyRootFilesystemsecurity context for podscnpgplugin forkubectlSimple bind and search+bind LDAP client authentication
Multi-arch format container images
OLM installation
Note
CloudNativePG does not use StatefulSet s for managing data persistence. Rather, it manages persistent volume claims (PVCs) directly. If you are curious, read Custom Pod Controller to know more.
About this guide
Follow the instructions in the Quickstart to test CloudNativePG on a local Kubernetes cluster using Kind, or Minikube.
In case you are not familiar with some basic terminology on Kubernetes and PostgreSQL, please consult the Before You Start .
are trademarks or registered trademarks of the PostgreSQL Community Association of Canada, and used with their permission.*
- Introduction
- Before You Start
- Use cases
- Architecture
- Installation and upgrades
- Installation on Kubernetes
- Details about the deployment
- Upgrades
- In-place updates of the instance manager
- Compatibility among versions
- Upgrading to 1.23.0, 1.22.3 or 1.21.5
- User defined replication slots
- Server-side apply of manifests
- Upgrading to 1.22 from a previous minor version
- Upgrading to 1.21 from a previous minor version
- Superuser access disabled
- Replication slots for HA
- Delay for PostgreSQL shutdown
- Delay for PostgreSQL startup
- Delay for PostgreSQL switchover
- Labels
- Shortcut for keeping the existing behavior
- Quickstart
- Image Catalog
- Bootstrap
- Importing Postgres databases
- Security
- Postgres instance manager
- Scheduling
- Resource management
- Failure Modes
- Rolling Updates
- Replication
- Backup
- Backup on object stores
- WAL archiving
- Backup on volume snapshots
- Recovery
- PostgreSQL Configuration
- Database Role Management
- Tablespaces
- Operator configuration
- Instance pod configuration
- Volume Claim Template for Temporary Storage
- Storage
- Backup and recovery
- Benchmarking CloudNativePG
- Encryption at rest
- Persistent Volume Claim (PVC)
- Configuration via a storage class
- Configuration via a PVC template
- Volume for WAL
- Volumes for tablespaces
- Volume expansion
- Static provisioning of persistent volumes
- Block storage considerations (Ceph/ Longhorn)
- Labels and annotations
- Monitoring
- Monitoring Instances
- Prometheus Operator example
- Predefined set of metrics
- User defined metrics
- Example of a user defined metric
- Example of a user defined metric running on multiple databases
- Structure of a user defined metric
- Output of a user defined metric
- Default set of metrics
- Differences with the Prometheus Postgres exporter
- Monitoring the operator
- How to inspect the exported metrics
- Auxiliary resources
- Monitoring Instances
- Logging
- Certificates
- Client TLS/SSL connections
- Connecting from an application
- Connection pooling
- Replica clusters
- Kubernetes Upgrade and Maintenance
- Exposing Postgres Services
- Kubectl Plugin
- Install
- Use
- Generation of installation manifests
- Status
- Promote
- Certificates
- Restart
- Reload
- Maintenance
- Report
- report Operator
- report Cluster
- Logs
- Cluster logs
- Destroy
- Cluster hibernation
- Benchmarking the database with pgbench
- Benchmarking the storage with fio
- Requesting a new physical backup
- Launching psql
- Snapshotting a Postgres cluster
- Using pgAdmin4 for evaluation/demonstration purposes only
- Logical Replication Publications
- Creating a new publication
- Dropping a publication
- Logical Replication Subscriptions
- Creating a new subscription
- Dropping a subscription
- Synchronizing sequences
- Integration with K9s
- Automated failover
- Troubleshooting
- Fencing
- Declarative hibernation
- PostGIS
- End-to-End Tests
- Container Image Requirements
- Operator capability levels
- Level 1: Basic install
- Operator deployment via declarative configuration
- PostgreSQL cluster deployment via declarative configuration
- Override of operand images through the CRD
- Labels and annotations
- Self-contained instance manager
- Storage configuration
- Replica configuration
- Database configuration
- Configuration of Postgres roles, users, and groups
- Pod security policies
- Affinity
- Topology spread constraints
- Command-line interface
- Current status of the cluster
- Operator’s certification authority
- Cluster’s certification authority
- TLS connections
- Certificate authentication for streaming replication
- Continuous configuration management
- Import of existing PostgreSQL databases
- PostGIS clusters
- Basic LDAP authentication for PostgreSQL
- Multiple installation methods
- Convention over configuration
- Level 2: Seamless upgrades
- Level 3: Full lifecycle
- PostgreSQL WAL archive
- PostgreSQL backups
- Backups from a standby
- Full restore from a backup
- Point-in-time recovery (PITR) from a backup
- Zero-data-loss clusters through synchronous replication
- Replica clusters
- Tablespace support
- Liveness and readiness probes
- Rolling deployments
- Scale up and down of replicas
- Maintenance window and PodDisruptionBudget for Kubernetes nodes
- Fencing
- Hibernation (declarative)
- Hibernation (imperative)
- Reuse of persistent volumes storage in pods
- CPU and memory requests and limits
- Connection pooling with PgBouncer
- Level 4: Deep insights
- Level 5: Auto pilot
- Level 1: Basic install
- Custom Pod Controller
- Examples
- Networking
- Benchmarking
- Commercial support
- Frequently Asked Questions (FAQ)
- API Reference
- Resource Types
- Backup
- Cluster
- ClusterImageCatalog
- ImageCatalog
- Pooler
- ScheduledBackup
- AffinityConfiguration
- AvailableArchitecture
- AzureCredentials
- BackupConfiguration
- BackupMethod
- BackupPhase
- BackupPluginConfiguration
- BackupSnapshotElementStatus
- BackupSnapshotStatus
- BackupSource
- BackupSpec
- BackupStatus
- BackupTarget
- BarmanCredentials
- BarmanObjectStoreConfiguration
- BootstrapConfiguration
- BootstrapInitDB
- BootstrapPgBaseBackup
- BootstrapRecovery
- CatalogImage
- CertificatesConfiguration
- CertificatesStatus
- ClusterSpec
- ClusterStatus
- CompressionType
- ConfigMapKeySelector
- ConfigMapResourceVersion
- DataBackupConfiguration
- DataSource
- DatabaseRoleRef
- EmbeddedObjectMetadata
- EncryptionType
- EnsureOption
- EphemeralVolumesSizeLimitConfiguration
- ExternalCluster
- GoogleCredentials
- ImageCatalogRef
- ImageCatalogSpec
- Import
- ImportSource
- InstanceID
- InstanceReportedState
- LDAPBindAsAuth
- LDAPBindSearchAuth
- LDAPConfig
- LDAPScheme
- LocalObjectReference
- ManagedConfiguration
- ManagedRoles
- Metadata
- MonitoringConfiguration
- NodeMaintenanceWindow
- OnlineConfiguration
- PasswordState
- PgBouncerIntegrationStatus
- PgBouncerPoolMode
- PgBouncerSecrets
- PgBouncerSpec
- PluginStatus
- PodTemplateSpec
- PodTopologyLabels
- PoolerIntegrations
- PoolerMonitoringConfiguration
- PoolerSecrets
- PoolerSpec
- PoolerStatus
- PoolerType
- PostInitApplicationSQLRefs
- PostgresConfiguration
- PrimaryUpdateMethod
- PrimaryUpdateStrategy
- RecoveryTarget
- ReplicaClusterConfiguration
- ReplicationSlotsConfiguration
- ReplicationSlotsHAConfiguration
- RoleConfiguration
- S3Credentials
- ScheduledBackupSpec
- ScheduledBackupStatus
- SecretKeySelector
- SecretVersion
- SecretsResourceVersion
- ServiceAccountTemplate
- ServiceTemplateSpec
- SnapshotOwnerReference
- SnapshotType
- StorageConfiguration
- SwitchReplicaClusterStatus
- SyncReplicaElectionConstraints
- SynchronizeReplicasConfiguration
- TablespaceConfiguration
- TablespaceState
- TablespaceStatus
- Topology
- VolumeSnapshotConfiguration
- WalBackupConfiguration
- Supported releases
- Release notes
- Appendixes
- Appendixes