From eaf53bc595837707f7e811039266a0e0e2b2d49f Mon Sep 17 00:00:00 2001 From: xuriwuyun Date: Tue, 14 Jan 2025 14:45:39 +0800 Subject: [PATCH 1/9] feat: support mysql group replication --- addons/mysql/config/mysql-group-replication.tpl | 7 +++++++ addons/mysql/templates/_helpers.tpl | 4 ++++ addons/mysql/templates/config-templates.yaml | 12 ++++++++++++ 3 files changed, 23 insertions(+) create mode 100644 addons/mysql/config/mysql-group-replication.tpl diff --git a/addons/mysql/config/mysql-group-replication.tpl b/addons/mysql/config/mysql-group-replication.tpl new file mode 100644 index 000000000..da263b649 --- /dev/null +++ b/addons/mysql/config/mysql-group-replication.tpl @@ -0,0 +1,7 @@ +binlog_checksum=NONE +plugin_load_add='group_replication.so' +group_replication_group_name= {{ .CLUSTER_UUID }} +group_replication_start_on_boot=off +#group_replication_local_address= "s1:33061" +#group_replication_group_seeds= "s1:33061,s2:33061,s3:33061" +group_replication_bootstrap_group=off \ No newline at end of file diff --git a/addons/mysql/templates/_helpers.tpl b/addons/mysql/templates/_helpers.tpl index 0fdea1968..30d3206ab 100644 --- a/addons/mysql/templates/_helpers.tpl +++ b/addons/mysql/templates/_helpers.tpl @@ -113,6 +113,10 @@ vars: valueFrom: clusterVarRef: clusterName: Required + - name: CLUSTER_UUID + valueFrom: + clusterVarRef: + clusterUID: Required - name: CLUSTER_NAMESPACE valueFrom: clusterVarRef: diff --git a/addons/mysql/templates/config-templates.yaml b/addons/mysql/templates/config-templates.yaml index 2135ccf52..d0047809f 100644 --- a/addons/mysql/templates/config-templates.yaml +++ b/addons/mysql/templates/config-templates.yaml @@ -18,3 +18,15 @@ metadata: data: my.cnf: |- {{- .Files.Get "config/mysql8.0-config.tpl" | nindent 4 }} + +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: mysql-8.0-mgr-config-template + labels: + {{- include "mysql.labels" . | nindent 4 }} +data: + my.cnf: |- + {{- .Files.Get "config/mysql8.0-config.tpl" | nindent 4 }} + {{- .Files.Get "config/mysql-group-replication.tpl" | nindent 4 }} From 970ba44da3846732b79b889da700eafab465bcb6 Mon Sep 17 00:00:00 2001 From: xuriwuyun Date: Tue, 14 Jan 2025 17:49:45 +0800 Subject: [PATCH 2/9] update --- addons-cluster/mysql/values.schema.json | 1 + addons-cluster/mysql/values.yaml | 5 +- .../mysql/config/mysql-group-replication.tpl | 9 +- addons/mysql/templates/_names.tpl | 8 ++ addons/mysql/templates/clusterdefinition.yaml | 4 + addons/mysql/templates/cmpd-mysql80-mgr.yaml | 130 ++++++++++++++++++ addons/mysql/templates/cpmv-mgr.yaml | 104 ++++++++++++++ 7 files changed, 255 insertions(+), 6 deletions(-) create mode 100644 addons/mysql/templates/cmpd-mysql80-mgr.yaml create mode 100644 addons/mysql/templates/cpmv-mgr.yaml diff --git a/addons-cluster/mysql/values.schema.json b/addons-cluster/mysql/values.schema.json index 19d01e9a0..298117d14 100644 --- a/addons-cluster/mysql/values.schema.json +++ b/addons-cluster/mysql/values.schema.json @@ -77,6 +77,7 @@ "enum": [ "semisync", "semisync-proxysql", + "mgr", "orc", "orc-proxysql" ] diff --git a/addons-cluster/mysql/values.yaml b/addons-cluster/mysql/values.yaml index a134382e2..4f14f5809 100644 --- a/addons-cluster/mysql/values.yaml +++ b/addons-cluster/mysql/values.yaml @@ -12,7 +12,7 @@ mode: standalone ## @param replicas specify cluster replicas ## -replicas: 1 +replicas: 2 ## @param cpu ## @@ -32,7 +32,7 @@ requests: ## @param storage size, the unit is Gi ## storage: 20 -topology: semisync +topology: mgr proxysql: replicas: 1 cpu: 1 @@ -41,6 +41,7 @@ proxysql: ## @param extra.rbacEnabled if true, create rbac extra: terminationPolicy: Delete + disableExporter: true orchestrator: # monitor_password: proxysql diff --git a/addons/mysql/config/mysql-group-replication.tpl b/addons/mysql/config/mysql-group-replication.tpl index da263b649..a9a636cdb 100644 --- a/addons/mysql/config/mysql-group-replication.tpl +++ b/addons/mysql/config/mysql-group-replication.tpl @@ -1,7 +1,8 @@ +[mysqld] binlog_checksum=NONE plugin_load_add='group_replication.so' -group_replication_group_name= {{ .CLUSTER_UUID }} -group_replication_start_on_boot=off +loose_group_replication_group_name= {{ .CLUSTER_UUID }} +loose_group_replication_start_on_boot=off +loose_group_replication_bootstrap_group=off #group_replication_local_address= "s1:33061" -#group_replication_group_seeds= "s1:33061,s2:33061,s3:33061" -group_replication_bootstrap_group=off \ No newline at end of file +#group_replication_group_seeds= "s1:33061,s2:33061,s3:33061" \ No newline at end of file diff --git a/addons/mysql/templates/_names.tpl b/addons/mysql/templates/_names.tpl index 9a890eb16..2dae15285 100644 --- a/addons/mysql/templates/_names.tpl +++ b/addons/mysql/templates/_names.tpl @@ -12,6 +12,10 @@ Define mysql orc component definition name prefix {{ include "mysql.cmpdNamePrefix" . }}-orc {{- end -}} +{{- define "mysql.cmpdMGRNamePrefix" -}} +{{ include "mysql.cmpdNamePrefix" . }}-mgr +{{- end -}} + {{/* Define mysql component definition regex regular */}} @@ -47,6 +51,10 @@ Define mysql component definition name {{- printf "%s-8.0-%s" (include "mysql.cmpdOrcNamePrefix" .) .Chart.Version -}} {{- end -}} +{{- define "mysql.componentDefNameMGR80" -}} +{{- printf "%s-8.0-%s" (include "mysql.cmpdMGRNamePrefix" .) .Chart.Version -}} +{{- end -}} + {{/* Define mysql component definition name */}} diff --git a/addons/mysql/templates/clusterdefinition.yaml b/addons/mysql/templates/clusterdefinition.yaml index 7a50cfe96..bcd2a33ca 100644 --- a/addons/mysql/templates/clusterdefinition.yaml +++ b/addons/mysql/templates/clusterdefinition.yaml @@ -13,6 +13,10 @@ spec: - name: mysql compDef: {{ include "mysql.componentDefRegex" . }} default: true + - name: mgr + components: + - name: mysql + compDef: {{ include "mysql.cmpdMGRNamePrefix" . }} - name: orc components: - name: mysql diff --git a/addons/mysql/templates/cmpd-mysql80-mgr.yaml b/addons/mysql/templates/cmpd-mysql80-mgr.yaml new file mode 100644 index 000000000..686dc5c17 --- /dev/null +++ b/addons/mysql/templates/cmpd-mysql80-mgr.yaml @@ -0,0 +1,130 @@ +apiVersion: apps.kubeblocks.io/v1 +kind: ComponentDefinition +metadata: + name: {{ include "mysql.componentDefNameMGR80" . }} + labels: + {{- include "mysql.labels" . | nindent 4 }} + annotations: + {{- include "mysql.annotations" . | nindent 4 }} +spec: + {{- include "mysql.spec.common" . | nindent 2 }} + serviceVersion: 8.0.33 + configs: + - name: mysql-replication-config + templateRef: mysql-8.0-mgr-config-template + constraintRef: mysql-8.0-config-constraints + volumeName: mysql-config + namespace: {{ .Release.Namespace }} + reRenderResourceTypes: + - vscale + runtime: + initContainers: + - image: {{ .Values.image.registry | default "docker.io" }}/apecloud/mysql_audit_log:8.0.33 + name: init-data + command: + - bash + - -c + - | + mkdir -p {{ .Values.dataMountPath }}/{log,binlog,auditlog} + cp /usr/lib/mysql/plugin/ {{ .Values.dataMountPath }}/plugin -r + imagePullPolicy: {{ default .Values.image.pullPolicy "IfNotPresent" }} + volumeMounts: + - mountPath: {{ .Values.dataMountPath }} + name: data + - command: + - cp + - -r + - /xtrabackup + - /tools/xtrabackup + image: {{ .Values.image.registry | default "docker.io" }}/apecloud/xtrabackup:8.0 + imagePullPolicy: {{ default "IfNotPresent" .Values.image.pullPolicy }} + name: init-xtrabackup + volumeMounts: + - mountPath: /tools + name: tools + - command: + - cp + - -r + - /jemalloc/lib/ + - /tools/lib + image: {{ .Values.image.registry | default "docker.io" }}/apecloud/jemalloc:5.3.0 + imagePullPolicy: {{ default "IfNotPresent" .Values.image.pullPolicy }} + name: init-jemalloc + volumeMounts: + - mountPath: /tools + name: tools + {{- include "mysql.spec.runtime.common" . | nindent 6 }} + containers: + - name: mysql + image: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.repository }}:8.0.33 + imagePullPolicy: {{ default .Values.image.pullPolicy "IfNotPresent" }} + command: + - syncer + - --disable-ha + - --port + - "3601" + - -- + - bash + - -c + - | + cp {{ .Values.dataMountPath }}/plugin/audit_log.so /usr/lib64/mysql/plugin/ + chown -R mysql:root {{ .Values.dataMountPath }} + export LD_PRELOAD=/tools/lib/libjemalloc.so.2 + SERVICE_ID=$((${POD_NAME##*-} + 1)) + docker-entrypoint.sh mysqld --server-id $SERVICE_ID \ + --plugin-load-add=rpl_semi_sync_source=semisync_source.so \ + --plugin-load-add=rpl_semi_sync_replica=semisync_replica.so \ + --plugin-load-add=audit_log=audit_log.so \ + --log-bin=/var/lib/mysql/binlog/${POD_NAME}-bin \ + --skip-slave-start=ON + volumeMounts: + - mountPath: {{ .Values.dataMountPath }} + name: data + - mountPath: /etc/mysql/conf.d + name: mysql-config + - name: scripts + mountPath: /scripts + - mountPath: /tools + name: tools + ports: + - containerPort: 3306 + name: mysql + - containerPort: 3601 + name: ha + - containerPort: 33061 + name: mgr + env: + - name: PATH + value: /tools/xtrabackup/bin:/tools/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin + - name: KB_ENGINE_TYPE + value: mysql + - name: KB_WORKLOAD_TYPE + value: mgr + - name: MYSQL_INITDB_SKIP_TZINFO + value: "1" + - name: MYSQL_ROOT_HOST + value: {{ .Values.auth.rootHost | default "%" | quote }} + - name: SERVICE_PORT + value: "3306" + - name: POD_NAME + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: metadata.name + - name: POD_NAMESPACE + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: metadata.namespace + - name: POD_UID + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: metadata.uid + - name: POD_IP + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: status.podIP + - name: mysql-exporter + {{- include "mysql.spec.runtime.exporter" . | nindent 8 }} diff --git a/addons/mysql/templates/cpmv-mgr.yaml b/addons/mysql/templates/cpmv-mgr.yaml new file mode 100644 index 000000000..bf11450ca --- /dev/null +++ b/addons/mysql/templates/cpmv-mgr.yaml @@ -0,0 +1,104 @@ +apiVersion: apps.kubeblocks.io/v1 +kind: ComponentVersion +metadata: + name: mysql-mgr + labels: + {{- include "mysql.labels" . | nindent 4 }} + annotations: + {{- include "mysql.apiVersion" . | nindent 4 }} +spec: + compatibilityRules: + - compDefs: + - {{ include "mysql.componentDefNameMGR80" . }} + releases: + - 8.0.30 + - 8.0.31 + - 8.0.32 + - 8.0.33 + - 8.0.34 + - 8.0.35 + - 8.0.36 + - 8.0.37 + - 8.0.38 + - 8.0.39 + releases: + - name: 8.0.30 + changes: + serviceVersion: 8.0.30 + images: + mysql: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.repository }}:8.0.30 + init-data: {{ .Values.image.registry | default "docker.io" }}/apecloud/mysql_audit_log:8.0.33 + init-xtrabackup: {{ .Values.image.registry | default "docker.io" }}/apecloud/xtrabackup:8.0 + {{- include "mysql.spec.runtime.images" . | nindent 8 }} + - name: 8.0.31 + changes: + serviceVersion: 8.0.31 + images: + mysql: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.repository }}:8.0.31 + init-data: {{ .Values.image.registry | default "docker.io" }}/apecloud/mysql_audit_log:8.0.33 + init-xtrabackup: {{ .Values.image.registry | default "docker.io" }}/apecloud/xtrabackup:8.0 + {{- include "mysql.spec.runtime.images" . | nindent 8 }} + - name: 8.0.32 + changes: + serviceVersion: 8.0.32 + images: + mysql: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.repository }}:8.0.32 + init-data: {{ .Values.image.registry | default "docker.io" }}/apecloud/mysql_audit_log:8.0.33 + init-xtrabackup: {{ .Values.image.registry | default "docker.io" }}/apecloud/xtrabackup:8.0 + {{- include "mysql.spec.runtime.images" . | nindent 8 }} + - name: 8.0.33 + changes: + serviceVersion: 8.0.33 + images: + mysql: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.repository }}:8.0.33 + init-data: {{ .Values.image.registry | default "docker.io" }}/apecloud/mysql_audit_log:8.0.33 + init-xtrabackup: {{ .Values.image.registry | default "docker.io" }}/apecloud/xtrabackup:8.0 + {{- include "mysql.spec.runtime.images" . | nindent 8 }} + - name: 8.0.34 + changes: + serviceVersion: 8.0.34 + images: + mysql: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.repository }}:8.0.34 + init-data: {{ .Values.image.registry | default "docker.io" }}/apecloud/mysql_audit_log:8.0.33 + init-xtrabackup: {{ .Values.image.registry | default "docker.io" }}/apecloud/xtrabackup:8.0 + {{- include "mysql.spec.runtime.images" . | nindent 8 }} + - name: 8.0.35 + changes: + serviceVersion: 8.0.35 + images: + mysql: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.repository }}:8.0.35 + init-data: {{ .Values.image.registry | default "docker.io" }}/apecloud/mysql_audit_log:8.0.33 + init-xtrabackup: {{ .Values.image.registry | default "docker.io" }}/apecloud/xtrabackup:8.0 + {{- include "mysql.spec.runtime.images" . | nindent 8 }} + - name: 8.0.36 + changes: + serviceVersion: 8.0.36 + images: + mysql: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.repository }}:8.0.36 + init-data: {{ .Values.image.registry | default "docker.io" }}/apecloud/mysql_audit_log:8.0.33 + init-xtrabackup: {{ .Values.image.registry | default "docker.io" }}/apecloud/xtrabackup:8.0 + {{- include "mysql.spec.runtime.images" . | nindent 8 }} + - name: 8.0.37 + changes: + serviceVersion: 8.0.37 + images: + mysql: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.repository }}:8.0.37 + init-data: {{ .Values.image.registry | default "docker.io" }}/apecloud/mysql_audit_log:8.0.33 + init-xtrabackup: {{ .Values.image.registry | default "docker.io" }}/apecloud/xtrabackup:8.0 + {{- include "mysql.spec.runtime.images" . | nindent 8 }} + - name: 8.0.38 + changes: + serviceVersion: 8.0.38 + images: + mysql: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.repository }}:8.0.38 + init-data: {{ .Values.image.registry | default "docker.io" }}/apecloud/mysql_audit_log:8.0.33 + init-xtrabackup: {{ .Values.image.registry | default "docker.io" }}/apecloud/xtrabackup:8.0 + {{- include "mysql.spec.runtime.images" . | nindent 8 }} + - name: 8.0.39 + changes: + serviceVersion: 8.0.39 + images: + mysql: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.repository }}:8.0.39 + init-data: {{ .Values.image.registry | default "docker.io" }}/apecloud/mysql_audit_log:8.0.33 + init-xtrabackup: {{ .Values.image.registry | default "docker.io" }}/apecloud/xtrabackup:8.0 + {{- include "mysql.spec.runtime.images" . | nindent 8 }} \ No newline at end of file From f666199012b1f6902389789eb0c070e48bf0de56 Mon Sep 17 00:00:00 2001 From: xuriwuyun Date: Tue, 14 Jan 2025 09:50:07 +0000 Subject: [PATCH 3/9] chore: auto generated files --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a8d44e325..764f33af0 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ KubeBlocks add-ons. | minio | minio-2024.6.29 | High Performance, Kubernetes Native Object Storage | fengluodb | | mogdb | mogdb-5.0.5 | A Helm chart for Kubernetes | yabinji shanshanying | | mongodb | mongodb-4.0.28
mongodb-4.2.24
mongodb-4.4.29
mongodb-5.0.28
mongodb-6.0.16
mongodb-7.0.12 | MongoDB is a document database designed for ease of application development and scaling. | xuriwuyun | -| mysql | mysql-5.7.44
mysql-8.0.30
mysql-8.0.31
mysql-8.0.32
mysql-8.0.33
mysql-8.0.34
mysql-8.0.35
mysql-8.0.36
mysql-8.0.37
mysql-8.0.38
mysql-8.0.39
mysql-8.4.0
mysql-8.4.1
mysql-8.4.2
mysql-orc-5.7.44
mysql-orc-8.0.30
mysql-orc-8.0.31
mysql-orc-8.0.32
mysql-orc-8.0.33
mysql-orc-8.0.34
mysql-orc-8.0.35
mysql-orc-8.0.36
mysql-orc-8.0.37
mysql-orc-8.0.38
mysql-orc-8.0.39
mysql-proxysql-2.4.4 | MySQL is a widely used, open-source relational database management system (RDBMS) | xuriwuyun | +| mysql | mysql-5.7.44
mysql-8.0.30
mysql-8.0.31
mysql-8.0.32
mysql-8.0.33
mysql-8.0.34
mysql-8.0.35
mysql-8.0.36
mysql-8.0.37
mysql-8.0.38
mysql-8.0.39
mysql-8.4.0
mysql-8.4.1
mysql-8.4.2
mysql-mgr-8.0.30
mysql-mgr-8.0.31
mysql-mgr-8.0.32
mysql-mgr-8.0.33
mysql-mgr-8.0.34
mysql-mgr-8.0.35
mysql-mgr-8.0.36
mysql-mgr-8.0.37
mysql-mgr-8.0.38
mysql-mgr-8.0.39
mysql-orc-5.7.44
mysql-orc-8.0.30
mysql-orc-8.0.31
mysql-orc-8.0.32
mysql-orc-8.0.33
mysql-orc-8.0.34
mysql-orc-8.0.35
mysql-orc-8.0.36
mysql-orc-8.0.37
mysql-orc-8.0.38
mysql-orc-8.0.39
mysql-proxysql-2.4.4 | MySQL is a widely used, open-source relational database management system (RDBMS) | xuriwuyun | | nebula | nebula-v3.5.0 | NebulaGraph is a popular open-source graph database that can handle large volumes of data with milliseconds of latency, scale up quickly, and have the ability to perform fast graph analytics. | shanshanying Xuntao Cheng | | neon | neon-broker-1.0.0
neon-compute-1.0.0
neon-pageserver-1.0.0
neon-safekeeper-1.0.0 | Neon is a serverless open-source alternative to AWS Aurora Postgres. It separates storage and compute and substitutes the PostgreSQL storage layer by redistributing data across a cluster of nodes. | skyrise-l | | oceanbase-ce | oceanbase-ce-4.3.0 | OceanBase has served over 400 customers across the globe and has been supporting all mission critical systems in Alipay. | Powerfooi shanshanying | From ca2bcf0f1b18a42768cc27318534d3206bee5561 Mon Sep 17 00:00:00 2001 From: xuriwuyun Date: Fri, 17 Jan 2025 18:57:08 +0800 Subject: [PATCH 4/9] update --- .../mysql/config/mysql-group-replication.tpl | 9 +- addons/mysql/config/mysql5.7-config.tpl | 4 - addons/mysql/config/mysql8.0-config.tpl | 4 - addons/mysql/templates/_helpers.tpl | 52 +++++++++ addons/mysql/templates/_names.tpl | 4 + addons/mysql/templates/cmpd-mysql80-mgr.yaml | 16 +-- addons/mysql/templates/cmpd-mysql84-mgr.yaml | 108 ++++++++++++++++++ addons/mysql/templates/cpmv-mgr.yaml | 50 ++++++-- addons/mysql/values.yaml | 2 +- 9 files changed, 213 insertions(+), 36 deletions(-) create mode 100644 addons/mysql/templates/cmpd-mysql84-mgr.yaml diff --git a/addons/mysql/config/mysql-group-replication.tpl b/addons/mysql/config/mysql-group-replication.tpl index a9a636cdb..fd8223920 100644 --- a/addons/mysql/config/mysql-group-replication.tpl +++ b/addons/mysql/config/mysql-group-replication.tpl @@ -1,8 +1,9 @@ [mysqld] +binlog_format=ROW binlog_checksum=NONE plugin_load_add='group_replication.so' -loose_group_replication_group_name= {{ .CLUSTER_UUID }} +plugin_load_add='mysql_clone.so' +group_replication_ip_allowlist="0.0.0.0/0" +loose_group_replication_recovery_get_public_key=ON loose_group_replication_start_on_boot=off -loose_group_replication_bootstrap_group=off -#group_replication_local_address= "s1:33061" -#group_replication_group_seeds= "s1:33061,s2:33061,s3:33061" \ No newline at end of file +loose_group_replication_bootstrap_group=off \ No newline at end of file diff --git a/addons/mysql/config/mysql5.7-config.tpl b/addons/mysql/config/mysql5.7-config.tpl index 551582aee..1277543e4 100644 --- a/addons/mysql/config/mysql5.7-config.tpl +++ b/addons/mysql/config/mysql5.7-config.tpl @@ -166,10 +166,6 @@ character_set_server = utf8mb4 # rpl_semi_sync_master_timeout = 1000 # rpl-semi-sync-slave-enabled = 1 -[mysql] -default-character-set=utf8mb4 - [client] port={{ $mysql_port }} socket=/var/run/mysqld/mysqld.sock -default-character-set=utf8mb4 diff --git a/addons/mysql/config/mysql8.0-config.tpl b/addons/mysql/config/mysql8.0-config.tpl index f81843e15..f72d779fb 100644 --- a/addons/mysql/config/mysql8.0-config.tpl +++ b/addons/mysql/config/mysql8.0-config.tpl @@ -198,10 +198,6 @@ default_tmp_storage_engine=innodb collation_server = utf8mb4_unicode_520_ci character_set_server = utf8mb4 -[mysql] -default-character-set=utf8mb4 - [client] port={{ $mysql_port }} socket=/var/run/mysqld/mysqld.sock -default-character-set=utf8mb4 diff --git a/addons/mysql/templates/_helpers.tpl b/addons/mysql/templates/_helpers.tpl index 30d3206ab..73b21d044 100644 --- a/addons/mysql/templates/_helpers.tpl +++ b/addons/mysql/templates/_helpers.tpl @@ -108,6 +108,25 @@ systemAccounts: numDigits: 5 numSymbols: 0 letterCase: MixedCases + - name: kbadmin + statement: select 1; + passwordGenerationPolicy: &defaultPasswordGenerationPolicy + length: 16 + numDigits: 8 + numSymbols: 0 + letterCase: MixedCases + - name: kbdataprotection + statement: CREATE USER ${KB_ACCOUNT_NAME} IDENTIFIED BY '${KB_ACCOUNT_PASSWORD}';GRANT RELOAD, LOCK TABLES, PROCESS, REPLICATION CLIENT ON ${ALL_DB} TO ${KB_ACCOUNT_NAME}; GRANT LOCK TABLES,RELOAD,PROCESS,REPLICATION CLIENT, SUPER,SELECT,EVENT,TRIGGER,SHOW VIEW ON ${ALL_DB} TO ${KB_ACCOUNT_NAME}; + passwordGenerationPolicy: *defaultPasswordGenerationPolicy + - name: kbprobe + statement: CREATE USER ${KB_ACCOUNT_NAME} IDENTIFIED BY '${KB_ACCOUNT_PASSWORD}'; GRANT REPLICATION CLIENT, PROCESS ON ${ALL_DB} TO ${KB_ACCOUNT_NAME}; GRANT SELECT ON performance_schema.* TO ${KB_ACCOUNT_NAME}; + passwordGenerationPolicy: *defaultPasswordGenerationPolicy + - name: kbmonitoring + statement: CREATE USER ${KB_ACCOUNT_NAME} IDENTIFIED BY '${KB_ACCOUNT_PASSWORD}'; GRANT REPLICATION CLIENT, PROCESS ON ${ALL_DB} TO ${KB_ACCOUNT_NAME}; GRANT SELECT ON performance_schema.* TO ${KB_ACCOUNT_NAME}; + passwordGenerationPolicy: *defaultPasswordGenerationPolicy + - name: kbreplicator + statement: select 1; + passwordGenerationPolicy: *defaultPasswordGenerationPolicy vars: - name: CLUSTER_NAME valueFrom: @@ -141,7 +160,40 @@ vars: credentialVarRef: name: root password: Required + - name: MYSQL_ADMIN_USER + valueFrom: + credentialVarRef: + name: kbadmin + username: Required + - name: MYSQL_ADMIN_PASSWORD + valueFrom: + credentialVarRef: + name: kbadmin + password: Required + - name: MYSQL_REPLICATION_USER + valueFrom: + credentialVarRef: + name: kbreplicator + username: Required + - name: MYSQL_REPLICATION_PASSWORD + valueFrom: + credentialVarRef: + name: kbreplicator + password: Required lifecycleActions: + accountProvision: + exec: + container: mysql + command: + - bash + - -c + - | + set -ex + ALL_DB='*.*' + eval statement=\"${KB_ACCOUNT_STATEMENT}\" + mysql -u${MYSQL_ROOT_USER} -p${MYSQL_ROOT_PASSWORD} -P3306 -h127.0.0.1 -e "${statement}" + targetPodSelector: Role + matchingKey: primary roleProbe: periodSeconds: {{ .Values.roleProbe.periodSeconds }} timeoutSeconds: {{ .Values.roleProbe.timeoutSeconds }} diff --git a/addons/mysql/templates/_names.tpl b/addons/mysql/templates/_names.tpl index 2dae15285..933d413f7 100644 --- a/addons/mysql/templates/_names.tpl +++ b/addons/mysql/templates/_names.tpl @@ -62,6 +62,10 @@ Define mysql component definition name {{- printf "%s-8.4-%s" (include "mysql.cmpdNamePrefix" .) .Chart.Version -}} {{- end -}} +{{- define "mysql.componentDefNameMGR84" -}} +{{- printf "%s-8.4-%s" (include "mysql.cmpdMGRNamePrefix" .) .Chart.Version -}} +{{- end -}} + {{/* Define mysql component definition name */}} diff --git a/addons/mysql/templates/cmpd-mysql80-mgr.yaml b/addons/mysql/templates/cmpd-mysql80-mgr.yaml index 686dc5c17..69d45a3d8 100644 --- a/addons/mysql/templates/cmpd-mysql80-mgr.yaml +++ b/addons/mysql/templates/cmpd-mysql80-mgr.yaml @@ -31,17 +31,6 @@ spec: volumeMounts: - mountPath: {{ .Values.dataMountPath }} name: data - - command: - - cp - - -r - - /xtrabackup - - /tools/xtrabackup - image: {{ .Values.image.registry | default "docker.io" }}/apecloud/xtrabackup:8.0 - imagePullPolicy: {{ default "IfNotPresent" .Values.image.pullPolicy }} - name: init-xtrabackup - volumeMounts: - - mountPath: /tools - name: tools - command: - cp - -r @@ -60,7 +49,6 @@ spec: imagePullPolicy: {{ default .Values.image.pullPolicy "IfNotPresent" }} command: - syncer - - --disable-ha - --port - "3601" - -- @@ -69,9 +57,9 @@ spec: - | cp {{ .Values.dataMountPath }}/plugin/audit_log.so /usr/lib64/mysql/plugin/ chown -R mysql:root {{ .Values.dataMountPath }} - export LD_PRELOAD=/tools/lib/libjemalloc.so.2 SERVICE_ID=$((${POD_NAME##*-} + 1)) docker-entrypoint.sh mysqld --server-id $SERVICE_ID \ + --report-host ${POD_NAME}.${CLUSTER_COMPONENT_NAME}-headless \ --plugin-load-add=rpl_semi_sync_source=semisync_source.so \ --plugin-load-add=rpl_semi_sync_replica=semisync_replica.so \ --plugin-load-add=audit_log=audit_log.so \ @@ -96,6 +84,8 @@ spec: env: - name: PATH value: /tools/xtrabackup/bin:/tools/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin + - name: LD_PRELOAD + value: /tools/lib/libjemalloc.so.2 - name: KB_ENGINE_TYPE value: mysql - name: KB_WORKLOAD_TYPE diff --git a/addons/mysql/templates/cmpd-mysql84-mgr.yaml b/addons/mysql/templates/cmpd-mysql84-mgr.yaml new file mode 100644 index 000000000..152bf6814 --- /dev/null +++ b/addons/mysql/templates/cmpd-mysql84-mgr.yaml @@ -0,0 +1,108 @@ +apiVersion: apps.kubeblocks.io/v1 +kind: ComponentDefinition +metadata: + name: {{ include "mysql.componentDefNameMGR84" . }} + labels: + {{- include "mysql.labels" . | nindent 4 }} + annotations: + {{- include "mysql.annotations" . | nindent 4 }} +spec: + {{- include "mysql.spec.common" . | nindent 2 }} + serviceVersion: 8.4.2 + configs: + - name: mysql-replication-config + templateRef: mysql-8.0-mgr-config-template + constraintRef: mysql-8.0-config-constraints + volumeName: mysql-config + namespace: {{ .Release.Namespace }} + reRenderResourceTypes: + - vscale + runtime: + initContainers: + - command: + - cp + - -r + - /jemalloc/lib/ + - /tools/lib + image: {{ .Values.image.registry | default "docker.io" }}/apecloud/jemalloc:5.3.0 + imagePullPolicy: {{ default "IfNotPresent" .Values.image.pullPolicy }} + name: init-jemalloc + volumeMounts: + - mountPath: /tools + name: tools + {{- include "mysql.spec.runtime.common" . | nindent 6 }} + containers: + - name: mysql + image: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.repository }}:8.4.2 + imagePullPolicy: {{ default .Values.image.pullPolicy "IfNotPresent" }} + command: + - syncer + - --port + - "3601" + - -- + - bash + - -c + - | + mkdir -p {{ .Values.dataMountPath }}/{log,binlog,auditlog} + chown -R mysql:root {{ .Values.dataMountPath }} + export LD_PRELOAD=/tools/lib/libjemalloc.so.2 + SERVICE_ID=$((${POD_NAME##*-} + 1)) + docker-entrypoint.sh mysqld --server-id $SERVICE_ID \ + --report-host ${POD_NAME}.${CLUSTER_COMPONENT_NAME}-headless \ + --plugin-load-add=rpl_semi_sync_source=semisync_source.so \ + --plugin-load-add=rpl_semi_sync_replica=semisync_replica.so \ + --log-bin=/var/lib/mysql/binlog/${POD_NAME}-bin \ + --skip-slave-start=ON + volumeMounts: + - mountPath: {{ .Values.dataMountPath }} + name: data + - mountPath: /etc/mysql/conf.d + name: mysql-config + - name: scripts + mountPath: /scripts + - mountPath: /tools + name: tools + ports: + - containerPort: 3306 + name: mysql + - containerPort: 3601 + name: ha + - containerPort: 33061 + name: mgr + env: + - name: PATH + value: /tools/xtrabackup/bin:/tools/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin + - name: LD_PRELOAD + value: /tools/lib/libjemalloc.so.2 + - name: KB_ENGINE_TYPE + value: mysql + - name: KB_WORKLOAD_TYPE + value: mgr + - name: MYSQL_INITDB_SKIP_TZINFO + value: "1" + - name: MYSQL_ROOT_HOST + value: {{ .Values.auth.rootHost | default "%" | quote }} + - name: SERVICE_PORT + value: "3306" + - name: POD_NAME + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: metadata.name + - name: POD_NAMESPACE + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: metadata.namespace + - name: POD_UID + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: metadata.uid + - name: POD_IP + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: status.podIP + - name: mysql-exporter + {{- include "mysql.spec.runtime.exporter" . | nindent 8 }} diff --git a/addons/mysql/templates/cpmv-mgr.yaml b/addons/mysql/templates/cpmv-mgr.yaml index bf11450ca..cd1c12da0 100644 --- a/addons/mysql/templates/cpmv-mgr.yaml +++ b/addons/mysql/templates/cpmv-mgr.yaml @@ -21,84 +21,114 @@ spec: - 8.0.37 - 8.0.38 - 8.0.39 + - compDefs: + - {{ include "mysql.componentDefName84" . }} + releases: + - 8.4.0 + - 8.4.1 + - 8.4.2 releases: - name: 8.0.30 changes: serviceVersion: 8.0.30 images: mysql: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.repository }}:8.0.30 + accountProvision: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.repository }}:8.0.30 init-data: {{ .Values.image.registry | default "docker.io" }}/apecloud/mysql_audit_log:8.0.33 - init-xtrabackup: {{ .Values.image.registry | default "docker.io" }}/apecloud/xtrabackup:8.0 {{- include "mysql.spec.runtime.images" . | nindent 8 }} - name: 8.0.31 changes: serviceVersion: 8.0.31 images: mysql: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.repository }}:8.0.31 + accountProvision: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.repository }}:8.0.31 init-data: {{ .Values.image.registry | default "docker.io" }}/apecloud/mysql_audit_log:8.0.33 - init-xtrabackup: {{ .Values.image.registry | default "docker.io" }}/apecloud/xtrabackup:8.0 {{- include "mysql.spec.runtime.images" . | nindent 8 }} - name: 8.0.32 changes: serviceVersion: 8.0.32 images: mysql: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.repository }}:8.0.32 + accountProvision: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.repository }}:8.0.32 init-data: {{ .Values.image.registry | default "docker.io" }}/apecloud/mysql_audit_log:8.0.33 - init-xtrabackup: {{ .Values.image.registry | default "docker.io" }}/apecloud/xtrabackup:8.0 {{- include "mysql.spec.runtime.images" . | nindent 8 }} - name: 8.0.33 changes: serviceVersion: 8.0.33 images: mysql: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.repository }}:8.0.33 + accountProvision: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.repository }}:8.0.33 init-data: {{ .Values.image.registry | default "docker.io" }}/apecloud/mysql_audit_log:8.0.33 - init-xtrabackup: {{ .Values.image.registry | default "docker.io" }}/apecloud/xtrabackup:8.0 {{- include "mysql.spec.runtime.images" . | nindent 8 }} - name: 8.0.34 changes: serviceVersion: 8.0.34 images: mysql: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.repository }}:8.0.34 + accountProvision: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.repository }}:8.0.34 init-data: {{ .Values.image.registry | default "docker.io" }}/apecloud/mysql_audit_log:8.0.33 - init-xtrabackup: {{ .Values.image.registry | default "docker.io" }}/apecloud/xtrabackup:8.0 {{- include "mysql.spec.runtime.images" . | nindent 8 }} - name: 8.0.35 changes: serviceVersion: 8.0.35 images: mysql: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.repository }}:8.0.35 + accountProvision: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.repository }}:8.0.35 init-data: {{ .Values.image.registry | default "docker.io" }}/apecloud/mysql_audit_log:8.0.33 - init-xtrabackup: {{ .Values.image.registry | default "docker.io" }}/apecloud/xtrabackup:8.0 {{- include "mysql.spec.runtime.images" . | nindent 8 }} - name: 8.0.36 changes: serviceVersion: 8.0.36 images: mysql: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.repository }}:8.0.36 + accountProvision: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.repository }}:8.0.36 init-data: {{ .Values.image.registry | default "docker.io" }}/apecloud/mysql_audit_log:8.0.33 - init-xtrabackup: {{ .Values.image.registry | default "docker.io" }}/apecloud/xtrabackup:8.0 {{- include "mysql.spec.runtime.images" . | nindent 8 }} - name: 8.0.37 changes: serviceVersion: 8.0.37 images: mysql: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.repository }}:8.0.37 + accountProvision: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.repository }}:8.0.37 init-data: {{ .Values.image.registry | default "docker.io" }}/apecloud/mysql_audit_log:8.0.33 - init-xtrabackup: {{ .Values.image.registry | default "docker.io" }}/apecloud/xtrabackup:8.0 {{- include "mysql.spec.runtime.images" . | nindent 8 }} - name: 8.0.38 changes: serviceVersion: 8.0.38 images: mysql: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.repository }}:8.0.38 + accountProvision: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.repository }}:8.0.38 init-data: {{ .Values.image.registry | default "docker.io" }}/apecloud/mysql_audit_log:8.0.33 - init-xtrabackup: {{ .Values.image.registry | default "docker.io" }}/apecloud/xtrabackup:8.0 {{- include "mysql.spec.runtime.images" . | nindent 8 }} - name: 8.0.39 changes: serviceVersion: 8.0.39 images: mysql: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.repository }}:8.0.39 + accountProvision: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.repository }}:8.0.39 init-data: {{ .Values.image.registry | default "docker.io" }}/apecloud/mysql_audit_log:8.0.33 - init-xtrabackup: {{ .Values.image.registry | default "docker.io" }}/apecloud/xtrabackup:8.0 + {{- include "mysql.spec.runtime.images" . | nindent 8 }} + - name: 8.4.0 + changes: + serviceVersion: 8.4.0 + images: + mysql: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.repository }}:8.4.0 + accountProvision: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.repository }}:8.4.0 + init-xtrabackup: {{ .Values.image.registry | default "docker.io" }}/apecloud/xtrabackup:8.4 + {{- include "mysql.spec.runtime.images" . | nindent 8 }} + - name: 8.4.1 + changes: + serviceVersion: 8.4.1 + images: + mysql: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.repository }}:8.4.1 + accountProvision: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.repository }}:8.4.1 + init-xtrabackup: {{ .Values.image.registry | default "docker.io" }}/apecloud/xtrabackup:8.4 + {{- include "mysql.spec.runtime.images" . | nindent 8 }} + - name: 8.4.2 + changes: + serviceVersion: 8.4.2 + images: + mysql: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.repository }}:8.4.2 + accountProvision: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.repository }}:8.4.2 + init-xtrabackup: {{ .Values.image.registry | default "docker.io" }}/apecloud/xtrabackup:8.4 {{- include "mysql.spec.runtime.images" . | nindent 8 }} \ No newline at end of file diff --git a/addons/mysql/values.yaml b/addons/mysql/values.yaml index b9b3d7789..87fe3ea58 100644 --- a/addons/mysql/values.yaml +++ b/addons/mysql/values.yaml @@ -16,7 +16,7 @@ image: repository: apecloud/percona-xtrabackup syncer: repository: apecloud/syncer - tag: 0.4.1 + tag: 0.5.0 # refer: addons/mysql/orc-tools/Dockerfile orcTools: repository: apecloud/orc-tools From 72a62751eddc09a52d6bb341d43b04a7a34812f3 Mon Sep 17 00:00:00 2001 From: xuriwuyun Date: Fri, 17 Jan 2025 10:57:28 +0000 Subject: [PATCH 5/9] chore: auto generated files --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 764f33af0..8019d4198 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ KubeBlocks add-ons. | minio | minio-2024.6.29 | High Performance, Kubernetes Native Object Storage | fengluodb | | mogdb | mogdb-5.0.5 | A Helm chart for Kubernetes | yabinji shanshanying | | mongodb | mongodb-4.0.28
mongodb-4.2.24
mongodb-4.4.29
mongodb-5.0.28
mongodb-6.0.16
mongodb-7.0.12 | MongoDB is a document database designed for ease of application development and scaling. | xuriwuyun | -| mysql | mysql-5.7.44
mysql-8.0.30
mysql-8.0.31
mysql-8.0.32
mysql-8.0.33
mysql-8.0.34
mysql-8.0.35
mysql-8.0.36
mysql-8.0.37
mysql-8.0.38
mysql-8.0.39
mysql-8.4.0
mysql-8.4.1
mysql-8.4.2
mysql-mgr-8.0.30
mysql-mgr-8.0.31
mysql-mgr-8.0.32
mysql-mgr-8.0.33
mysql-mgr-8.0.34
mysql-mgr-8.0.35
mysql-mgr-8.0.36
mysql-mgr-8.0.37
mysql-mgr-8.0.38
mysql-mgr-8.0.39
mysql-orc-5.7.44
mysql-orc-8.0.30
mysql-orc-8.0.31
mysql-orc-8.0.32
mysql-orc-8.0.33
mysql-orc-8.0.34
mysql-orc-8.0.35
mysql-orc-8.0.36
mysql-orc-8.0.37
mysql-orc-8.0.38
mysql-orc-8.0.39
mysql-proxysql-2.4.4 | MySQL is a widely used, open-source relational database management system (RDBMS) | xuriwuyun | +| mysql | mysql-5.7.44
mysql-8.0.30
mysql-8.0.31
mysql-8.0.32
mysql-8.0.33
mysql-8.0.34
mysql-8.0.35
mysql-8.0.36
mysql-8.0.37
mysql-8.0.38
mysql-8.0.39
mysql-8.4.0
mysql-8.4.1
mysql-8.4.2
mysql-mgr-8.0.30
mysql-mgr-8.0.31
mysql-mgr-8.0.32
mysql-mgr-8.0.33
mysql-mgr-8.0.34
mysql-mgr-8.0.35
mysql-mgr-8.0.36
mysql-mgr-8.0.37
mysql-mgr-8.0.38
mysql-mgr-8.0.39
mysql-mgr-8.4.0
mysql-mgr-8.4.1
mysql-mgr-8.4.2
mysql-orc-5.7.44
mysql-orc-8.0.30
mysql-orc-8.0.31
mysql-orc-8.0.32
mysql-orc-8.0.33
mysql-orc-8.0.34
mysql-orc-8.0.35
mysql-orc-8.0.36
mysql-orc-8.0.37
mysql-orc-8.0.38
mysql-orc-8.0.39
mysql-proxysql-2.4.4 | MySQL is a widely used, open-source relational database management system (RDBMS) | xuriwuyun | | nebula | nebula-v3.5.0 | NebulaGraph is a popular open-source graph database that can handle large volumes of data with milliseconds of latency, scale up quickly, and have the ability to perform fast graph analytics. | shanshanying Xuntao Cheng | | neon | neon-broker-1.0.0
neon-compute-1.0.0
neon-pageserver-1.0.0
neon-safekeeper-1.0.0 | Neon is a serverless open-source alternative to AWS Aurora Postgres. It separates storage and compute and substitutes the PostgreSQL storage layer by redistributing data across a cluster of nodes. | skyrise-l | | oceanbase-ce | oceanbase-ce-4.3.0 | OceanBase has served over 400 customers across the globe and has been supporting all mission critical systems in Alipay. | Powerfooi shanshanying | From f5400cb2562bc70ab4b4234e70cb6e9a37b5af62 Mon Sep 17 00:00:00 2001 From: xuriwuyun Date: Sat, 18 Jan 2025 22:13:02 +0800 Subject: [PATCH 6/9] update --- addons-cluster/mysql/values.schema.json | 7 +++++-- addons/mysql/templates/clusterdefinition.yaml | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/addons-cluster/mysql/values.schema.json b/addons-cluster/mysql/values.schema.json index 298117d14..c4ee63b56 100644 --- a/addons-cluster/mysql/values.schema.json +++ b/addons-cluster/mysql/values.schema.json @@ -24,8 +24,11 @@ "type": "string", "default": "standalone", "enum": [ - "standalone", - "replication" + "semisync", + "semisync-proxysql", + "semisync-orc", + "semisync-orc-proxysql", + "mgr" ] }, "replicas": { diff --git a/addons/mysql/templates/clusterdefinition.yaml b/addons/mysql/templates/clusterdefinition.yaml index bcd2a33ca..85039ec9e 100644 --- a/addons/mysql/templates/clusterdefinition.yaml +++ b/addons/mysql/templates/clusterdefinition.yaml @@ -17,11 +17,11 @@ spec: components: - name: mysql compDef: {{ include "mysql.cmpdMGRNamePrefix" . }} - - name: orc + - name: semisync-orc components: - name: mysql compDef: {{ include "mysql.cmpdOrcNamePrefix" . }} - - name: orc-proxysql + - name: semisync-orc-proxysql components: - name: mysql compDef: {{ include "mysql.cmpdOrcNamePrefix" . }} From 16b112eba0b6eb385a1cb15691dd7b5cc64ecc87 Mon Sep 17 00:00:00 2001 From: xuriwuyun Date: Mon, 20 Jan 2025 09:46:55 +0800 Subject: [PATCH 7/9] update --- addons-cluster/mysql/values.schema.json | 4 ++-- addons/mysql/templates/clusterdefinition.yaml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/addons-cluster/mysql/values.schema.json b/addons-cluster/mysql/values.schema.json index c4ee63b56..e5284abf0 100644 --- a/addons-cluster/mysql/values.schema.json +++ b/addons-cluster/mysql/values.schema.json @@ -26,8 +26,8 @@ "enum": [ "semisync", "semisync-proxysql", - "semisync-orc", - "semisync-orc-proxysql", + "orc", + "orc-proxysql", "mgr" ] }, diff --git a/addons/mysql/templates/clusterdefinition.yaml b/addons/mysql/templates/clusterdefinition.yaml index 85039ec9e..bcd2a33ca 100644 --- a/addons/mysql/templates/clusterdefinition.yaml +++ b/addons/mysql/templates/clusterdefinition.yaml @@ -17,11 +17,11 @@ spec: components: - name: mysql compDef: {{ include "mysql.cmpdMGRNamePrefix" . }} - - name: semisync-orc + - name: orc components: - name: mysql compDef: {{ include "mysql.cmpdOrcNamePrefix" . }} - - name: semisync-orc-proxysql + - name: orc-proxysql components: - name: mysql compDef: {{ include "mysql.cmpdOrcNamePrefix" . }} From 5647540d51a148798e6613b76ef7f1c3ca7138fb Mon Sep 17 00:00:00 2001 From: xuriwuyun Date: Mon, 20 Jan 2025 10:36:02 +0800 Subject: [PATCH 8/9] update --- addons-cluster/mysql/templates/_helpers.tpl | 16 +++++++--------- addons-cluster/mysql/values.schema.json | 13 ------------- addons-cluster/mysql/values.yaml | 4 ---- addons/mysql/config/mysql-group-replication.tpl | 1 - 4 files changed, 7 insertions(+), 27 deletions(-) diff --git a/addons-cluster/mysql/templates/_helpers.tpl b/addons-cluster/mysql/templates/_helpers.tpl index cacf1d4c9..50356be82 100644 --- a/addons-cluster/mysql/templates/_helpers.tpl +++ b/addons-cluster/mysql/templates/_helpers.tpl @@ -1,21 +1,19 @@ {{/* Define replica count. -standalone mode: 1 -replication mode: 2 -raftGroup mode: 3 or more - +semisync: 2 or more +mgr: 3 or more orchestrator mode: 2 or more */}} {{- define "mysql-cluster.replicaCount" -}} {{- if .Values.orchestrator.enable }} replicas: {{ max .Values.replicas 2 }} {{- else }} - {{- if eq .Values.mode "standalone" }} -replicas: 1 - {{- else if eq .Values.mode "replication" }} -replicas: {{ max .Values.replicas 2 }} - {{- else }} + {{- if hasPrefix "semisync" .Values.topology }} +replicas: 2 + {{- else if hasPrefix "mgr" .Values.topology }} replicas: {{ max .Values.replicas 3 }} + {{- else }} +replicas: {{ max .Values.replicas 2 }} {{- end }} {{- end }} {{- end }} \ No newline at end of file diff --git a/addons-cluster/mysql/values.schema.json b/addons-cluster/mysql/values.schema.json index e5284abf0..8604aba1a 100644 --- a/addons-cluster/mysql/values.schema.json +++ b/addons-cluster/mysql/values.schema.json @@ -18,19 +18,6 @@ "5.7.44" ] }, - "mode": { - "title": "Mode", - "description": "Cluster topology mode.", - "type": "string", - "default": "standalone", - "enum": [ - "semisync", - "semisync-proxysql", - "orc", - "orc-proxysql", - "mgr" - ] - }, "replicas": { "title": "Replicas", "description": "The number of replicas.", diff --git a/addons-cluster/mysql/values.yaml b/addons-cluster/mysql/values.yaml index 4f14f5809..17daf22ba 100644 --- a/addons-cluster/mysql/values.yaml +++ b/addons-cluster/mysql/values.yaml @@ -6,10 +6,6 @@ ## version: 8.0.39 -## @param mode MySQL cluster topology mode, standalone, replication -## -mode: standalone - ## @param replicas specify cluster replicas ## replicas: 2 diff --git a/addons/mysql/config/mysql-group-replication.tpl b/addons/mysql/config/mysql-group-replication.tpl index fd8223920..81da84c11 100644 --- a/addons/mysql/config/mysql-group-replication.tpl +++ b/addons/mysql/config/mysql-group-replication.tpl @@ -3,7 +3,6 @@ binlog_format=ROW binlog_checksum=NONE plugin_load_add='group_replication.so' plugin_load_add='mysql_clone.so' -group_replication_ip_allowlist="0.0.0.0/0" loose_group_replication_recovery_get_public_key=ON loose_group_replication_start_on_boot=off loose_group_replication_bootstrap_group=off \ No newline at end of file From 6edb072668f035980fa6601c64bfb68eeb8c855c Mon Sep 17 00:00:00 2001 From: xuriwuyun Date: Wed, 22 Jan 2025 10:37:39 +0800 Subject: [PATCH 9/9] add examples --- examples/mysql/cluster-mgr.yaml | 60 +++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 examples/mysql/cluster-mgr.yaml diff --git a/examples/mysql/cluster-mgr.yaml b/examples/mysql/cluster-mgr.yaml new file mode 100644 index 000000000..3387f5f55 --- /dev/null +++ b/examples/mysql/cluster-mgr.yaml @@ -0,0 +1,60 @@ +apiVersion: apps.kubeblocks.io/v1 +kind: Cluster +metadata: + name: mysql-mgr-cluster + namespace: default +spec: + # Specifies the behavior when a Cluster is deleted. + # Valid options are: [DoNotTerminate, Delete, WipeOut] (`Halt` is deprecated since KB 0.9) + # - `DoNotTerminate`: Prevents deletion of the Cluster. This policy ensures that all resources remain intact. + # - `Delete`: Extends the `Halt` policy by also removing PVCs, leading to a thorough cleanup while removing all persistent data. + # - `WipeOut`: An aggressive policy that deletes all Cluster resources, including volume snapshots and backups in external storage. This results in complete data removal and should be used cautiously, primarily in non-production environments to avoid irreversible data loss. + terminationPolicy: Delete + # Specifies a list of ClusterComponentSpec objects used to define the + # individual Components that make up a Cluster. + # This field allows for detailed configuration of each Component within the Cluster + componentSpecs: + - name: mysql + # Specifies the ComponentDefinition custom resource (CR) that defines the + # Component's characteristics and behavior. + # Supports three different ways to specify the ComponentDefinition: + # - the regular expression - recommended + # - the full name - recommended + # - the name prefix + componentDef: "mysql-mgr-8.0" # match all CMPD named with 'mysql-mgr-8.0-' + # ServiceVersion specifies the version of the Service expected to be + # provisioned by this Component. + # When componentDef is "mysql-8.0", + # Valid options are: [8.0.30,8.0.31,8.0.32,8.0.33,8.0.34,8.0.35,8.0.36,8.0.37,8.0.38,8.0.39] + serviceVersion: 8.0.35 + # Determines whether metrics exporter information is annotated on the + # Component's headless Service. + # Valid options are [true, false] + disableExporter: false + # Specifies the desired number of replicas in the Component + replicas: 3 + # Specifies the resources required by the Component. + resources: + limits: + cpu: '0.5' + memory: 0.5Gi + requests: + cpu: '0.5' + memory: 0.5Gi + # Specifies a list of PersistentVolumeClaim templates that define the storage + # requirements for the Component. + volumeClaimTemplates: + # Refers to the name of a volumeMount defined in + # `componentDefinition.spec.runtime.containers[*].volumeMounts + - name: data + spec: + # The name of the StorageClass required by the claim. + # If not specified, the StorageClass annotated with + # `storageclass.kubernetes.io/is-default-class=true` will be used by default + storageClassName: "" + accessModes: + - ReadWriteOnce + resources: + requests: + # Set the storage size as needed + storage: 20Gi