PostgreSQL operators for Kubernetes. How we chose the ideal option for organizing a DBaaS system

Some time ago in our cloud Amvera Cloud The task arose to organize the possibility of creating managed databases. The complexity of this task is that we need to deploy and manage thousands of PostgreSQL databases that provide replication, backups, monitoring and other functions useful to users. At the same time, the core of our system is Kubernetes, in which user applications are launched. And for a number of factors, we needed to run databases inside the cluster.

In order not to reinvent the wheel, we decided to look at well-known operators that allow you to deploy and manage PostgreSQL databases on Kubernetes.

Our review included the following solutions

Let's take a closer look at them.

  1. Crunchy Data PostgreSQL Operator

License – Apache 2.0

Number of stars on GitHub – 3600

Year of first release – 2017

Main functionality

Supports native installation in kubernetes clusters. Supports Pod Anti-Affinity, namely rules that can be used to specify which nodes/regions specific replicas should run on. There is support for backup clusters, which can work both within several clusters and between them.

Supports full, incremental and differentiated backups with the ability to auto-recover data, including delta recovery.

Monitoring using the pgMonitor library and Grafana.

Support for TLS encryption.

Update management.

Data cloning tool.

Expanded connection pooling support.

Configuring the deployment topology.

Support for backup functionality to S3-compatible storage.

Peculiarities

Supports a declarative approach and features such as database management using Kustomize, OLM, ArgoCD and Helm. Compatible with all major Kubernetes builds and services.

Link for the project

2.Stolon

License – Apache 2.0

Number of stars on GitHub – 4400

Year of first release – 2015

Main functionality

It is not a Kubernetes operator, but does have integration with Kubernetes. Supports replication, backups and other useful functions.

Peculiarities

Example architecture from official documentation

Link for the project

  1. Zalando Postgres Operator

License – MIT

Number of stars on GitHub – 3800

Year of first release – 2018

Main functionality

  • Consistent updates of Postgres cluster changes, incl. fast updates of minor versions

  • Resizing a live volume without restarting the module (AWS EBS, PVC)

  • Database Connection Pooling with PGBouncer

  • Support fast update of major version. Supports global update of all clusters.

  • Restore and clone Postgres clusters on AWS, GCS and Azure.

  • Additionally, you can configure logical backup to an S3 or GCS bucket.

  • Backup cluster from S3 or GCS WAL archive

  • Configurable for non-cloud environments

  • Basic credential and user management on K8s simplifies application deployment.

  • Support for custom TLS certificates.

  • User interface for creating and editing Postgres cluster manifests

  • AWS EBS gp2 to gp3 migration support, I/O support and throughput tuning.

  • OpenShift compatible.

  • Streaming replication cluster via Patroni

  • Point in time recovery using pg_basebackup/WAL-E via Spilo

Peculiarities

Solution architecture from the official documentation

  1. KubeDB

License – Apache 2.0, but not for all functionality

Number of stars on GitHub – 530

Year of first release – 2017

Main functionality

Supports not only PostgreSQL, but also MySQL, Elasticsearch, MySQL, MongoDB, Redis, Memcached.

Peculiarities

The special feature is dormantdatabases.kubedb.com resource. It protects against unintentional/incorrect actions: all deleted databases are archived and copied to this resource, so they can be restored if necessary.

Many features, including backups, connection pooling, snapshots, and inactive databases, are only available in the enterprise version. This significantly reduces the popularity of the product.

Link for the project

  1. StackGres

License – AGPLv3

Number of stars on GitHub – no, because they use GitLab

Year of first release – 2019

Main functionality

  • Creating clusters in Kubernetes

  • Log collection system

  • web panel similar to Zalando

  • monitoring system similar to Crunchy Data

  • backup aggregation system based on MinIO

Peculiarities

The operator does not support custom image builds or multiple additional containers for the database server. The Postgres module contains five containers.

From these, we can disable the metrics exporter, connection pool and container using additional tools.

Link for the project

  1. Сloudnative-pg

License – Apache 2.0

Number of stars on GitHub – 2700

First release year – 2022

Main functionality

Native support for Kubernetes with integration with API-Kubernetes.

CloudNativePG provides native cloud capabilities such as self-healing, high availability, rolling updates, read-only replica scaling, Anti-Affinity affinity/anti-affinity/scheduling tolerances, resource management, etc.

For security, TLS connections are used.

The solution supports physical replication. CloudNativePG uses stream replication and file replication as a fallback method. You can configure synchronous replication to obtain replicas with zero data loss.

Ability to restore to a specified timestamp.

Monitoring using Prometheus and Grafana.

Peculiarities

CloudNativePG relies solely on the Kubernetes API server and instance manager to coordinate complex operations. They should run on a PostgreSQL cluster without requiring any assistance from a middleware management tool responsible for high availability and failover. This sets CloudNativePG apart from its competitors.

Link for the project

Comparison table

Comparison

License

Stars on GitHub

Year of first release

Functional

Crunchy Data

Apache 2.0

3600

3600

Wide

Stolon

Apache 2.0

4400

4400

Narrow

Zalando Postgres Operator

MIT

380

2018

Wide

KubeDB

Apache 2.0

*not for everything

530

2017

Wide, additionally supports other DBMSs

StackGres

AGPLv3

2019

Average

Сloudnative-pg

Apache 2.0

2700

2022

Wide

Result: by a combination of factors, for yourself in Amvera Cloud We chose Cloudnative-pg, Zalando Postgres Operator and Crunchy Data PostgreSQL Operator for testing. And based on the test results, they began to use Cloudnative-pg to create their own managed-DBMS service with replication, backup and monitoring functionality.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *