Logo
Using Operator

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 #

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 #

NameDescriptionValue
replicaCountoperator replica count2
image.repositoryoperator image namesphereex/dbplusengine-operator
image.pullPolicymirror pull policyIfNotPresent
image.tagimage tag0.0.1
imagePullSecretsimage pulls key of private repository[]
resourcesresources required by the operator{}
webhook.portoperator webhook boot port9443
health.healthProbePortoperator health check port8081

DBPlusEngine-Operator-Cluster Parameters #

DBPlusEngine-Operator-Cluster parameters #

NameDescriptionValue
replicaCountDBPlusEngine-Operator-Cluster cluster starts the number of replicas, Note: after you enable automaticScaling, this parameter will no longer take effect"1"
automaticScaling.enableWhether the DBPlusEngine-Operator-Cluster cluster has auto-scaling enabledfalse
automaticScaling.scaleUpWindowsDBPlusEngine-Operator-Cluster automatically scales the stable window30
automaticScaling.scaleDownWindowsDBPlusEngine-Operator-Cluster automatically shrinks the stabilized window30
automaticScaling.targetDBPlusEngine-Operator-Cluster auto-scaling threshold, the value is a percentage. Note: at this stage, only cpu is supported as a metric for scaling70
automaticScaling.maxInstanceDBPlusEngine-Operator-Cluster maximum number of scaled-out replicas4
automaticScaling.minInstanceDBPlusEngine-Operator-Cluster has a minimum number of boot replicas, and the shrinkage will not be less than this number of replicas1
image.registryDBPlusEngine-Operator-Cluster image hostdocker.io
image.repositoryDBPlusEngine-Operator-Cluster image repository namesphereex/dbplusengine-proxy
image.tagDBPlusEngine-Operator-Cluster image tag5.1.2
resourcesDBPlusEngine-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.typeDBPlusEngine-Operator-Cluster external exposure modeClusterIP
service.portDBPlusEngine-Operator-Cluster exposes the port to the outside world3307
startPortDBPlusEngine-Operator-Cluster boot port3307
imagePullSecretsDBPlusEngine-Operator-Cluster private image repository key[]
mySQLDriver.versionThe DBPlusEngine-Operator-Cluster mysql driver version will not be downloaded if it is empty""
GN.modeDBPlusEngine-Operator-Cluster governance center mode, supporting sidecar/zookeeperzookeeper
GN.SidecarRegistryDBPlusEngine-Operator-Cluster sidecar mode image host<image warehouse host>
GN.SidecarRepositoryDBPlusEngine-Operator-Cluster sidecar mode image warehouse namesphereex/dbplusengine-sidecar
GN.SidecarTagDBPlusEngine-Operator-Cluster sidecar mode image tag0.2.0
GN.sidecarServerAddrDBPlusEngine-Operator-Cluster sidecar address of mode image serverServer Address
withAgentDBPlusEngine-Operator-Cluster whether start agent parameterfalse

Compute Node DBPlusEngine-Operator-Cluster Server Authority Configuration Items #

NameDescriptionValue
serverConfig.authority.privilege.typeThe authority provider type for storage node data authorization, the default value is ALL_PERMITTEDALL_PERMITTED
serverConfig.authority.users[0].passwordThe password used to login to the compute noderoot
serverConfig.authority.users[0].userThe username used to login to the compute node, the authorized host. Format: @ hostname as % or an empty string indicates no restriction on the authorized hostroot@%

Compute Node DBPlusEngine-Operator-Cluster Server Mode Configuration Items #

NameDescriptionValue
serverConfig.mode.typeThe running mode type. At this stage, only cluster mode is supportedCluster
serverConfig.mode.repository.props.namespaceRegistry center namespacegovernance_ds
serverConfig.mode.repository.props.server-listsRegistry center connection address{{ printf "%s-zookeeper.%s:2181" .Release.Name .Release.Namespace }}
serverConfig.mode.repository.props.maxRetriesThe maximum number of client connections retries3
serverConfig.mode.repository.props.operationTimeoutMillisecondsThe number of milliseconds that the client operation timed out5000
serverConfig.mode.repository.props.retryIntervalMillisecondsThe number of milliseconds between retries500
serverConfig.mode.repository.props.timeToLiveSecondsThe number of seconds that temporary data invalidated60
serverConfig.mode.repository.typePersist repository type. Only ZooKeeper is supported at this stageZooKeeper

Governance Node ZooKeeper Configuration Item #

Configuration ItemDescriptionValue
zookeeper.enabledUsed to switch whether use ZooKeeper charttrue
zookeeper.replicaCountNumber of ZooKeeper nodes1
zookeeper.persistence.enabledIdentifies whether ZooKeeper uses PersistentVolumeClaim to apply for PersistentVolumefalse
zookeeper.persistence.storageClassStorageClass for PersistentVolume""
zookeeper.persistence.accessModesAccess mode of PersistentVolume["ReadWriteOnce"]
zookeeper.persistence.sizePersistentVolume size8Gi

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
  ## @param serverConfig.mode.overwrite Whether overwrite persistent configuration with local configuration
  ##
  ##
  ## mode:
  ##   repository:
  ##     props:
  ##       namespace: ssd1031test1
  ##       server-lists: "127.0.0.1:21506"
  ##     type: SphereEx:MATE
  ##   type: Cluster
  mode:
    overwrite: true
    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