云原生PostgreSQL集群-PGO:来自CrunchyData的PostgresOperator

博客 分享
0 218
优雅殿下
优雅殿下 2022-02-23 12:55:42
悬赏:0 积分 收藏

云原生 PostgreSQL 集群 - PGO:来自 Crunchy Data 的 Postgres Operator

使用 PGOKubernetes 上运行 Cloud Native PostgreSQL:来自 Crunchy DataPostgres Operator

  • Cloud Native PostgreSQL
    • https://www.crunchydata.com/products/crunchy-postgresql-for-kubernetes/
  • Crunchy Data
    • https://www.crunchydata.com/
  • Postgres Operator
    • https://github.com/CrunchyData/postgres-operator

PGO 是由 Crunchy Data 开发并包含在 Crunchy PostgreSQL for Kubernetes 中的 Postgres Operator,可自动化并简化在 Kubernetes 上部署和管理开源 PostgreSQL 集群。

  • Crunchy PostgreSQL for Kubernetes
    • https://www.crunchydata.com/products/crunchy-postgresql-for-kubernetes/

无论您是需要启动并运行一个简单的 Postgres 集群,还是需要在生产中部署一个高可用性、容错群集群,或者是运行自己的数据库即服务(database-as-a-service)PostgreSQL Operator 都提供了保持云原生 Postgres 集群健康所需的基本功能,包括:

Postgres 集群供应

轻松创建、扩展和删除 PostgreSQL 集群,同时完全自定义您的 PodPostgreSQL 配置!

  • provisioning
    • https://crunchydata.github.io/postgres-operator/latest/architecture/provisioning/
  • 轻松创建、扩展和删除 PostgreSQL 集群
    • https://crunchydata.github.io/postgres-operator/latest/tutorial/create-cluster/

高可用性

由基于分布式共识的高可用性解决方案支持的安全、自动故障转移。使用 Pod Anti-Affinity 来帮助恢复;您可以配置它的 aggressive! 失败的初选会自动恢复,从而加快恢复时间。

  • 高可用性
    • https://crunchydata.github.io/postgres-operator/latest/architecture/high-availability/
  • Pod Anti-Affinity
    • https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#inter-pod-affinity-and-anti-affinity

支持在多个 Kubernetes 集群中工作的备用 PostgreSQL 集群

  • 多个 Kubernetes 集群
    • https://crunchydata.github.io/postgres-operator/latest/architecture/high-availability/multi-cluster-kubernetes/

灾难恢复

备份和恢复利用开源 pgBackRest 实用程序,包括对完整、增量和差异备份以及高效增量恢复的支持。 设置您希望备份保留多长时间。适用于非常大的数据库!

  • 灾难恢复
    • https://crunchydata.github.io/postgres-operator/latest/architecture/disaster-recovery/

TLS

通过为 PostgreSQL 服务器启用 TLS 来保护应用程序和数据服务器之间的通信,包括强制所有连接使用 TLS 的能力。

  • PostgreSQL 服务器启用 TLS
    • https://crunchydata.github.io/postgres-operator/latest/tutorial/tls/

监控

使用开源 pgMonitor 库跟踪 PostgreSQL 集群的运行状况。

  • 监控
    • https://crunchydata.github.io/postgres-operator/latest/architecture/monitoring/
  • pgMonitor
    • https://github.com/CrunchyData/pgmonitor

PostgreSQL 用户管理

使用强大的命令从您的 PostgreSQL 集群中快速添加和删除用户。 管理密码过期策略或使用您首选的 PostgreSQL 身份验证方案。

升级管理

以最小的可用性影响安全地应用 PostgreSQL 更新到您的 PostgreSQL 集群。

高级复制支持

对于对丢失事务敏感的工作负载,可以在异步复制同步复制之间进行选择。

  • 异步复制
    • https://crunchydata.github.io/postgres-operator/latest/architecture/high-availability/
  • 同步复制
    • https://crunchydata.github.io/postgres-operator/latest/architecture/high-availability/#synchronous-replication-guarding-against-transactions-loss

克隆

使用 pgo create cluster --restore-from 从现有集群或备份创建新集群。

连接池

使用 pgBouncer 进行连接池。

  • pgBouncer
    • https://crunchydata.github.io/postgres-operator/latest/tutorial/pgbouncer/

K8S 亲和力和容忍度

使用 node affinity(节点亲和性) 将 PostgreSQL 集群部署到您偏好的 Kubernetes 节点,或者指定 Kubernetes 可以将 PostgreSQL 实例调度到哪些节点并具有 tolerations(容忍度)。

  • node affinity
    • https://crunchydata.github.io/postgres-operator/latest/architecture/high-availability/#node-affinity
  • Kubernetes 节点
    • https://kubernetes.io/docs/concepts/architecture/nodes/
  • tolerations(容忍度)
    • https://crunchydata.github.io/postgres-operator/latest/architecture/high-availability/#tolerations

定期备份

选择备份类型(完整、增量、差异)以及您希望它在每个 PostgreSQL 集群上发生的频率。

  • scheduling-backups
    • https://crunchydata.github.io/postgres-operator/latest/architecture/disaster-recovery/#scheduling-backups

备份到 S3 或 GCS

将您的备份存储在 Amazon S3、任何支持 S3 协议的对象存储系统或 GCS 中。PostgreSQL Operator 可以从这些备份中备份、恢复和创建新集群。

  • 将您的备份存储在 Amazon S3
    • https://crunchydata.github.io/postgres-operator/latest/architecture/disaster-recovery/#using-s3
  • GCS
    • https://crunchydata.github.io/postgres-operator/latest/architecture/disaster-recovery/#using-gcs

多命名空间支持

您可以控制 PGO(Postgres Operator) 如何利用具有多种不同部署模型的 Kubernetes 命名空间:

  • PGO 和所有 PostgreSQL 集群部署到同一个命名空间
  • PGO 部署到一个命名空间,并将所有 PostgreSQL 集群部署到不同的命名空间
  • PGO 部署到一个命名空间,并跨多个命名空间管理 PostgreSQL 集群
  • 使用 pgo 客户端运行 pgo create namespacepgo delete namespace 动态添加和删除由 PostgreSQL Operator 管理的命名空间

Kubernetes 命名空间

  • https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/

完全可定制性

Postgres Operator(PGO) 使 Postgres 在支持 Kubernetes 的平台上启动和运行变得容易,但也可以进行进一步的自定义。因此,PGO 允许您进一步自定义您的部署,包括:

  • 为主存储、副本存储和备份存储选择不同的存储类
  • 为每个 PostgreSQL 集群部署选择自己的容器资源类; 区分用于主集群和副本集群的资源!
  • 使用自己的容器镜像仓库,包括支持 imagePullSecrets 和私有仓库
  • 自定义您的 PostgreSQL 配置
    • https://crunchydata.github.io/postgres-operator/latest/advanced/custom-configuration/
  • 带上您自己的受信任证书颁发机构 (CA) 以与 Operator API server 一起使用
  • 覆盖每个集群的 PostgreSQL 配置

工作原理

Crunchy PostgreSQL Operator 扩展了 Kubernetes,为快速创建和管理 PostgreSQL 集群提供更高级别的抽象。Crunchy PostgreSQL Operator 利用称为 “自定义资源(Custom Resources)”Kubernetes 概念来创建多个自定义资源定义 (CRD),以允许管理 PostgreSQL 集群。

包含的组件

使用 PostgreSQL Operator 部署的 PostgreSQL 容器包括以下组件:

  • PostgreSQL
    • PostgreSQL Contrib Modules
      • https://www.postgresql.org/docs/current/contrib.html
    • PL/Python + PL/Python 3
      • https://www.postgresql.org/docs/current/plpython.html
    • PL/Perl
      • https://www.postgresql.org/docs/current/plperl.html
    • pgAudit
      • https://www.pgaudit.org/
    • pgAudit Analyze
      • https://github.com/pgaudit/pgaudit_analyze
    • pgnodemx
      • https://github.com/CrunchyData/pgnodemx
    • pg_cron
      • https://github.com/citusdata/pg_cron
    • pg_partman
      • https://github.com/pgpartman/pg_partman
    • set_user
      • https://github.com/pgaudit/set_user
    • TimescaleDB (Apache 2 edition)
      • https://github.com/timescale/timescaledb
    • wal2json
      • https://github.com/eulerto/wal2json
  • pgBackRest
    • https://pgbackrest.org/
  • pgBouncer
    • http://pgbouncer.github.io/
  • pgAdmin 4
    • https://www.pgadmin.org/
  • pgMonitor
    • https://github.com/CrunchyData/pgmonitor
  • Patroni
    • https://patroni.readthedocs.io/
  • LLVM (for JIT compilation)
    • https://llvm.org/
    • https://www.postgresql.org/docs/current/jit.html

除上述内容外,地理空间增强的 PostgreSQL + PostGIS 容器还添加了以下组件:

  • PostGIS
    • http://postgis.net/
  • pgRouting
    • https://pgrouting.org/
  • PL/R
    • https://github.com/postgres-plr/plr

PostgreSQL Operator Monitoring 使用以下组件:

  • pgMonitor
    • https://github.com/CrunchyData/pgmonitor
  • Prometheus
    • https://github.com/prometheus/prometheus
  • Grafana
    • https://github.com/grafana/grafana
  • Alertmanager
    • https://github.com/prometheus/alertmanager

未直接与 PostgreSQL Operator 集成但可以与其一起工作的其他容器包括:

  • pgPool II
    • https://access.crunchydata.com/documentation/crunchy-postgres-containers/latest/container-specifications/crunchy-pgpool/
  • pg_upgrade
    • https://access.crunchydata.com/documentation/crunchy-postgres-containers/latest/container-specifications/crunchy-upgrade/
  • pgBench
    • https://access.crunchydata.com/documentation/crunchy-postgres-containers/latest/container-specifications/crunchy-pgbench/

有关 PostgreSQL Operator 的哪些版本包含哪些组件的更多信息,请访问文档的兼容性部分。

  • https://crunchydata.github.io/postgres-operator/latest/configuration/compatibility/

支持的平台

PGOPostgres Operator,是 Kubernetes-native 的,并保持与 Kubernetes 1.11 的向后兼容性,并针对以下平台进行了测试:

  • Kubernetes 1.17+
  • Openshift 4.4+
  • OpenShift 3.11
  • Google Kubernetes Engine (GKE), including Anthos
  • Amazon EKS
  • Microsoft AKS
  • VMware Tanzu

此列表仅包括 Postgres Operator 在发布过程中经过专门测试的平台:PGO 也适用于其他 Kubernetes 发行版。

存储

PGO,即 Postgres Operator,使用各种不同类型的 Kubernetes 存储和 Storage Classes 以及 hostPathNFS 进行了测试。

有各种不同类型的 Storage Class 可供 Kubernetes 使用,PGO 尽最大努力测试每一个,但由于这一领域的广度,PGO 无法验证每一类中的 Postgres Operator 功能。尽管如此,PostgreSQL Operator 被设计为与存储类无关,并已被证明可以与其他存储类一起工作。

公众号:黑客下午茶
posted @ 2022-02-23 12:23 为少 阅读(1) 评论(0) 编辑 收藏 举报
回帖
    优雅殿下

    优雅殿下 (王者 段位)

    2018 积分 (2)粉丝 (47)源码

    小小码农,大大世界

     

    温馨提示

    亦奇源码

    最新会员