The Postgres Operator provides an easy-to-run high-availability PostgreSQL cluster on Top of Kubernetes (K8s) supported by the Patroni. It is configured only with Postgres Manifest (CRD) for easy integration into automated CI/CD pipelines without direct access to the Kubernetes API, facilitating infrastructure as code rather than manual operations.

  • Patroni: Github.com/zalando/pat…
  • PostgreSQL: www.postgresql.org/

Operator functions

  • PostgresRolling updates of cluster changes, including quick minor version updates
  • No need to rebootpodYou can adjust the real-time volume size (AWS EBS,PVC)
  • usePGBouncerPool database connections
  • supportPG13Fast upgrade. All clusters can be upgraded globally
  • Restore and clonePostgresCluster (including major version upgrades)
  • In addition, can be configured toS3Logical backup of buckets
  • fromS3 WALArchived standby cluster
  • It can be configured for non-cloud environments
  • K8sSimplifies application deployment with basic credentials and user management on
  • Support customizationTLScertificate
  • Create and editPostgresCluster manifestUI
  • inAmazon AWS,Google Cloud,OpenShiftKindGood local performance
  • supportAWS EBS gp2gp3Migration, supportiopsAnd throughput configuration

PostgreSQL function

  • supportPostgreSQL 14, from9.6 +start
  • throughPatroniStreaming replication cluster
  • throughSpilousepg_basebackup / WAL-EPerform point-in-time recovery (Point-In-Time-Recovery)
    • Spilo: Github.com/zalando/spi…
    • pg_basebackup: www.postgresql.org/docs/11/app…
    • WAL-E: github.com/wal-e/wal-e
  • Preloaded libraries:bg_mon.pg_stat_statements.pgextwlist.pg_auth_mon
    • bg_mon: Github.com/CyberDem0n/…
    • pg_stat_statements: www.postgresql.org/docs/14/pgs…
    • pgextwlist: Github.com/dimitri/pge…
    • pg_auth_mon: Github.com/RafiaSabih/…
  • Including. The popularPostgresExtension, for exampledecoderbufs.hypopg.pg_cron.pg_partman.pg_stat_kcache.pgq.plpgsql_check.postgis.set_user 和 timescaledb
    • decoderbufs: Github.com/debezium/po…
    • hypopg: Github.com/HypoPG/hypo…
    • pg_cron: Github.com/citusdata/p…
    • pg_partman: Github.com/pgpartman/p…
    • pg_stat_kcache: Github.com/powa-team/p…
    • pgq: github.com/pgq/pgq
    • plpgsql_check: Github.com/okbob/plpgs…
    • postgis: postgis.net/
    • set_user: Github.com/pgaudit/set…
    • timescaledb: Github.com/timescale/t…

The Postgres Operator was developed in Zalando and has been in production for more than three years.

Use a Spilo 12 or older image

If you are already using the Postgres operator with a Spilo 12 Docker image in older versions, you need to be aware of the backup path changes. We introduced the major version into the backup path to smooth out the major version upgrade that is now supported.

  • Major Version upgrade:Github.com/zalando/pos…

The new operator configuration can set the compatibility flag enable_SPILo_WAL_PATH_compat to cause Spilo to look for WAL segments in the current path, but also in the old format path. This comes at a potential performance cost and should be disabled after a few days.

The latest Spilo mirror is: registry. Opensource. Zalan. Do/acid/Spilo – walk. 1 – p4

The oldest Spilo mirror is: registry. Opensource. Zalan. Do/acid/Spilo – 12:1. 6 – (p5)

An introduction to

To get a quick first impression, follow the instructions in the getting started tutorial.

  • Introductory tutorial:Github.com/zalando/pos…

Supported Postgres and application Settings

concept

The Postgres operator manages a PostgreSQL cluster on Kubernetes (K8s) :

  1. operatormonitoringPostgreSQLAdd, update, and delete cluster listings, and change the running cluster accordingly. For example, when a user submits a new list,operatorGets the list and generates a new onePostgresClusters and all necessary entities, for exampleK8s StatefulSetsPostgresRole. See this for Settings that the listing might containPostgres Cluster list.
    • operator: Coreos.com/blog/introd…
    • Postgres cluster listing:Github.com/zalando/pos…
  2. operatorAlso monitor theIts configurationAnd change what is running if necessaryPostgresThe cluster. For example, ifpodIn theDockerIf the mirror image changes, thenoperatorPerform a rolling update, which means it will be updated with the newDockerThe image is re-generated one by one for each hostingStatefulSetpod.
    • Self-configuration:Github.com/zalando/pos…
  3. In the end,operatorRegularly add eachPostgresThe actual state of the cluster is synchronized with the required state defined in the cluster manifest.
  4. operatorThe goal is to free your hands, because configuration can only be done through a checklist. This can be easily integrated into an automated deployment pipeline without direct accessK8s.

scope

The Scope of the Postgres Operator is to provide, modify configuration, and clean up Postgres clusters using Patroni, basically for the ease and convenience of running patroni-based clusters on K8s. Configuration and modification includes K8s resources on one side, but also database and role configurations once the cluster is up and running. We try to leave the work to K8s and Patroni, especially cluster boot and high availability. However, operators need to participate in some general choreography, such as rolling updates to improve the user experience.

In the current state, it is not in the scope of operator to monitor or adjust Postgres. However, with a globally configurable Sidecar, we provide enough flexibility to complement other tools such as ZMON, Prometheus, or more Postgres specific options.

  • ZMON: opensource.zalando.com/zmon/
  • Prometheus: prometheus.io/

Overview of the entities involved

This is a diagram that summarizes what the operator will create when submitting the new Postgres Cluster CRD:

This diagram wouldn’t be complete without an overview of the inside of a single cluster pod, so let’s zoom in:

These two diagrams should help you understand the basics of the type of functionality provided by operator.

state

The project is currently under active development. However, Zalando already uses it internally to run a large number of Postgres clusters on K8s for staging environments and a growing number of production clusters. In this environment, operators are deployed across multiple K8s clusters, and users create listings either through our CI/CD infrastructure deployment checklists or by relying on a streamlined user interface.

  • Jobs.zalando.com/tech/blog/p…

Please report any problems you find to github.com/zalando/pos… .

Related video

  • “Take Care of your PostGIS Crowd” Talk by Felix Kunde, FOSS4G 2021:video | slides
    • www.youtube.com/watch?v=T96…
    • Docs.google.com/presentatio…
  • “PostgreSQL on Zalando K8S: Two Years in Production” Talk by Alexander Kukushkin, FOSSDEM 2020:video | slides
    • Fosdem.org/2020/schedu…
    • Fosdem.org/2020/schedu…
  • “Zalando’s Postgres as a Service “Talk by Jan Mußler, DevOpsDays Poznań 2019:video
    • www.youtube.com/watch?v=FiW…
  • “Build your own PostgreSQL as a Service on Kubernetes” Talk by Alexander Kukushkin, KubeCon NA 2018:video | slides
    • www.youtube.com/watch?v=G8M…
    • Static.sched.com/hosted_file…
  • PostgreSQL and Kubernetes: DBaaS Without Vendor Lock-in talk by Oleksii Kliukin, PostgreSQL Sessions 2018:video | slides
    • www.youtube.com/watch?v=q26…
    • Speakerdeck.com/alexeyklyuk…
  • “PostgreSQL High Availability using Patroni on Kubernetes” Talk by Oleksii Kliukin, Atmosphere 2018:video | slides
    • www.youtube.com/watch?v=cFl…
    • Speakerdeck.com/alexeyklyuk…
  • Talk by Oleksii Kliukin and Jan Mussler, FOSDEM 2018: Postgres + Kubernetesvideo | slides (pdf)
    • Fosdem.org/2018/schedu…
    • www.postgresql.eu/events/fosd…
  • “Kube-Native Postgres” talk by Josh Berkus, KubeCon 2017: video
    • www.youtube.com/watch?v=Zn1…

Related articles

  • “Zalando Operator for PostgreSQL “by Daniel Westermann ondbi services blog, Mar. 2021.
    • Blog.dbi-services.com/getting-sta…
  • “Zalando’s experience with the Postgres Operator for Kubernetes “by Nikolay Bogdanov onflant blog, Feb. 2021.
    • Blog.flant.com/our-experie…
  • “How to set up continuous backup and monitoring” by Pal Kristensen onGitHub, Mar. 2020.
    • Github.com/zalando/pos…
  • “Postgres on Kubernetes using Zalando Operator “by Vito Botta onhas_many :code, Feb. 2020.
    • Vitobotta.com/2020/02/05/…
  • “Running PostgreSQL in Google Kubernetes Engine” by Kenneth Rørvik onRepill Linpro blog, Sep. 2019.
    • www.redpill-linpro.com/techblog/20…
  • “Zalando Postgres Operator: One Year from now “by Sergey Dudoladov onOpen Source Zalando, Nov. 2018
    • Opensource.zalando.com/blog/2018/1…

More and more

  • Zalando Postgres Operator quick to get started