Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support wesql #1356

Draft
wants to merge 13 commits into
base: release-0.9
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions addons-cluster/wesql-cluster/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
*.lock
32 changes: 32 additions & 0 deletions addons-cluster/wesql-cluster/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
annotations:
category: Database
apiVersion: v2
name: wesql-cluster
type: application
version: 0.9.0
description: WeSQL is an innovative MySQL distribution that adopts a compute-storage separation architecture,
with storage backed by S3 (and S3-compatible systems). It can run on any cloud, ensuring no vendor lock-in.
dependencies:
- name: kblib
version: 0.1.0
repository: file://../kblib
alias: extra

appVersion: "8.0.35-0.1.0_beta3.38"

keywords:
- mysql
- database
- raft
- separation of compute and storage
- disaggregated storage

home: https://wesql.io
icon: https://wesql.io/img/logo.png

maintainers:
- name: free6om
url: https://github.io/free6om

sources:
- https://github.com/apecloud/kubeblocks-addons/
3 changes: 3 additions & 0 deletions addons-cluster/wesql-cluster/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Connect to WeSQL by using the following command:
mysql -h <wesql host> -u <wesql user> -p <wesql password>

88 changes: 88 additions & 0 deletions addons-cluster/wesql-cluster/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
{{/*
Define the cluster componnets with proxy.
The proxy cpu cores is 1/6 of the cluster total cpu cores and is multiple of 0.5.
The minimum proxy cpu cores is 0.5 and the maximum cpu cores is 64.
*/}}
{{- define "wesql-cluster.proxyComponents" }}
{{- $replicas := .Values.replicas }}
{{- $proxyCPU := divf (mulf $replicas .Values.cpu) 6.0 }}
{{- $proxyCPU = divf $proxyCPU 0.5 | ceil | mulf 0.5 }}
{{- if lt $proxyCPU 0.5 }}
{{- $proxyCPU = 0.5 }}
{{- else if gt $proxyCPU 64.0 }}
{{- $proxyCPU = 64 }}
{{- end }}
- name: wescale-ctrl
{{- if eq .Values.topology "wesql-proxy" }}
serviceRefs:
{{ include "wesql-cluster.serviceRef" . | indent 4 }}
{{- end }}
volumeClaimTemplates:
- name: data
spec:
storageClassName: {{ .Values.proxy.storageClassName | quote }}
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 20Gi
replicas: 1
resources:
limits:
cpu: 500m
memory: 128Mi
- name: wescale
{{- if eq .Values.topology "wesql-proxy" }}
serviceRefs:
{{ include "wesql-cluster.serviceRef" . | indent 4 }}
{{- end }}
replicas: 1
resources:
requests:
cpu: {{ $proxyCPU | quote }}
memory: 500Mi
limits:
cpu: {{ $proxyCPU | quote }}
memory: 500Mi
{{- end }}

{{- define "wesql-cluster.serviceRef" }}
- name: etcd
namespace: {{ .Release.Namespace }}
serviceDescriptor: {{ include "kblib.clusterName" . }}-etcd-descriptor
{{- end -}}

{{- define "wesql-cluster.etcdComponents" }}
- name: etcd
volumeClaimTemplates:
- name: data
spec:
storageClassName: {{ .Values.proxy.storageClassName | quote }}
accessModes:
- ReadWriteOnce
resources:
requests:
storage: {{ .Values.etcd.resources.storage }}
replicas: {{ .Values.etcd.replicas }}
resources:
requests:
cpu: 500m
memory: 500Mi
limits:
cpu: 500m
memory: 500Mi
{{- end -}}

{{- define "wesql-cluster.schedulingPolicy" }}
schedulingPolicy:
affinity:
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- podAffinityTerm:
labelSelector:
matchLabels:
app.kubernetes.io/instance: {{ include "kblib.clusterName" . }}
apps.kubeblocks.io/component-name: wesql-server
topologyKey: kubernetes.io/hostname
weight: 100
{{- end -}}
50 changes: 50 additions & 0 deletions addons-cluster/wesql-cluster/templates/cluster.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
apiVersion: apps.kubeblocks.io/v1alpha1
kind: Cluster
metadata:
name: {{ include "kblib.clusterName" . }}
namespace: {{ .Release.Namespace }}
labels:
{{ include "kblib.clusterLabels" . | nindent 4 }}
spec:
terminationPolicy: {{ .Values.extra.terminationPolicy }}
clusterDefinitionRef: wesql # ref clusterdefinition.name
topology: {{ .Values.topology }}
componentSpecs:
- name: wesql-server
env:
- name: WESQL_CLUSTER_MEMBER
value: "$(KB_POD_NAME).$(KB_CLUSTER_NAME)-$(KB_COMP_NAME)-headless:13306"
- name: MYSQL_CUSTOM_CONFIG
value: |
[mysqld]
objectstore_provider={{ .Values.objectStore.provider }}
objectstore_region={{ .Values.objectStore.region }}
objectstore_bucket={{ .Values.objectStore.bucket }}
repo_objectstore_id={{ .Values.objectStore.repoId }}
branch_objectstore_id={{ .Values.objectStore.branchId }}
log-bin=binlog
gtid_mode=ON
enforce_gtid_consistency=ON
log_slave_updates=ON
binlog_format=ROW
skip_name_resolve=ON
- name: WESQL_OBJECTSTORE_ACCESS_KEY
value: {{ .Values.objectStore.accessKey }}
- name: WESQL_OBJECTSTORE_SECRET_KEY
value: {{ .Values.objectStore.secretKey }}
{{- include "kblib.componentMonitor" . | indent 6 }}
{{- include "wesql-cluster.schedulingPolicy" . | indent 6 }}
{{- if eq .Values.topology "wesql-proxy" }}
serviceVersion: {{ .Values.version }}
serviceRefs:
{{ include "wesql-cluster.serviceRef" . | indent 8 }}
{{- end }}
replicas: {{ .Values.replicas }}
{{- include "kblib.componentResources" . | indent 6 }}
{{- include "kblib.componentStorages" . | indent 6 }}
{{- if ne .Values.topology "wesql" }}
{{- include "wesql-cluster.proxyComponents" . | indent 4 }}
{{- end }}
{{- if eq .Values.topology "wesql-proxy-etcd" }}
{{- include "wesql-cluster.etcdComponents" . | indent 4 }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{{- if eq .Values.topology "wesql-proxy" }}
apiVersion: apps.kubeblocks.io/v1alpha1
kind: ServiceDescriptor
metadata:
name: {{ include "kblib.clusterName" . }}-etcd-descriptor
namespace: {{ .Release.Namespace }}
spec:
serviceKind: etcd
serviceVersion: {{ .Values.etcd.serviceVersion }}
endpoint:
value: {{ .Values.etcd.serviceReference.endpoint }}
{{- end -}}
1 change: 1 addition & 0 deletions addons-cluster/wesql-cluster/templates/rbac.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{- include "kblib.rbac" . }}
15 changes: 15 additions & 0 deletions addons-cluster/wesql-cluster/templates/validate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{{/*
Validate cpu, memory and storage
*/}}
{{- $cpu := (float64 .Values.cpu) }}
{{- $memory := (float64 .Values.memory) }}
{{- $storage := (float64 .Values.storage) }}
{{- if or (lt $cpu 0.5) (gt $cpu 64.0) }}
{{- fail (print "cpu must be between 0.5 and 64, got " $cpu) }}
{{- end }}
{{- if or (lt $memory 0.5) (gt $memory 1000.0) }}
{{- fail (print "memory must be between 0.5 and 1000, got " $memory) }}
{{- end }}
{{- if or (lt $storage 1.0 ) (gt $storage 10000.0) }}
{{- fail (print "storage must be between 1 and 10000, got " $storage) }}
{{- end }}
76 changes: 76 additions & 0 deletions addons-cluster/wesql-cluster/values.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
{
"$schema": "http://json-schema.org/schema#",
"type": "object",
"properties": {
"version": {
"title": "Version",
"description": "MySQL Service Version.",
"type": "string",
"default": "8.0.35"
},
"topology": {
"title": "Topology",
"description": "Cluster topology.",
"type": "string",
"default": "wesql",
"enum": [
"wesql",
"wesql-proxy",
"wesql-proxy-etcd"
]
},
"replicas": {
"title": "Replicas",
"description": "The number of replicas.",
"type": "integer",
"default": 1,
"minimum": 1,
"maximum": 5
},
"cpu": {
"title": "CPU",
"description": "CPU cores.",
"type": [
"number",
"string"
],
"default": 0.5,
"minimum": 0.5,
"maximum": 64,
"multipleOf": 0.5
},
"memory": {
"title": "Memory(Gi)",
"description": "Memory, the unit is Gi.",
"type": [
"number",
"string"
],
"default": 0.5,
"minimum": 0.5,
"maximum": 1000
},
"storage": {
"title": "Storage(Gi)",
"description": "Storage size, the unit is Gi.",
"type": [
"number",
"string"
],
"default": 20,
"minimum": 1,
"maximum": 10000
},
"storageClassName": {
"title": "Storage Class Name",
"description": "Storage class name of the data volume",
"type": "string"
},
"proxyEnabled": {
"title": "Proxy",
"description": "Enable proxy or not.",
"type": "boolean",
"default": false
}
}
}
62 changes: 62 additions & 0 deletions addons-cluster/wesql-cluster/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Default values for wesql-cluster.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

## @param version WeSQL server version
##
version: 8.0.35

## @param mode MySQL cluster topology, wesql, wesql-proxy, wesql-proxy-etcd
##
topology: wesql

## @param replicas specify cluster replicas
##
replicas: 1

## @param cpu
##
cpu: 0.5

## @param memory, the unit is Gi
##
memory: 1

## @param requests.cpu if not set, use cpu
## @param requests.memory, if not set, use memory
##
requests:
# cpu:
# memory:

## @param storage size, the unit is Gi
##
storage: 20

proxy:
storageClassName: ""

## customized default values to override kblib chart's values
extra:
disableExporter: true
rbacEnabled: true
terminationPolicy: Delete


etcd:
serviceReference:
endpoint: "" # ex: etcd-cluster-etcd-headless.default.svc.cluster.local:2379
serviceVersion: 3.5.6
etcdctlApi: "3" # the etcd tool etcdctl api version
replicas: 3 # no support other num
resources:
storage: 20Gi

objectStore:
provider: aws
region: us-west-1
bucket: wesql-storage
repoId: db
branchId: main
accessKey:
secretKey:
Loading
Loading