The Postgres operator
manages PostgreSQL clusters on Kubernetes (K8s):
Postgres Operator 管理 Kubernetes (K8s) 上的 PostgreSQL 集群:
-
The operator watches additions, updates, and deletions of PostgreSQL cluster manifests and changes the running clusters accordingly. For example, when a user submits a new manifest, the operator fetches that manifest and spawns a new Postgres cluster along with all necessary entities such as K8s StatefulSets and Postgres roles. See this Postgres cluster manifest for settings that a manifest may contain.\
- operator监视PostgreSQL集群清单的添加、更新和删除,并相应地更改正在运行的集群。 例如,当用户提交新的清单时,操作员会获取该清单并生成一个新的 Postgres 集群以及所有必要的实体(例如 K8s StatefulSets 和 Postgres 角色)。请参阅此 Postgres集群清单了解清单可能包含的设置。
-
The operator also watches updates to its own configuration and alters running Postgres clusters if necessary. For instance, if the Docker image in a pod is changed, the operator carries out the rolling update, which means it re-spawns pods of each managed StatefulSet one-by-one with the new Docker image.
2. Operator 还会监视其自身配置 的更新,并在必要时更改正在运行的 Postgres 集群。 例如,如果 Pod 中的 Docker 镜像发生更改,Operator 会执行滚动更新,这意味着它会使用新的 Docker 镜像一一重新生成每个托管 StatefulSet 的 Pod。 -
Finally, the operator periodically synchronizes the actual state of each Postgres cluster with the desired state defined in the cluster's manifest.
3. 最后,operator定期同步各个节点的实际状态。Postgres 集群具有集群清单中定义的所需状态。 -
The operator aims to be hands free as configuration works only via manifests. This enables easy integration in automated deploy pipelines with no access to K8s directly.
4. operator的目标是解放双手,因为配置只能通过清单进行。这使得可以轻松集成到自动化部署管道中,而无需直接访问 K8。
The scope of the Postgres Operator is on provisioning, modifying configuration
and cleaning up Postgres clusters that use Patroni, basically to make it easy
and convenient to run Patroni based clusters on K8s. The provisioning
and modifying includes K8s resources on one side but also e.g. database
and role provisioning once the cluster is up and running. We try to leave as
much work as possible to K8s and to Patroni where it fits, especially
the cluster bootstrap and high availability. The operator is however involved
in some overarching orchestration, like rolling updates to improve the user
experience.
Postgres Operator 的作用范围包括提供、修改配置和清理使用 Patroni 的 Postgres 集群,基本上是为了让在 K8s 上运行基于 Patroni 的集群变得简单方便。提供和修改包括 K8s 资源的一侧,但也包括例如数据库和角色提供,一旦集群启动并运行。我们尽量将尽可能多的工作留给 K8s 和 Patroni,特别是在集群引导和高可用性方面。然而,该操作员也参与一些全局编排,如滚动更新以改善用户体验。
Monitoring or tuning Postgres is not in scope of the operator in the current
state. However, with globally configurable sidecars we provide enough
flexibility to complement it with other tools like ZMON,
Prometheus or more Postgres specific options.
监控或调整 Postgres 不在当前操作员的范围内。然而,通过全局可配置的sidecars,我们提供了足够的灵活性,可以与其他工具如[ZMON]、[Prometheus]或更多针对 Postgres 的特定选项相补充。
Here is a diagram, that summarizes what would be created by the operator, when a new Postgres cluster CRD is submitted:
This picture is not complete without an overview of what is inside a single cluster pod, so let's zoom in:
These two diagrams should help you to understand the basics of what kind of functionality the operator provides.
This project is currently in active development. It is however already
used internally by Zalando
in order to run Postgres clusters on K8s in larger numbers for staging
environments and a growing number of production clusters. In this environment
the operator is deployed to multiple K8s clusters, where users deploy
manifests via our CI/CD infrastructure or rely on a slim user interface to
create manifests.
该项目目前正在积极开发中。然而,它已经[被 Zalando 内部使用],以便在 K8 上大量运行 Postgres 集群临时环境和越来越多的生产集群。在此环境中,操作员部署到多个 K8s 集群,用户通过我们的 CI/CD 基础设施部署清单或依靠精简的用户界面来创建清单。
Please, report any issues discovered to https://github.com/zalando/postgres-operator/issues.
-
"Watching after your PostGIS herd" talk by Felix Kunde, FOSS4G 2021: video | slides
-
"PostgreSQL on K8S at Zalando: Two years in production" talk by Alexander Kukushkin, FOSSDEM 2020: video | slides
-
"Postgres as a Service at Zalando" talk by Jan Mußler, DevOpsDays Poznań 2019: video
-
"Building your own PostgreSQL-as-a-Service on Kubernetes" talk by Alexander Kukushkin, KubeCon NA 2018: video | slides
-
"PostgreSQL and Kubernetes: DBaaS without a vendor-lock" talk by Oleksii Kliukin, PostgreSQL Sessions 2018: video | slides
-
"PostgreSQL High Availability on Kubernetes with Patroni" talk by Oleksii Kliukin, Atmosphere 2018: video | slides
-
"Blue elephant on-demand: Postgres + Kubernetes" talk by Oleksii Kliukin and Jan Mussler, FOSDEM 2018: video | slides (pdf)
-
"Kube-Native Postgres" talk by Josh Berkus, KubeCon 2017: video
-
Series of blog posts on how to use the Zalando Operator, configure backups and use etcd as DCS by thedatabaseme, Mar. 2022-23.
-
"Zalando Postgres Operator in Production: the way of Helm" by Zangir Kapishov on medium, Jan. 2023.
-
"Chaos testing of a Postgres cluster managed by the Zalando Postgres Operator" by Nikolay Sivko on coroot, Aug. 2022.
-
"Getting started with the Zalando Operator for PostgreSQL" by Daniel Westermann on dbi services blog, Mar. 2021.
-
"Our experience with Postgres Operator for Kubernetes by Zalando" by Nikolay Bogdanov on Palark blog, Feb. 2021.
-
"How to set up continuous backups and monitoring" by Pål Kristensen on GitHub, Mar. 2020.
-
"Postgres on Kubernetes with the Zalando operator" by Vito Botta on has_many :code, Feb. 2020.
-
"Running PostgreSQL in Google Kubernetes Engine" by Kenneth Rørvik on Repill Linpro blog, Sep. 2019.
-
"Zalando Postgres Operator: One Year Later" by Sergey Dudoladov on Open Source Zalando, Nov. 2018