Postgres Operator
Postgres Operator 基于 https://github.com/zalando/patroni 提供了在 Kubernetes (K8s) 上轻松运行高可用 https://www.postgresql.org/ 集群的能力。它仅通过 Postgres 清单(CRD)进行配置,无需直接访问 Kubernetes API 即可轻松集成到自动化 CI/CD 流水线中,推动基础设施即代码(infrastructure as code)而非手动操作。
Operator 特性
- Postgres 集群变更时的滚动更新,包括快速小版本更新
- 无需重启 Pod 即可动态调整卷大小(AWS EBS、PVC)
- 通过 PGBouncer 实现数据库连接池
- 支持快速原地大版本升级,支持所有集群的全局升级
- 引导阶段的 Pod 保护和可配置的维护窗口
- 在 AWS、GCS 和 Azure 上恢复和克隆 Postgres 集群
- 可配置到 S3 或 GCS 存储桶的逻辑备份
- 基于 S3 或 GCS WAL 归档的备用集群
- 可针对非云环境进行配置
- Kubernetes 上的基本凭证和用户管理,简化应用部署
- 支持自定义 TLS 证书
- 用于创建和编辑 Postgres 集群清单的 UI
- 与 OpenShift 兼容
PostgreSQL 特性
- 支持 PostgreSQL 18,从 14+ 开始
- 通过 Patroni 实现流式复制集群
- 使用 https://www.postgresql.org/docs/18/app-pgbasebackup.html 的时间点恢复(Point-In-Time-Recovery)
- 预加载库:https://github.com/CyberDem0n/bg_mon%E3%80%81https://www.postgresql.org/docs/18/pgstatstatements.html%E3%80%81https://github.com/dimitri/pgextwlist%E3%80%81https://github.com/RafiaSabih/pg_auth_mon
- 包括流行的 Postgres 扩展,如 https://github.com/debezium/postgres-decoderbufs%E3%80%81https://github.com/HypoPG/hypopg%E3%80%81https://github.com/citusdata/pg_cron%E3%80%81https://github.com/reorg/pg_repack%E3%80%81https://github.com/pgpartman/pg_partman%E3%80%81https://github.com/powa-team/pg_stat_kcache%E3%80%81https://github.com/pgaudit/pgaudit%E3%80%81https://github.com/cybertec-postgresql/pgfaceting%E3%80%81https://github.com/pgq/pgq%E3%80%81https://github.com/pgvector/pgvector%E3%80%81https://github.com/okbob/plpgsql_check%E3%80%81https://github.com/plproxy/plproxy%E3%80%81https://postgis.net/%E3%80%81https://github.com/ChenHuajun/pg_roaringbitmap%E3%80%81https://github.com/pgaudit/set_user 和 https://github.com/timescale/timescaledb
Postgres Operator 由 Zalando 开发,已在生产环境中使用超过五年。
支持的 Postgres 和 K8s 版本
| Release | Postgres 版本 | K8s 版本 | Golang |
|---|
| v1.15.1 | 13 → 17 | 1.27+ | 1.25.3 |
| v1.14.0 | 13 → 17 | 1.27+ | 1.23.4 |
| v1.13.0 | 12 → 16 | 1.27+ | 1.22.5 |
| v1.12.0 | 11 → 16 | 1.27+ | 1.22.3 |
| v1.11.0 | 11 → 16 | 1.27+ | 1.21.7 |
| v1.10.1 | 10 → 15 | 1.21+ | 1.19.8 |
快速开始
如需快速了解,请按照本 教程 中的说明操作。
Postgres 和应用的支持配置
文档
本文档的浏览器友好版本位于 https://postgres-operator.readthedocs.io
- 工作原理
- 安装
- K8s 上的 Postgres 使用体验
- Postgres Operator UI
- DBA 选项 - 从 RBAC 到备份
- 构建、调试和扩展 operator
- 配置选项
- Postgres 清单参考
- 命令行选项和环境变量