使用 Helm

背景信息

使用 Helm 在 Kubernetes 集群中引导 ShardingSphere-Proxy 实例进行安装。关于 ShardingSphere Helm Charts 的更多内容可以参考:ShardingSphere-on-Cloud 子项目

前提条件

  • kubernetes 1.18+
  • kubectl
  • helm 3.3.0+
  • 可以动态申请 PV(Persistent Volumes) 的 StorageClass 用于持久化数据。(可选)

操作步骤

在线安装

  1. 将 ShardingSphere-Proxy 添加到 Helm 本地仓库:
  1. helm repo add shardingsphere https://shardingsphere.apache.org/charts
  1. 以 ShardingSphere-Proxy 命名安装 charts:
  1. helm install shardingsphere-proxy shardingsphere/shardingsphere-proxy

源码安装

  1. 执行下述命令以执行默认配置进行安装。
  1. git clone https://github.com/apache/shardingsphere-on-cloud.git
  2. cd charts/shardingsphere-proxy/charts/governance
  3. helm dependency build
  4. cd ../..
  5. helm dependency build
  6. cd ..
  7. helm install shardingsphere-proxy shardingsphere-proxy

说明:

  1. 其他的配置详见下方的配置列表。
  2. 执行 helm list 获取所有安装的 release。

卸载

  1. 默认删除所有发布记录,增加 --keep-history 参数保留发布记录。
  1. helm uninstall shardingsphere-proxy

参数解释

治理节点配置项

配置项描述
governance.enabled用来切换是否使用治理节点的 charttrue

治理节点 ZooKeeper 配置项

配置项描述
governance.zookeeper.enabled用来切换是否使用 ZooKeeper 的 charttrue
governance.zookeeper.replicaCountZooKeeper 节点数量1
governance.zookeeper.persistence.enabled标识 ZooKeeper 是否使用持久卷申领 (PersistentVolumeClaim) 用来申请持久卷(PersistentVolume)false
governance.zookeeper.persistence.storageClass持久卷(PersistentVolume)的存储类 (StorageClass)“”
governance.zookeeper.persistence.accessModes持久卷(PersistentVolume)的访问模式[“ReadWriteOnce”]
governance.zookeeper.persistence.size持久卷(PersistentVolume) 大小8Gi
governance.zookeeper.resources.limitsZooKeeper 容器的资源限制{}
governance.zookeeper.resources.requests.memoryZooKeeper 容器申请的内存256Mi
governance.zookeeper.resources.requests.cpuZooKeeper 容器申请的 cpu 核数250m

计算节点 ShardingSphere-Proxy 配置项

配置项描述
compute.image.repositoryShardingSphere-Proxy 的镜像名apache/shardingsphere-proxy
compute.image.pullPolicyShardingSphere-Proxy 镜像拉取策略IfNotPresent
compute.image.tagShardingSphere-Proxy 镜像标签5.1.2
compute.imagePullSecrets拉取私有仓库的凭证[]
compute.resources.limitsShardingSphere-Proxy 容器的资源限制{}
compute.resources.requests.memoryShardingSphere-Proxy 容器申请的内存2Gi
compute.resources.requests.cpuShardingSphere-Proxy 容器申请的 cpu 核数200m
compute.replicasShardingSphere-Proxy 节点个数3
compute.service.typeShardingSphere-Proxy 网络模式ClusterIP
compute.service.portShardingSphere-Proxy 暴露端口3307
compute.mysqlConnector.versionMySQL 驱动版本5.1.49
compute.startPortShardingSphere-Proxy 启动端口3307
compute.serverConfigShardingSphere-Proxy 模式配置文件“”

配置示例

  1. #
  2. # Licensed to the Apache Software Foundation (ASF) under one or more
  3. # contributor license agreements. See the NOTICE file distributed with
  4. # this work for additional information regarding copyright ownership.
  5. # The ASF licenses this file to You under the Apache License, Version 2.0
  6. # (the "License"); you may not use this file except in compliance with
  7. # the License. You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS,
  13. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16. #
  17. ## @section Governance-Node parameters
  18. ## @param governance.enabled Switch to enable or disable the governance helm chart
  19. ##
  20. governance:
  21. enabled: true
  22. ## @section Governance-Node ZooKeeper parameters
  23. zookeeper:
  24. ## @param governance.zookeeper.enabled Switch to enable or disable the ZooKeeper helm chart
  25. ##
  26. enabled: true
  27. ## @param governance.zookeeper.replicaCount Number of ZooKeeper nodes
  28. ##
  29. replicaCount: 1
  30. ## ZooKeeper Persistence parameters
  31. ## ref: https://kubernetes.io/docs/user-guide/persistent-volumes/
  32. ## @param governance.zookeeper.persistence.enabled Enable persistence on ZooKeeper using PVC(s)
  33. ## @param governance.zookeeper.persistence.storageClass Persistent Volume storage class
  34. ## @param governance.zookeeper.persistence.accessModes Persistent Volume access modes
  35. ## @param governance.zookeeper.persistence.size Persistent Volume size
  36. ##
  37. persistence:
  38. enabled: false
  39. storageClass: ""
  40. accessModes:
  41. - ReadWriteOnce
  42. size: 8Gi
  43. ## ZooKeeper's resource requests and limits
  44. ## ref: https://kubernetes.io/docs/user-guide/compute-resources/
  45. ## @param governance.zookeeper.resources.limits The resources limits for the ZooKeeper containers
  46. ## @param governance.zookeeper.resources.requests.memory The requested memory for the ZooKeeper containers
  47. ## @param governance.zookeeper.resources.requests.cpu The requested cpu for the ZooKeeper containers
  48. ##
  49. resources:
  50. limits: {}
  51. requests:
  52. memory: 256Mi
  53. cpu: 250m
  54. ## @section Compute-Node parameters
  55. ##
  56. compute:
  57. ## @section Compute-Node ShardingSphere-Proxy parameters
  58. ## ref: https://kubernetes.io/docs/concepts/containers/images/
  59. ## @param compute.image.repository Image name of ShardingSphere-Proxy.
  60. ## @param compute.image.pullPolicy The policy for pulling ShardingSphere-Proxy image
  61. ## @param compute.image.tag ShardingSphere-Proxy image tag
  62. ##
  63. image:
  64. repository: "apache/shardingsphere-proxy"
  65. pullPolicy: IfNotPresent
  66. ## Overrides the image tag whose default is the chart appVersion.
  67. ##
  68. tag: "5.1.2"
  69. ## @param compute.imagePullSecrets Specify docker-registry secret names as an array
  70. ## e.g:
  71. ## imagePullSecrets:
  72. ## - name: myRegistryKeySecretName
  73. ##
  74. imagePullSecrets: []
  75. ## ShardingSphere-Proxy resource requests and limits
  76. ## ref: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
  77. ## @param compute.resources.limits The resources limits for the ShardingSphere-Proxy containers
  78. ## @param compute.resources.requests.memory The requested memory for the ShardingSphere-Proxy containers
  79. ## @param compute.resources.requests.cpu The requested cpu for the ShardingSphere-Proxy containers
  80. ##
  81. resources:
  82. limits: {}
  83. requests:
  84. memory: 2Gi
  85. cpu: 200m
  86. ## ShardingSphere-Proxy Deployment Configuration
  87. ## ref: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/
  88. ## ref: https://kubernetes.io/docs/concepts/services-networking/service/
  89. ## @param compute.replicas Number of cluster replicas
  90. ##
  91. replicas: 3
  92. ## @param compute.service.type ShardingSphere-Proxy network mode
  93. ## @param compute.service.port ShardingSphere-Proxy expose port
  94. ##
  95. service:
  96. type: ClusterIP
  97. port: 3307
  98. ## MySQL connector Configuration
  99. ## ref: https://shardingsphere.apache.org/document/current/en/quick-start/shardingsphere-proxy-quick-start/
  100. ## @param compute.mysqlConnector.version MySQL connector version
  101. ##
  102. mysqlConnector:
  103. version: "5.1.49"
  104. ## @param compute.startPort ShardingSphere-Proxy start port
  105. ## ShardingSphere-Proxy start port
  106. ## ref: https://shardingsphere.apache.org/document/current/en/user-manual/shardingsphere-proxy/startup/docker/
  107. ##
  108. startPort: 3307
  109. ## @section Compute-Node ShardingSphere-Proxy ServerConfiguration parameters
  110. ## NOTE: If you use the sub-charts to deploy Zookeeper, the server-lists field must be "{{ printf \"%s-zookeeper.%s:2181\" .Release.Name .Release.Namespace }}",
  111. ## otherwise please fill in the correct zookeeper address
  112. ## The server.yaml is auto-generated based on this parameter.
  113. ## If it is empty, the server.yaml is also empty.
  114. ## ref: https://shardingsphere.apache.org/document/current/en/user-manual/shardingsphere-jdbc/yaml-config/mode/
  115. ## ref: https://shardingsphere.apache.org/document/current/en/user-manual/common-config/builtin-algorithm/metadata-repository/
  116. ##
  117. serverConfig:
  118. ## @section Compute-Node ShardingSphere-Proxy ServerConfiguration authority parameters
  119. ## NOTE: It is used to set up initial user to login compute node, and authority data of storage node.
  120. ## ref: https://shardingsphere.apache.org/document/current/en/user-manual/shardingsphere-proxy/yaml-config/authentication/
  121. ## @param compute.serverConfig.authority.privilege.type authority provider for storage node, the default value is ALL_PERMITTED
  122. ## @param compute.serverConfig.authority.users[0].password Password for compute node.
  123. ## @param compute.serverConfig.authority.users[0].user Username,authorized host for compute node. Format: <username>@<hostname> hostname is % or empty string means do not care about authorized host
  124. ##
  125. authority:
  126. privilege:
  127. type: ALL_PRIVILEGES_PERMITTED
  128. users:
  129. - password: root
  130. user: root@%
  131. ## @section Compute-Node ShardingSphere-Proxy ServerConfiguration mode Configuration parameters
  132. ## @param compute.serverConfig.mode.type Type of mode configuration. Now only support Cluster mode
  133. ## @param compute.serverConfig.mode.repository.props.namespace Namespace of registry center
  134. ## @param compute.serverConfig.mode.repository.props.server-lists Server lists of registry center
  135. ## @param compute.serverConfig.mode.repository.props.maxRetries Max retries of client connection
  136. ## @param compute.serverConfig.mode.repository.props.operationTimeoutMilliseconds Milliseconds of operation timeout
  137. ## @param compute.serverConfig.mode.repository.props.retryIntervalMilliseconds Milliseconds of retry interval
  138. ## @param compute.serverConfig.mode.repository.props.timeToLiveSeconds Seconds of ephemeral data live
  139. ## @param compute.serverConfig.mode.repository.type Type of persist repository. Now only support ZooKeeper
  140. ## @param compute.serverConfig.mode.overwrite Whether overwrite persistent configuration with local configuration
  141. ##
  142. mode:
  143. type: Cluster
  144. repository:
  145. type: ZooKeeper
  146. props:
  147. maxRetries: 3
  148. namespace: governance_ds
  149. operationTimeoutMilliseconds: 5000
  150. retryIntervalMilliseconds: 500
  151. server-lists: "{{ printf \"%s-zookeeper.%s:2181\" .Release.Name .Release.Namespace }}"
  152. timeToLiveSeconds: 60
  153. overwrite: true