K8s上的数据库私有云之旅:KubeBlocks架构设计与实践

如果无法正常显示,请先停止浏览器的去广告插件。
分享至:
1. K8s上的数据库私有云之旅: KubeBlocks架构设计与实践 曹伟丨 云猿生数据创始人 / CEO
2.
3. 演讲者:曹伟 云猿生数据创始人 / CEO 前阿里云数据库总经理(研究员),阿里云RDS的架 构师,云原生数据库PolarDB创始人。中国计算机学 会数据库专委会、开源专委会执行专委,获得 2020 年中国电子学会科技进步一等奖,在 SIGMOD、 VLDB、ICDE、FAST、USENIX ATC 等数据库与存 储国际顶级学术会议发表论文 20 余篇。
4. 内容大纲 • 公共云、私有云,K8s和数据库的演进趋势 • dbPaaS的挑战 • KubeBlocks的设计理念及核心特点 • 数据库容器化的常见问题 • 数据库私有云平台案例
5. 数据库行业发展方向 Serverless 适合小规模且难以预测的负载 公共云全托管 适合中小型规模且波动较为规律的负载 On-Prem 适合中大型规模且波动较为规律的负载
6. 公有云 vs. 私有云的选择 合规性要求 内因 成本控制 定制化和可控性 外因 云原生和K8s技术的发展
7. 趋势一 私有云正在从 时代全面进化到
8. 趋势二 K8s 发展带动 技术水平追赶
9. 趋势三 K8s 正在统一公共云和私有云的
10. K8s: 构建 PaaS 的基础 业务层 PaaS层 App Workflow Middleware CI/CD Big Data AI IaaS透明 调度器 K8s 服务发现 POD service PVC/PV secret configmap Taint Toleration Affinity Anti-Affinity event ACK EKS GKE AKS OpenShift Rancher 阿里云 AWS GCP Azure 物理机 配置管理 声明式API
11. K8s PaaS 全景图里还缺最后一块:
12. dbPaaS的挑战 数据库种类太多 运维操作复杂 研发和运维 人力不足
13. 陷阱:烟囱式架构 运 维 操 作 HA 备份恢复 容灾 账号 扩缩容 授权 迁移 监控报警 升级 开发和维护成本高 审计 引入新引擎成本高 引 擎 环 境 MySQL PG Redis MongoDB ClickHouse, ES, Kafka, …… 调度 网络 存储 虚拟机 物理机 容器
14. 数据库容器化后 能不能像 一样在K8s上进行管理呢?
15. 首先思考:如何解决软件工程复杂性问题 文件系统的模型 K8s扩展的模型 抽象 网络系统的模型 分层 抽象 APP POSIX - open() - read() - write() System call VFS ext4 nfs xfs fus e zfs s3f s CRI CSI CNI
16. KubeBlocks通过抽象和分层管理数据库 KubeBlocks Operator实现 kbcli Cluster Controller Component Controller InstanceSet Controller …… KubeBlocks API Addon API Cluster ClusterDefintion Component ComponentDefinition ComponentVersion InstanceSet KubeBlocks Cloud KubeBlocks Addons Instance K8s API Pod Service PVC Secret Configmap … ……
17. KubeBlocks通过抽象和分层管理数据库 KubeBlocks Operator实现 Cluster Controller Component Controller KubeBlocks API:数据库容器化的标准 InstanceSet Controller kbcli KubeBlocks API Addon API Cluster ClusterDefintion Component ComponentDefinition ComponentVersion InstanceSet KubeBlocks Cloud …… KubeBlocks Addons Instance K8s API Pod Service PVC Secret Configmap … ……
18. KubeBlocks通过抽象和分层管理数据库 KubeBlocks Operator实现 数据库引擎无关的 Operator实现 kbcli Cluster Controller Component Controller InstanceSet Controller …… KubeBlocks API Addon API Cluster ClusterDefintion Component ComponentDefinition ComponentVersion InstanceSet KubeBlocks Cloud KubeBlocks Addons Instance K8s API Pod Service PVC Secret Configmap … ……
19. KubeBlocks通过抽象和分层管理数据库 KubeBlocks Operator实现 kbcli Cluster Controller Component Controller InstanceSet Controller …… KubeBlocks API Addon API Cluster ClusterDefintion Component ComponentDefinition ComponentVersion InstanceSet KubeBlocks Cloud KubeBlocks Addons Instance K8s API Pod Service PVC Secret Configmap … ……
20. 把KubeBlocks API映射到数据库 – MySQL Cluster: MySQL Component: Proxy Component: MySQL Component: Orchestrator InstanceSet InstanceSet InstanceSet Instance Instance Instance Instance Instance Instance Instance Instance Pod Service Pod PVC Service Pod Service
21. 把KubeBlocks API映射到数据库 – Redis主备 Cluster: Redis Component: Redis Component: Sentinel InstanceSet InstanceSet Instance Instance Instance Instance Instance Pod Service Pod Service
22. 把KubeBlocks API映射到数据库 – Redis集群 Cluster: RedisCluster Component: Redis Component: Redis Component: Redis Component: Redis Component: Redis InstanceSet InstanceSet InstanceSet InstanceSet InstanceSet Instance Instance Instance Instance Instance Instance Instance Instance Instance Instance Pod Service Pod Service Pod Service Pod Service Pod Service
23. 把KubeBlocks API映射到数据库 – Kafka Cluster: Kafka Component: Broker Component: Controller Component: Exporter InstanceSet InstanceSet InstanceSet Instance Instance Instance Instance Instance Instance Instance Pod PVC Service Pod PVC Service Pod Service
24. KubeBlocks通过抽象和分层管理数据库 KubeBlocks Operator实现 kbcli Cluster Controller Component Controller InstanceSet Controller …… KubeBlocks API Addon API Cluster ClusterDefintion Component ComponentDefinition ComponentVersion InstanceSet KubeBlocks Cloud 通过YAML低代码的集成 多种数据库容器 KubeBlocks Addons Instance K8s API Pod Service PVC Secret Configmap … ……
25. 例子:Redis Addon支持Redis的多种部署形态 01 单节点 02 主从+Sentinel 03 RedisProxy + 主从 + Sentinel Proxy (e.g. TwemProxy/Camellia) HA Sentinel Sentinel HA Sentinel Sentinel Sentinel Sentinel https://github.com/apecloud/kubeblocks-addons/tree/main/addons/redis 04 Redis Cluster
26. 1. 编写ComponentDefinition:Redis/Sentinel/RedisProxy cmpd-redis.yaml kind: ComponentDefinition metadata: name: redis spec: serviceKind: redis serviceVersion: 7.0.6 services: ports: - port: 6379 volume : - name: data … roles: - name: primary … - name: secondary … configs:… scripts :… logConfigs :… exporter:… systemAccounts: - name: default … cmpd-redis.yaml lifecycleActions: - roleProbe :… - postProvision :… - accountProvision :… - … vars: - name:REDIS_ADVERTISED_PORT … - name: SENTINEL_SERVICE_PORT … - name: SENTINEL_POD_NAME_LIST … runtime: containers: - name: redis image :… command :… env :… ports:… volumeMounts:… - name: metrics image :… https://github.com/apecloud/kubeblocks-addons/blob/main/addons/redis/templates/componentdefinition-redis.yaml
27. 2. 编写ComponentDefinition:Redis/Sentinel/RedisProxy cmpd-redis-sentinel.yaml kind: ComponentDefinition metadata: name: redis-sentinel spec: serviceKind: redis-sentinel serviceVersion: 7.0.6 services: ports: - port: 26379 volume : - name: data … configs:… scripts :… logConfigs :… exporter:… systemAccounts: - name: default … cmpd-redis-sentinel.yaml lifecycleActions: - accountProvision :… vars: - name: SENTINEL_USER … - name: SENTINEL_PASSWORD … runtime: containers: - name: redis-sentinel image :… command :… env :… ports:… volumeMounts:… https://github.com/apecloud/kubeblocks-addons/blob/main/addons/redis/templates/componentdefinition-redis-sentinel.yaml
28. 3. 编写ComponentDefinition:Redis/Sentinel/RedisProxy cmpd-redis-twemproxy.yaml kind: ComponentDefinition metadata: name: redis-twemproxy spec: serviceKind: redis-twemproxy serviceVersion: 0.5 services: ports: - port: 22121 volume : - name: data … configs:… scripts :… logConfigs :… exporter:… cmpd-redis-twemproxy .yaml vars: - name:REDIS_SERVICE_NAME … - name: REDIS_SERVICE_PORT … runtime: initContainers : - name: init-redis-twemproxy image :… containers: - name: redis-twemproxy image :… command :… env :… ports:… volumeMounts:… - name: metrics image :… https://github.com/apecloud/kubeblocks-addons/blob/main/addons/redis/templates/componentdefinition-redis-twemproxy.yaml
29. 4. 编写ClusterDefinition:组装Redis/Sentinel/RedisProxy cd- redis.yaml kind: ClusterDefinition metadata: name: redis spec: topologies: - name: standalone components: - name: redis compDef: “cmpd-redis” - name: replication components: - name: redis compDef: “cmpd-redis” - name: redis-sentinel compDef: “cmpd-redis-sentinel” - name: replication-twemproxy components: - name: redis compDef: “cmpd-redis” - name: redis-sentinel compDef: “cmpd-redis-sentinel” - name: redis-twemproxy compDef: “cmpd-redis-twemproxy” 1. 单节点 HA Sen tine l 2. 主从+Sentinel Sen tine l Sen tine l Proxy (e.g. TwemProxy/Camellia) 3. RedisProxy + 主从 + Sentinel https://github.com/apecloud/kubeblocks-addons/blob/main/addons/redis/templates/clusterdefinition.yaml HA Sen tine l Sen tine l Sen tine l
30. 5. 使用Redis Addon创建和管理Redis数据库 通过kbcli 通过YAML API cluster-cd- topology.yaml kind: Cluster metadata: name: redis-cluster spec: clusterDefinitionRef:redis topology: replication componentSpecs: - name: redis replicas: 2 enableLogs: - running resources: limits: cpu: “1.0” memory: 1Gi volumeClaimTemplates: … storage: 10Gi - name: sentinel … Step 1: 安装 redis 插件 kbcli addon enable redis Step 2: 创建 redis cluster kbcli cluster create redis-cluster --cluster-definition redis Step X: 集群运维 kbcli cluster <ops> redis https://github.com/apecloud/kubeblocks-addons/blob/main/examples/redis/cluster-cd-topology.yaml
31. KubeBlocks 已经集成了35种数据库引擎 https://github.com/apecloud/kubeblocks-addons/tree/main/addons
32. 数据库容器化的常见问题 容器化会不会影响数据库的性能? K8s 适合管理有状态服务么 ?
33. 虚拟化与容器方案对比 内核态 VM microVM 用户态 gVisor runC • Kata • Firecracker 性能:runC > microVM > VM > gVisor 安全性:VM ≈ microVM ≈ gVisor > runC
34. KubeBlocks 基于 runC 容器进行的性能优化 网络 eBPF CNI Hostnetwork 数据库 Connection pool Parameter tunning XFS 操作系统 CPU Binding IO Throttle FS Tuning PostgreSQL Throughput (KubeBlocks v.s. RDS) 0.6 0.5 0.4 0.3 0.2 存储 0.1 全栈优化数据+容器性能 Batch I/O I/O Merge Striping 0 Node2Node Node2NodePort Redis Latency (BareMetal v.s. K8s v.s KubeBlocks eBPF Network)
35. 数据库容器化的常见问题 容器化会不会影响数据库的性能? K8s 适合管理有状态服务么 ?
36. 从StatefulSet到InstanceSet StatefulSet InstanceSet • 不支持PVC扩容 • 直接管理Pod • 变更Pod配置时必须按照严格顺序 • 支持异构的Pod配置 e.g. pod-2, pod-1, pod-0 • 不支持异构的Pod配置 • 支持指定Pod下线 • 支持管理非常多数量的Pod(e.g. 几千个)
37. 高可用和高可靠仍然是通过数据库层面多副本技术 MySQL PostgreSQL 容灾调度策略 Orchestrator Master Slave Redis Primary Secondary Postgres Postgres Patroni Patroni ApeCloud MySQL Sentinel Sentinel Sentinel Leader Slave Follower 不同节点部署 不同可用区部署 角色/健康探测 • • 探测节点可用性 切换角色 Label 控制粒度到Pod • • 滚动更新,控制节点变更顺序 计划内角色切换 支持集成第三方高可用组件 Raft Master • • Follower • • 可定制健康探测,结合系统信息综合判断 节点异常时提供自修复能力
38. 在 正在成为趋势
39. 应用场景:互联网公司的私有云降本增效 统一架构 业务团队 数据库团队 业务团队 业务团队 大数据团队 … … 业务团队 中间件团队 提高密度 容器平台团队 运维团队 降低成本
40. 应用场景:央国企和银行的数科公司的私有云 计量计费 数科公司 国产替代 子公司 子公司 … … 子公司 可定制性
41. 应用场景:为软件厂商进行私有化部署 提高部署效率 轻量化部署 业务出海
42. KubeBlocks in CNCF Landscape CNCF Cloud Native LANDSCAPE 收录的唯一的开源多引擎dbPaaS项目
43. KubeBlocks 企业版 基于 KubeBlocks 提供公共云RDS体验的私有云数据库一站式管理服务 客户VPC / IDC KB 企业版/云服务 KB Cloud Manager  集群部署      公共云 集群配置 集群升级 弹性扩缩容 监控日志 备份恢复 KB Cloud Agent 私有云 VM 裸金属
44. KubeBlocks 特性总结 • 基于抽象和API标准对多种据库引擎进行统一的管理 • 高质量高性能,生产环境部署标准的K8s Operator • 东八区最专业的数据库容器化团队
45. 欢迎交流
46.

inicio - Wiki
Copyright © 2011-2024 iteam. Current version is 2.134.0. UTC+08:00, 2024-09-30 06:24
浙ICP备14020137号-1 $mapa de visitantes$