ShardingSphere-On-Cloud 0.2.0 发布!新的 CRD ComputeNode

Apache ShardingSphere-On-Cloud 近日迎来了 0.2.0 版本发布。本次 0.2.0 版本主要为 ShardingSphere Operator 引入了全新 CRD ComputeNode,用于完整定义 ShardingSphere 架构中的计算节点。

ComputeNode介绍‍‍‍‍

在 Apache ShardingSphere 的经典架构里,主要的组件分为计算节点、存储节点和治理节点。其中计算节点指的是 ShardingSphere Proxy,是所有数据流量的入口,承担着分片等各类数据治理能力。存储节点指的是数据库。治理节点是用于存放 ShardingSphere 各类元数据比如分片规则、加密规则、读写分离规则,还有逻辑库表等信息的环境,常用的治理节点组件有 Zookeeper,Etcd 等。

071846cb6c29283f343b55e67820bf96.png

在 ShardingSphere Operator 0.1.x 版本中,已经推出了两个 CRD Proxy 和 ProxyServerConfig,分别用于描述 ShardingSphere Proxy 的部署和配置,如下图:

ae0973ad4af1fa80b1743a1d963daa58.png

通过 Proxy 和 ProxyServerConfig 可以达到对 ShardingSphere Proxy 的部署和基础维护能力,可以满足 PoC 的需要。但是对于 Operator 来说,需要能够应对生产环境中的各类场景和问题,才能真正帮助到了用户。除了部署外,operator 还需要能够管理跨版本升级、会话优雅停止、多 Metrics 的水平弹性扩容、位置感知流量调度、配置安全、集群级高可用等等。而想要实现这些丰富的管理能力,需要将它们的作用集中到一组特定的对象,首当其冲的这个对象就是 ComputeNode,如下图:

478b0eb12e09705b0611baf21aea4417.png

相比 Proxy 和 ProxyServerConfig,ComputeNode 的改变主要有:

d35f9665efaf749bea64131c1edceb65.jpeg

ComputeNode实践
‍‍‍‍‍‍

快速安装 ShardingSphere Operator

执行如下 helm 命令即可快速拉起一套通过 ComputeNode 描述的 ShardingSphere Proxy 集群。

1. 添加 ShardingSphere on Cloud 的 Helm 仓库:

helm repo add shardingsphere https://apache.github.io/shardingsphere-on-cloud

b524abef160f0cdbd6b5645073e1960b.png

2. 利用 helm install 命令安装 shardingsphere-operator:

说明:目前 ComputeNode 仍然属于 v1alpha1 阶段,需要通过 feature gate 进行启用

helm install shardingsphere-operator shardingsphere/apache-shardingsphere-operator-charts --set operator.featureGates.computeNode=true --set proxyCluster.enabled=false

899938707b56c0540b390d5f7929bb35.png

3. 通过 kubectl get pod 查看部署情况:

8392f24af57dc2226c3cf48a09f5656a.png

现在,已经部署好了一套完整的由 ShardingSphere Operator 管理的集群。

利用 kubectl get 查看 ShardingSphere Proxy 集群状态

通过 kubectl get 可以看到 computenode 的状态列包括 READYINSTANCES,PHASE,CLUSTER-IP,SERVICEPORTS 和 AGE。其中:

  • READYINSTANCES:表示当前处于 Ready 状态的 ShardingSphere Pod 数量,如图中为 1

  • PHASE:表示当前集群状态,如图中为 Ready 状态

  • CLUSTER-IP:表示当前集群 Service 的 ClusterIP

  • SERVICEPORTS:表示当前集群 Service 的端口列表

  • AGE:表示当前集群的创建时长

    kubectl get computenode

12fca71f7c57dc4b6d2dc5d1d2e142f0.png


利用 kubectl scale 快速伸缩 ShardingSphere Proxy 集群

为了方便使用,ComputeNode 支持 Scale 子资源,所以可以通过 kubectl scale 配合 --replicas参数进行手动扩容:

349ab8161c6db02a88c30a2e1f473b1d.png

68ba99ac5f3d083bbfa7f89c417cfdaf.png


自定义 ComputeNode 配置

如果 operator 默认的 charts 里面安装的 ComputeNode 无法满足使用场景,那么需要自行编写 ComputeNode yaml 并提交到 kubernetes 进行部署:

apiVersion: shardingsphere.apache.org/v1alpha1
kind: ComputeNode
metadata:
  labels:
    app: foo
  name: foo
spec:
  storageNodeConnector:
    type: mysql
    version: 5.1.47
  serverVersion: 5.3.1
  replicas: 1
  selector:
    matchLabels:
      app: foo
  portBindings:
  - name: server
    containerPort: 3307
    servicePort: 3307
    protocol: TCP
  serviceType: ClusterIP
  bootstrap:
    serverConfig:
      authority:
        privilege:
          type: ALL_PERMITTED
        users:
        - user: root%
          password: root
      mode:
        type: Cluster
        repository:
          type: ZooKeeper
          props:
            timeToLiveSeconds: "600"
            server-lists: shardingsphere-operator-zookeeper.default:2181
            retryIntervalMilliseconds: "500"
            operationTimeoutMilliseconds: "5000"
            namespace: governance_ds
            maxRetries: "3"
      props:
        proxy-frontend-database-protocol-type: MySQL

将上述配置保存为 foo.yml 并执行如下命令即可创建:

kubectl apply -f foo.yml

3aa23b48cf3f39bca24f4d30302d9e66.png

8dc5aca592d1672e11a7f0f78582ec6f.png

上述示例可以 Github 仓库中的找到:

https://github.com/apache/shardingsphere-on-cloud/blob/main/examples/operator

其他改进
‍‍‍‍‍‍

本次发布的其它更新有:

  • 在 ShardingSphereProxy CRD 的 Annotation 中增加对滚动升级参数的支持 #172

  • 修复 ShardingSphereProxy Status 字段中 readyNodes 和 Conditions 在某些场景中错误的问题 #177

  • 向 ComputeNode 引入 scale 子资源以支持 kubectl scale #189

  • 将 ComputeNode 和 ShardingSphereProxy 构造和更新逻辑分离 #182

  • 向 ComputeNode 定义中反写 NodePort #187

  • 修复非 MySQL 类型配置导致空指针异常的问题 #179

  • 重构 Manager 配置逻辑,分离命令行配置 #192

  • 修复 CI 中 Docker 构建过程 #173

社区建设

此次 ShardingSphere-On-Cloud 0.2.0  版本的发布,共有 2 位 Contributor 提交了 22 个 PR,感谢社区伙伴们的大力支持。

GitHub ID 

🔖 mlycore

🔖 xuanyuan300

相关参考链接:

🔗 Apache ShardingSphere on Cloud 项目:https://github.com/apache/shardingsphere-on-cloud 
🔗 设计提案:https://github.com/apache/shardingsphere-on-cloud/issues/166 ComputeNode
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值