cloudnative-pg/cloudnative-pg
GitHub: cloudnative-pg/cloudnative-pg
CloudNativePG 是一个 Kubernetes 原生的 PostgreSQL Operator,通过直接集成 K8s API 实现数据库全生命周期自动化管理,无需依赖外部高可用工具。
Stars: 8170 | Forks: 632
[][cncf-landscape]
[][latest-release]
[][license]
[][openssf]
[][openssf]
[][openssf-socrecard-view]
[][documentation]
[][stackoverflow]
[][fossa]
[](https://clomonitor.io/projects/cncf/cloudnative-pg)
[](https://artifacthub.io/packages/search?repo=cloudnative-pg)
# 欢迎来到 CloudNativePG 项目!
**CloudNativePG (CNPG)** 是一个开源平台,旨在
在 Kubernetes 环境中无缝管理 [PostgreSQL](https://www.postgresql.org/) 数据库。
它通过其核心组件 CloudNativePG operator 覆盖了整个操作生命周期——从部署到
持续维护。
## 目录
- [行为准则](CODE_OF_CONDUCT.md)
- [治理策略](https://github.com/cloudnative-pg/governance/blob/main/GOVERNANCE.md)
- [贡献](CONTRIBUTING.md)
- [采用者](ADOPTERS.md)
- [商业支持](https://cloudnative-pg.io/support/)
- [许可证](LICENSE)
## 快速入门
入门的最佳方式是查看 [快速入门指南](https://cloudnative-pg.io/docs/devel/quickstart/)。
## 范围
### 使命
CloudNativePG 旨在通过使 PostgreSQL 成为开发流程和 GitOps 驱动的 CI/CD
自动化不可或缺的一部分,来增加 PostgreSQL 在 Kubernetes 中的采用。
### 核心原则与特性
CloudNativePG 由 PostgreSQL 专家为 Kubernetes 管理员设计,遵循
Kubernetes 原生方法进行 PostgreSQL 主/备集群管理。它不依赖外部高可用
工具(如 Patroni、repmgr 或 Stolon),而是直接与 Kubernetes API 集成,
以自动执行熟练 DBA 会手动完成的数据库操作。
关键设计决策包括:
- 与 Kubernetes API 直接集成:PostgreSQL 集群的状态
直接在 `Cluster` 资源中可用,允许用户
通过 Kubernetes API 进行检查。
- Operator 模式:operator 确保自动协调所需的 PostgreSQL 状态,
遵循 Kubernetes 最佳实践。
- 不可变应用容器:更新遵循不可变基础设施
模型,如
["Why EDB Chose Immutable Application Containers"](https://www.enterprisedb.com/blog/why-edb-chose-immutable-application-containers) 中所述。
### CloudNativePG 如何工作
operator 持续监控并更新 PostgreSQL 集群状态。
自动操作的示例包括:
- 故障转移管理:如果主实例发生故障,operator 会选出新的
主实例,更新集群状态,并协调转换过程。
- 扩展读副本:当所需的副本数量发生变化时,operator 会
在管理流复制的同时,配置或移除持久卷、secrets
和 config maps 等资源。
- 服务更新:Kubernetes 始终是唯一的真实来源,确保
PostgreSQL 服务端点始终保持最新。
- 滚动更新:当镜像更新时,operator 遵循滚动
策略——首先更新副本 pod,然后再对主实例执行受控的
切换。
CloudNativePG 管理额外的 Kubernetes 资源以增强 PostgreSQL
管理,包括:`Backup`、`ClusterImageCatalog`、`Database`、
`ImageCatalog`、`Pooler`、`Publication`、`ScheduledBackup` 和 `Subscription`。
## 不在范围内
- **仅限 Kubernetes:** CloudNativePG 专注于由
[Cloud Native Computing Foundation (CNCF)](https://kubernetes.io/) 维护的 vanilla Kubernetes。
- **仅限 PostgreSQL:** CloudNativePG 专注于由
[PostgreSQL Global Development Group (PGDG)](https://www.postgresql.org/about/) 维护的 vanilla PostgreSQL。
- **不支持分支:** 只有当 PostgreSQL 分支的功能可以作为扩展或可插拔框架集成时,才会
被考虑。
- **非通用数据库 operator:** CloudNativePG 不支持
其他数据库(例如 MariaDB)。
CloudNativePG 可以通过 [CNPG-I plugin interface](https://github.com/cloudnative-pg/cnpg-i) 进行扩展。
## 交流
- [Github Discussions](https://github.com/cloudnative-pg/cloudnative-pg/discussions)
- [Slack](https://cloud-native.slack.com/archives/C08MAUJ7NPM)
(加入 [CNCF Slack Workspace](https://communityinviter.com/apps/cloud-native/cncf))。
- [Twitter](https://twitter.com/CloudNativePg)
- [Mastodon](https://mastodon.social/@CloudNativePG)
- [Bluesky](https://bsky.app/profile/cloudnativepg.bsky.social)
## 资源
- [路线图](ROADMAP.md)
- [网站](https://cloudnative-pg.io)
- [FAQ](docs/src/faq.md)
- [博客](https://cloudnative-pg.io/blog/)
- [CloudNativePG plugin Interface (CNPG-I)](https://github.com/cloudnative-pg/cnpg-i)。
## 采用者
CloudNativePG operator 的公开已知用户列表位于 [ADOPTERS.md](ADOPTERS.md)。
通过将您自己和您的组织添加到此列表,帮助我们发展社区和 CloudNativePG!
### KubeCon 上的 CloudNativePG
- 2025 年 11 月 10 日,亚特兰大 KubeCon North America 2025:["Project Lightning Talk: CloudNativePG: Running Postgres The Kubernetes Way"](https://www.youtube.com/watch?v=pYwYwehQX3U&t=4s) - Gabriele Bartolini, EDB
- 2025 年 11 月 11 日,亚特兰大 KubeCon North America 2025:["Modern PostgreSQL Authorization With Keycloak: Cloud Native Identity Meets Database Security"](https://www.youtube.com/watch?v=TYgPemq06fg) - Yoshiyuki Tabata, Hitachi, Ltd. & Gabriele Bartolini, EDB
- 2025 年 11 月 13 日,亚特兰大 KubeCon North America 2025:["Quorum-Based Consistency for Cluster Changes With CloudNativePG Operator"](https://www.youtube.com/watch?v=iQUOO3-JRK4&list=PLj6h78yzYM2MLSW4tUDO2gs2pR5UpiD0C&index=67) - Jeremy Schneider, GEICO Tech & Gabriele Bartolini, EDB
- 2025 年 4 月 4 日,伦敦 KubeCon Europe:["Consistent Volume Group Snapshots, Unraveling the Magic"](https://sched.co/1tx8g) - Leonardo Cecchi (EDB) and Xing Yang (VMware)
- 2024 年 11 月 11 日,Cloud Native Rejekts NA 2024:["Maximising Microservice Databases with Kubernetes, Postgres, and CloudNativePG"](https://www.youtube.com/watch?v=uBzl_stoxoc&ab_channel=CloudNativeRejekts) - Gabriele Bartolini (EDB) and Leonardo Cecchi (EDB)
- 2024 年 3 月 21 日,巴黎 KubeCon Europe 2024:["Scaling Heights: Mastering Postgres Database Vertical Scalability with Kubernetes Storage Magic"](https://kccnceu2024.sched.com/event/1YeM4/scaling-heights-mastering-postgres-database-vertical-scalability-with-kubernetes-storage-magic-gabriele-bartolini-edb-gari-singh-google) - Gari Singh, Google & Gabriele Bartolini, EDB
- 2024 年 3 月 19 日,巴黎 KubeCon Europe 2024 的 Data on Kubernetes Day:["From Zero to Hero: Scaling Postgres in Kubernetes Using the Power of CloudNativePG"](https://colocatedeventseu2024.sched.com/event/1YFha/from-zero-to-hero-scaling-postgres-in-kubernetes-using-the-power-of-cloudnativepg-gabriele-bartolini-edb) - Gabriele Bartolini, EDB
- 2023 年 11 月 7 日,芝加哥 KubeCon North America 2023:["Disaster Recovery with Very Large Postgres Databases (in Kubernetes)"](https://kccncna2023.sched.com/event/1R2ml/disaster-recovery-with-very-large-postgres-databases-gabriele-bartolini-edb-michelle-au-google) - Michelle Au, Google & Gabriele Bartolini, EDB
- 2022 年 10 月 27 日,底特律 KubeCon North America 2022:["Data On Kubernetes, Deploying And Running PostgreSQL And Patterns For Databases In a Kubernetes Cluster"](https://kccncna2022.sched.com/event/182GB/data-on-kubernetes-deploying-and-running-postgresql-and-patterns-for-databases-in-a-kubernetes-cluster-chris-milsted-ondat-gabriele-bartolini-edb) - Chris Milsted, Ondat & Gabriele Bartolini, EDB
### 有用的链接
- ["Quorum-Based Consistency for Cluster Changes With CloudNativePG Operator"](https://www.youtube.com/watch?v=sRF09UMAlsI) (网络研讨会) - Jeremy Schneider, GEICO Tech & Leonardo Cecchi, EDB
- [Data on Kubernetes (DoK) Community](https://dok.community/)
- ["Cloud Neutral Postgres Databases with Kubernetes and CloudNativePG" by Gabriele Bartolini](https://www.cncf.io/blog/2024/11/20/cloud-neutral-postgres-databases-with-kubernetes-and-cloudnativepg/) (2024 年 11 月)
- ["How to migrate your PostgreSQL database in Kubernetes with ~0 downtime from anywhere" by Gabriele Bartolini](https://gabrielebartolini.it/articles/2024/03/cloudnativepg-recipe-5-how-to-migrate-your-postgresql-database-in-kubernetes-with-~0-downtime-from-anywhere/) (2024 年 3 月)
- ["Maximizing Microservice Databases with Kubernetes, Postgres, and CloudNativePG" by Gabriele Bartolini](https://gabrielebartolini.it/articles/2024/02/maximizing-microservice-databases-with-kubernetes-postgres-and-cloudnativepg/) (2024 年 2 月)
- ["Recommended Architectures for PostgreSQL in Kubernetes" by Gabriele Bartolini](https://www.cncf.io/blog/2023/09/29/recommended-architectures-for-postgresql-in-kubernetes/) (2023 年 9 月)
- ["The Current State of Major PostgreSQL Upgrades with CloudNativePG" by Gabriele Bartolini](https://www.enterprisedb.com/blog/current-state-major-postgresql-upgrades-cloudnativepg-kubernetes) (2023 年 8 月)
- ["The Rise of the Kubernetes Native Database" by Jeff Carpenter](https://thenewstack.io/the-rise-of-the-kubernetes-native-database/) (2022 年 12 月)
- ["Why Run Postgres in Kubernetes?" by Gabriele Bartolini](https://cloudnativenow.com/kubecon-cnc-eu-2022/why-run-postgres-in-kubernetes/) (2022 年 5 月)
- ["Shift-Left Security: The Path To PostgreSQL On Kubernetes" by Gabriele Bartolini](https://www.tfir.io/shift-left-security-the-path-to-postgresql-on-kubernetes/) (2021 年 4 月)
- ["Local Persistent Volumes and PostgreSQL usage in Kubernetes" by Gabriele Bartolini](https://www.2ndquadrant.com/en/blog/local-persistent-volumes-and-postgresql-usage-in-kubernetes/) (2020 年 6 月)
我们是 Cloud Native Computing Foundation 沙箱项目。
CloudNativePG 最初由 EDB 构建并赞助。
Postgres、PostgreSQL 和 Slonik Logo 是 PostgreSQL Community Association of Canada 的商标或注册商标, 并经其许可使用。
标签:CNCF, Database-as-a-Service, DBA工具, DNS解析, EVTX分析, NIDS, Operator, PostgreSQL, SQL, web渗透, 备份恢复, 子域名突变, 存储解决方案, 容器化, 开源项目, 提示注入, 数据库管理, 数据持久化, 日志审计, 测试用例, 系统审计, 自动化运维, 请求拦截, 集群管理