Using Operator #
What is DBPlusEngine-Operator? #
Kubernetes’ operator mode allows you to expand the ability of the cluster by associating controllers for one or more custom resources without modifying kubernetes’ own code. Operator is the kubernetes API client and acts as the custom resources controller.
The operator mode aims to capture the key objectives of the DevOps teams (who are managing one or a group of services).
DBPlusEngine-Operator helps users quickly deploy a set of DBPlusEngine-Proxy cluster in kubernetes environment, and is responsible for deploying and maintaining relevant resources around the cluster and monitoring the cluster status.
Terms #
CRD #
CRD (customresourcedefinition) user-defined resource definition means that DBPlusEngine-Operator will deploy a complete set of DBPlusEngine-Proxy clusters in kubernetes cluster by using CR (customresource) defined by CRD.
Advantages #
Simplified configuration #
You only need to write a simple yaml to deploy a complete set of DBPlusEngine-Proxy clusters in the cluster.
Easy to expand #
By modifying CR yaml, a series of features such as horizontal scaling can be used.
Simple operation and maintenance #
Using DBPlusEngine-Operator will not interfere with the status of DBPlusEngine-Proxy in the cluster. DBPlusEngine-Operator will automatically detect the status of the cluster and correct it.
Architecture #
Install DBPlusEngine-Operator #
Configure [DBPlusEngine-Operator Parameters] (#DBPlusEngine-Operator Parameters), configuration file located in dbplusengine-operator/values.yaml.
Run
kubectl create ns dbplusengine-operator
helm install dbplusengine-operator dbplusengine-operator -n dbplusengine-operator
Install DBPlusEngine-Operator-Cluster cluster #
Configure the [DBPlusEngine-Operator-Cluster Parameters](#DBPlusEngine-Operator-Cluster Parameters) configuration file located in dbplusengine-proxy/values.yaml.
Move the sphere-ex.license to dbplusengine-proxy/license, and keep the name sphere-ex.license.
kubectl create ns dbplusengine
helm install dbplusengine-operator-cluster dbplusengine-operator-cluster -n dbplusengine
DBPlusEngine-Operator Parameters #
DBPlusEngine-Operator parameters #
Name | Description | Value |
---|---|---|
replicaCount | operator replica count | 2 |
image.repository | operator image name | sphereex/dbplusengine-operator |
image.pullPolicy | mirror pull policy | IfNotPresent |
image.tag | image tag | 0.0.1 |
imagePullSecrets | image pulls key of private repository | [] |
resources | resources required by the operator | {} |
webhook.port | operator webhook boot port | 9443 |
health.healthProbePort | operator health check port | 8081 |
DBPlusEngine-Operator-Cluster Parameters #
DBPlusEngine-Operator-Cluster parameters #
Name | Description | Value |
---|---|---|
replicaCount | DBPlusEngine-Operator-Cluster cluster starts the number of replicas, Note: after you enable automaticScaling, this parameter will no longer take effect | "1" |
automaticScaling.enable | Whether the DBPlusEngine-Operator-Cluster cluster has auto-scaling enabled | false |
automaticScaling.scaleUpWindows | DBPlusEngine-Operator-Cluster automatically scales the stable window | 30 |
automaticScaling.scaleDownWindows | DBPlusEngine-Operator-Cluster automatically shrinks the stabilized window | 30 |
automaticScaling.target | DBPlusEngine-Operator-Cluster auto-scaling threshold, the value is a percentage. Note: at this stage, only cpu is supported as a metric for scaling | 70 |
automaticScaling.maxInstance | DBPlusEngine-Operator-Cluster maximum number of scaled-out replicas | 4 |
automaticScaling.minInstance | DBPlusEngine-Operator-Cluster has a minimum number of boot replicas, and the shrinkage will not be less than this number of replicas | 1 |
image.registry | DBPlusEngine-Operator-Cluster image host | docker.io |
image.repository | DBPlusEngine-Operator-Cluster image repository name | sphereex/dbplusengine-proxy |
image.tag | DBPlusEngine-Operator-Cluster image tag | 5.1.2 |
resources | DBPlusEngine-Operator-Cluster starts the requirement resource, and after opening automaticScaling, the resource of the request multiplied by the percentage of target is used to trigger the scaling action | {} |
service.type | DBPlusEngine-Operator-Cluster external exposure mode | ClusterIP |
service.port | DBPlusEngine-Operator-Cluster exposes the port to the outside world | 3307 |
startPort | DBPlusEngine-Operator-Cluster boot port | 3307 |
imagePullSecrets | DBPlusEngine-Operator-Cluster private image repository key | [] |
mySQLDriver.version | The DBPlusEngine-Operator-Cluster mysql driver version will not be downloaded if it is empty | "" |
GN.mode | DBPlusEngine-Operator-Cluster governance center mode, supporting sidecar/zookeeper | zookeeper |
GN.SidecarRegistry | DBPlusEngine-Operator-Cluster sidecar mode image host | <image warehouse host> |
GN.SidecarRepository | DBPlusEngine-Operator-Cluster sidecar mode image warehouse name | sphereex/dbplusengine-sidecar |
GN.SidecarTag | DBPlusEngine-Operator-Cluster sidecar mode image tag | 0.2.0 |
GN.sidecarServerAddr | DBPlusEngine-Operator-Cluster sidecar address of mode image server | Server Address |
withAgent | DBPlusEngine-Operator-Cluster whether start agent parameter | false |
Compute Node DBPlusEngine-Operator-Cluster Server Authority Configuration Items #
Name | Description | Value |
---|---|---|
serverConfig.authority.privilege.type | The authority provider type for storage node data authorization, the default value is ALL_PERMITTED | ALL_PERMITTED |
serverConfig.authority.users[0].password | The password used to login to the compute node | root |
serverConfig.authority.users[0].user | The username used to login to the compute node, the authorized host. Format: | root@% |
Compute Node DBPlusEngine-Operator-Cluster Server Mode Configuration Items #
Name | Description | Value |
---|---|---|
serverConfig.mode.type | The running mode type. At this stage, only cluster mode is supported | Cluster |
serverConfig.mode.repository.props.namespace | Registry center namespace | governance_ds |
serverConfig.mode.repository.props.server-lists | Registry center connection address | {{ printf "%s-zookeeper.%s:2181" .Release.Name .Release.Namespace }} |
serverConfig.mode.repository.props.maxRetries | The maximum number of client connections retries | 3 |
serverConfig.mode.repository.props.operationTimeoutMilliseconds | The number of milliseconds that the client operation timed out | 5000 |
serverConfig.mode.repository.props.retryIntervalMilliseconds | The number of milliseconds between retries | 500 |
serverConfig.mode.repository.props.timeToLiveSeconds | The number of seconds that temporary data invalidated | 60 |
serverConfig.mode.repository.type | Persist repository type. Only ZooKeeper is supported at this stage | ZooKeeper |
Governance Node ZooKeeper Configuration Item #
Configuration Item | Description | Value |
---|---|---|
zookeeper.enabled | Used to switch whether use ZooKeeper chart | true |
zookeeper.replicaCount | Number of ZooKeeper nodes | 1 |
zookeeper.persistence.enabled | Identifies whether ZooKeeper uses PersistentVolumeClaim to apply for PersistentVolume | false |
zookeeper.persistence.storageClass | StorageClass for PersistentVolume | "" |
zookeeper.persistence.accessModes | Access mode of PersistentVolume | ["ReadWriteOnce"] |
zookeeper.persistence.size | PersistentVolume size | 8Gi |
Sample #
dbplusengine-operator/values.yaml #
## @section DBPlusEngine-Operator-Cluster operator parameters
## @param replicaCount operator replica count
##
replicaCount: 2
image:
## @param image.repository operator image name
##
repository: "sphere-ex/dbplusengine-operator"
## @param image.pullPolicy image pull strategy
##
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
## @param image.tag image tag
##
tag: "0.1.0"
## @param imagePullSecrets Private warehouse image pull key
## e.g:
## imagePullSecrets:
## - name: mysecret
##
imagePullSecrets: []
## @param resources operator required resources
## e.g:
## resources:
## limits:
## cpu: 2
## limits:
## cpu: 2
##
resources: {}
## @param webhook.port operator webhook boot port
##
webhook:
port: 9443
## @param health.healthProbePort operator health check port
##
health:
healthProbePort: 8081
dbplusengine-proxy/values.yaml #
## @section DBPlusEngine-Operator-Cluster cluster parameters
## @param replicaCount DBPlusEngine-Operator-Cluster The number of cluster startup copies. Note: this parameter will no longer take effect after automaticScaling is enabled.
##
replicaCount: "1"
## @param automaticScaling.enable DBPlusEngine-Operator-Cluster Whether the cluster starts automatic capacity expansion and contraction
## @param automaticScaling.scaleUpWindows DBPlusEngine-Operator-Cluster Auto expansion stable window
## @param automaticScaling.scaleDownWindows DBPlusEngine-Operator-Cluster Auto shrink stable window
## @param automaticScaling.target DBPlusEngine-Operator-Cluster The threshold value of automatic capacity expansion and contraction is percentage. Note: at this stage, only CPU is supported for capacity expansion and contraction.
## @param automaticScaling.maxInstance DBPlusEngine-Operator-Cluster Maximum number of capacity expansion copies
## @param automaticScaling.minInstance DBPlusEngine-Operator-Cluster The minimum number of startup copies, and the shrink size will not be less than this number of copies.
##
automaticScaling:
enable: false
scaleUpWindows: 30
scaleDownWindows: 30
target: 20
maxInstance: 4
minInstance: 1
## @param image.registry DBPlusEngine-Operator-Cluster image host
## @param image.repository DBPlusEngine-Operator-Cluster Image warehouse name
## @param image.tag DBPlusEngine-Operator-Cluster image tag
##
image:
registry: <image warehouse host>
repository: sphere-ex/dbplusengine-proxy
tag: 1.1.0
withAgent: false
## @param resources DBPlusEngine-Operator-Cluster Start the demand resource. After automaticscaling is enabled, multiply the resource of request by the percentage of target as the actual utilization rate to trigger the expansion and contraction action.
## e.g:
## resources:
## limits:
## cpu: 2
## requests:
## cpu: 2
##
resources: {}
## @param service.type DBPlusEngine-Operator-Cluster external exposure mode
## @param service.port DBPlusEngine-Operator-Cluster external exposure port
##
service:
type: ClusterIP
port: 3307
## @param startPort DBPlusEngine-Operator-Cluster startup port
##
startPort: 3307
## @param imagePullSecrets DBPlusEngine-Operator-Cluster private image warehouse key
## e.g:
## imagePullSecrets:
## - name: mysecret
##
imagePullSecrets: []
## @param mySQLDriver.version DBPlusEngine-Operator-Cluster mysql driver version. If it is empty, the driver will not be downloaded.
##
mySQLDriver:
version: ""
## @section DBPlusEngine-Operator-Cluster ServerConfiguration parameters
## 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 }}",
## otherwise please fill in the correct zookeeper address
## The server.yaml is auto-generated based on this parameter.
## If it is empty, the server.yaml is also empty.
## ref: https://shardingsphere.apache.org/document/current/en/user-manual/shardingsphere-jdbc/yaml-config/mode/
## ref: https://shardingsphere.apache.org/document/current/en/user-manual/common-config/builtin-algorithm/metadata-repository/
##
serverConfig:
## @section Compute-Node DBPlusEngine-Operator-Cluster ServerConfiguration authority parameters
## NOTE: It is used to set up initial user to login compute node, and authority data of storage node.
## @param serverConfig.authority.privilege.type authority provider for storage node, the default value is ALL_PERMITTED
## @param serverConfig.authority.users[0].password Password for compute node.
## @param 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
##
authority:
privilege:
type: ALL_PERMITTED
users:
- password: root
user: root@%
## @section Compute-Node DBPlusEngine-Operator-Cluster ServerConfiguration mode Configuration parameters
## @param serverConfig.mode.type Type of mode configuration. Now only support Cluster mode
## @param serverConfig.mode.repository.props.namespace Namespace of registry center
## @param serverConfig.mode.repository.props.server-lists Server lists of registry center
## @param serverConfig.mode.repository.props.maxRetries Max retries of client connection
## @param serverConfig.mode.repository.props.operationTimeoutMilliseconds Milliseconds of operation timeout
## @param serverConfig.mode.repository.props.retryIntervalMilliseconds Milliseconds of retry interval
## @param serverConfig.mode.repository.props.timeToLiveSeconds Seconds of ephemeral data live
## @param serverConfig.mode.repository.type Type of persist repository. Now only support ZooKeeper
##
##
## mode:
## repository:
## props:
## namespace: ssd1031test1
## server-lists: "127.0.0.1:21506"
## type: SphereEx:MATE
## type: Cluster
mode:
repository:
props:
maxRetries: 3
namespace: governance_ds
operationTimeoutMilliseconds: 5000
retryIntervalMilliseconds: 500
server-lists: "{{ printf \"%s-zookeeper.%s:2181\" .Release.Name .Release.Namespace }}"
timeToLiveSeconds: 600
type: ZooKeeper
type: Cluster
props:
proxy-frontend-database-protocol-type: PostgreSQL
## @section ZooKeeper chart parameters
## ZooKeeper chart configuration
## https://github.com/bitnami/charts/blob/master/bitnami/zookeeper/values.yaml
##
zookeeper:
## @param zookeeper.enabled Switch to enable or disable the ZooKeeper helm chart
##
enabled: true
## @param zookeeper.replicaCount Number of ZooKeeper nodes
##
replicaCount: 3
## ZooKeeper Persistence parameters
## ref: https://kubernetes.io/docs/user-guide/persistent-volumes/
## @param zookeeper.persistence.enabled Enable persistence on ZooKeeper using PVC(s)
## @param zookeeper.persistence.storageClass Persistent Volume storage class
## @param zookeeper.persistence.accessModes Persistent Volume access modes
## @param zookeeper.persistence.size Persistent Volume size
##
persistence:
enabled: false
storageClass: ""
accessModes:
- ReadWriteOnce
size: 8Gi
Clean #
helm uninstall dbplusengine-proxy -n dbplusengine
helm uninstall dbplusengine-operator -n dbplusengine-operator
kubectl delete crd clusters.dbplusengine.sphere-ex.com \
proxyconfigs.dbplusengine.sphere-ex.com \
plocks.dbplusengine.sphere-ex.com \
pmetadata.dbplusengine.sphere-ex.com \
pnodes.dbplusengine.sphere-ex.com \
ppipelines.dbplusengine.sphere-ex.com \
psys.dbplusengine.sphere-ex.com \
pworkids.dbplusengine.sphere-ex.com