From e56fdb9305b9e4884d1a75e96f17a8a40b276566 Mon Sep 17 00:00:00 2001 From: sophon Date: Thu, 12 Dec 2024 18:26:36 +0800 Subject: [PATCH] chore: support parameters api for wesql --- addons/apecloud-mysql/templates/_names.tpl | 40 ++++- .../templates/cmpd-apecloudmysql.yaml | 4 - .../templates/cmpd-wescale.yaml | 1 - .../templates/configconstraint.yaml | 162 ------------------ .../apecloud-mysql/templates/pcr-wescale.yaml | 17 ++ .../apecloud-mysql/templates/pcr-wesql.yaml | 25 +++ .../apecloud-mysql/templates/pd-wescale.yaml | 45 +++++ .../templates/pd-wesql-vttablet.yaml | 45 +++++ addons/apecloud-mysql/templates/pd-wesql.yaml | 54 ++++++ 9 files changed, 217 insertions(+), 176 deletions(-) delete mode 100644 addons/apecloud-mysql/templates/configconstraint.yaml create mode 100644 addons/apecloud-mysql/templates/pcr-wescale.yaml create mode 100644 addons/apecloud-mysql/templates/pcr-wesql.yaml create mode 100644 addons/apecloud-mysql/templates/pd-wescale.yaml create mode 100644 addons/apecloud-mysql/templates/pd-wesql-vttablet.yaml create mode 100644 addons/apecloud-mysql/templates/pd-wesql.yaml diff --git a/addons/apecloud-mysql/templates/_names.tpl b/addons/apecloud-mysql/templates/_names.tpl index 2a6951d57..90adcbe27 100644 --- a/addons/apecloud-mysql/templates/_names.tpl +++ b/addons/apecloud-mysql/templates/_names.tpl @@ -102,27 +102,27 @@ Define wescale-controller component definition name {{/* Define config constriant name */}} -{{- define "apecloud-mysql.configConstraintName" -}} +{{- define "apecloud-mysql.wesqlParamsDefName" -}} {{- if eq (len .Values.resourceNamePrefix) 0 -}} -apecloud-mysql8.0-config-constraints +apecloud-mysql8.0-pd {{- else -}} -{{- .Values.resourceNamePrefix -}}-config-constraints +{{- .Values.resourceNamePrefix -}}-pd {{- end -}} {{- end -}} -{{- define "apecloud-mysql.configConstraintVttabletName" }} +{{- define "apecloud-mysql.wesqlVttabletParamsDefName" }} {{- if eq (len .Values.resourceNamePrefix) 0 -}} -apecloud-mysql-scale-vttablet-config-constraints +apecloud-mysql-scale-vttablet-pd {{- else -}} -{{- .Values.resourceNamePrefix -}}-vttablet-config-constraints +{{- .Values.resourceNamePrefix -}}-vttablet-pd {{- end -}} {{- end -}} -{{- define "apecloud-mysql.configConstraintVtgateName" }} +{{- define "apecloud-mysql.wescaleParamsDefName" }} {{- if eq (len .Values.resourceNamePrefix) 0 -}} -apecloud-mysql-scale-vtgate-config-constraints +apecloud-mysql-scale-vtgate-pd {{- else -}} -{{- .Values.resourceNamePrefix -}}-vtgate-config-constraints +{{- .Values.resourceNamePrefix -}}-vtgate-pd {{- end -}} {{- end -}} @@ -165,3 +165,25 @@ apecloud-mysql-scripts {{- .Values.resourceNamePrefix -}}-scripts {{- end -}} {{- end -}} + +{{/* +Define config constriant name +*/}} +{{- define "apecloud-mysql.wesqlPCRName" -}} +{{- if eq (len .Values.resourceNamePrefix) 0 -}} +apecloud-mysql8.0-wesql-pcr +{{- else -}} +{{- .Values.resourceNamePrefix -}}-wesql-pcr +{{- end -}} +{{- end -}} + +{{/* +Define config constriant name +*/}} +{{- define "apecloud-mysql.wescalePCRName" -}} +{{- if eq (len .Values.resourceNamePrefix) 0 -}} +apecloud-mysql8.0-wescale-pcr +{{- else -}} +{{- .Values.resourceNamePrefix -}}-wescale-pcr +{{- end -}} +{{- end -}} \ No newline at end of file diff --git a/addons/apecloud-mysql/templates/cmpd-apecloudmysql.yaml b/addons/apecloud-mysql/templates/cmpd-apecloudmysql.yaml index ed4ba6b6a..0644f0c0f 100644 --- a/addons/apecloud-mysql/templates/cmpd-apecloudmysql.yaml +++ b/addons/apecloud-mysql/templates/cmpd-apecloudmysql.yaml @@ -11,14 +11,10 @@ spec: configs: - name: mysql-consensusset-config templateRef: {{ include "apecloud-mysql.configTplName" . }} - constraintRef: {{ include "apecloud-mysql.configConstraintName" . }} volumeName: mysql-config namespace: {{ .Release.Namespace }} - reRenderResourceTypes: - - vscale - name: vttablet-config templateRef: {{ include "apecloud-mysql.configTplVttabletName" . }} - constraintRef: {{ include "apecloud-mysql.configConstraintVttabletName" . }} volumeName: mysql-scale-config namespace: {{ .Release.Namespace }} runtime: diff --git a/addons/apecloud-mysql/templates/cmpd-wescale.yaml b/addons/apecloud-mysql/templates/cmpd-wescale.yaml index 7570d2f8e..28c14dd0d 100644 --- a/addons/apecloud-mysql/templates/cmpd-wescale.yaml +++ b/addons/apecloud-mysql/templates/cmpd-wescale.yaml @@ -31,7 +31,6 @@ spec: configs: - name: vtgate-config templateRef: {{ include "apecloud-mysql.configTplVtgateName" . }} - constraintRef: {{ include "apecloud-mysql.configConstraintVtgateName" . }} volumeName: vtgate-config namespace: {{ .Release.Namespace }} services: diff --git a/addons/apecloud-mysql/templates/configconstraint.yaml b/addons/apecloud-mysql/templates/configconstraint.yaml deleted file mode 100644 index e43366150..000000000 --- a/addons/apecloud-mysql/templates/configconstraint.yaml +++ /dev/null @@ -1,162 +0,0 @@ -{{- $cc := .Files.Get "config/mysql8-config-effect-scope.yaml" | fromYaml }} -apiVersion: apps.kubeblocks.io/v1beta1 -kind: ConfigConstraint -metadata: - name: {{ include "apecloud-mysql.configConstraintName" . }} - labels: - {{- include "apecloud-mysql.labels" . | nindent 4 }} -spec: - # configmap reference - # tplRef: mysql-3node-tpl-8.0 - reloadAction: - tplScriptTrigger: - sync: true - scriptConfigMapRef: {{ include "apecloud-mysql.cmReloadScriptName" .}} - namespace: {{ .Release.Namespace }} - - - # ConfigurationSchema that impose restrictions on engine parameter's rule - parametersSchema: - # top level mysql configuration type - topLevelKey: MysqlParameter - - # schemaInJSON: auto generate from cue scripts - # example: ../../pkg/configuration/testdata/mysql_openapi.json - cue: |- - {{- .Files.Get "config/mysql8-config-constraint.cue" | nindent 6 }} - - ## define static parameter list - {{- if hasKey $cc "staticParameters" }} - staticParameters: - {{- $params := get $cc "staticParameters" }} - {{- range $params }} - - {{ . }} - {{- end }} - {{- end}} - - ## define dynamic parameter list - {{- if hasKey $cc "dynamicParameters" }} - dynamicParameters: - {{- $params := get $cc "dynamicParameters" }} - {{- range $params }} - - {{ . }} - {{- end }} - {{- end}} - - ## define immutable parameter list, this feature is not currently supported. - {{- if hasKey $cc "immutableParameters" }} - immutableParameters: - {{- $params := get $cc "immutableParameters" }} - {{- range $params }} - - {{ . }} - {{- end }} - {{- end}} - - - # mysql configuration file format - fileFormatConfig: - format: ini - iniConfig: - sectionName: mysqld ---- -{{- $vttabletcc := .Files.Get "config/mysql-scale-vttablet-config-effect-scope.yaml" | fromYaml }} -apiVersion: apps.kubeblocks.io/v1beta1 -kind: ConfigConstraint -metadata: - name: {{ include "apecloud-mysql.configConstraintVttabletName" . }} - - labels: - {{- include "apecloud-mysql.labels" . | nindent 4 }} -spec: - reloadAction: - autoTrigger: - processName: vttablet - - parametersSchema: - topLevelKey: VtTabletParameter - cue: |- - {{- .Files.Get "config/mysql-scale-vttablet-config-constraint.cue" | nindent 6 }} - - ## define static parameter list - {{- if hasKey $vttabletcc "staticParameters" }} - staticParameters: - {{- $params := get $vttabletcc "staticParameters" }} - {{- range $params }} - - {{ . }} - {{- end }} - {{- end}} - - ## define dynamic parameter list - {{- if hasKey $vttabletcc "dynamicParameters" }} - dynamicParameters: - {{- $params := get $vttabletcc "dynamicParameters" }} - {{- range $params }} - - {{ . }} - {{- end }} - {{- end}} - - ## define immutable parameter list, this feature is not currently supported. - {{- if hasKey $vttabletcc "immutableParameters" }} - immutableParameters: - {{- $params := get $vttabletcc "immutableParameters" }} - {{- range $params }} - - {{ . }} - {{- end }} - {{- end}} - - # mysql-scale configuration file format - fileFormatConfig: - format: ini - iniConfig: - sectionName: vttablet ---- -{{- $vtgatecc := .Files.Get "config/mysql-scale-vtgate-config-effect-scope.yaml" | fromYaml }} -apiVersion: apps.kubeblocks.io/v1beta1 -kind: ConfigConstraint -metadata: - name: {{ include "apecloud-mysql.configConstraintVtgateName" . }} - labels: - {{- include "apecloud-mysql.labels" . | nindent 4 }} -spec: - reloadAction: - autoTrigger: - processName: vtgate - - parametersSchema: - topLevelKey: VtGateParameter - - cue: |- - {{- .Files.Get "config/mysql-scale-vtgate-config-constraint.cue" | nindent 6 }} - - ## define static parameter list - {{- if hasKey $vtgatecc "staticParameters" }} - staticParameters: - {{- $params := get $vtgatecc "staticParameters" }} - {{- range $params }} - - {{ . }} - {{- end }} - {{- end}} - - ## define dynamic parameter list - {{- if hasKey $vtgatecc "dynamicParameters" }} - dynamicParameters: - {{- $params := get $vtgatecc "dynamicParameters" }} - {{- range $params }} - - {{ . }} - {{- end }} - {{- end}} - - ## define immutable parameter list, this feature is not currently supported. - {{- if hasKey $vtgatecc "immutableParameters" }} - immutableParameters: - {{- $params := get $vtgatecc "immutableParameters" }} - {{- range $params }} - - {{ . }} - {{- end }} - {{- end}} - - # mysql-scale configuration file format - fileFormatConfig: - format: ini - iniConfig: - sectionName: vtgate \ No newline at end of file diff --git a/addons/apecloud-mysql/templates/pcr-wescale.yaml b/addons/apecloud-mysql/templates/pcr-wescale.yaml new file mode 100644 index 000000000..600a0bf36 --- /dev/null +++ b/addons/apecloud-mysql/templates/pcr-wescale.yaml @@ -0,0 +1,17 @@ +apiVersion: parameters.kubeblocks.io/v1alpha1 +kind: ParameterDrivenConfigRender +metadata: + name: {{ include "apecloud-mysql.wescalePCRName" . }} + labels: + {{- include "apecloud-mysql.labels" . | nindent 4 }} +spec: + componentDef: {{ include "apecloud-mysql.cmpdNameWescale" . }} + parametersDefs: + - {{ include "apecloud-mysql.wescaleParamsDefName" . }} + + configs: + - name: vtgate.cnf + fileFormatConfig: + format: ini + iniConfig: + sectionName: vtgate \ No newline at end of file diff --git a/addons/apecloud-mysql/templates/pcr-wesql.yaml b/addons/apecloud-mysql/templates/pcr-wesql.yaml new file mode 100644 index 000000000..0f96aeba0 --- /dev/null +++ b/addons/apecloud-mysql/templates/pcr-wesql.yaml @@ -0,0 +1,25 @@ +apiVersion: parameters.kubeblocks.io/v1alpha1 +kind: ParameterDrivenConfigRender +metadata: + name: {{ include "apecloud-mysql.wesqlPCRName" . }} + labels: + {{- include "apecloud-mysql.labels" . | nindent 4 }} +spec: + componentDef: {{ include "apecloud-mysql.cmpdNameApecloudMySQL" . }} + parametersDefs: + - {{ include "apecloud-mysql.wesqlParamsDefName" . }} + - {{ include "apecloud-mysql.wesqlVttabletParamsDefName" . }} + + configs: + - name: my.cnf + fileFormatConfig: + format: ini + iniConfig: + sectionName: mysqld + reRenderResourceTypes: + - vscale + - name: vttablet.cnf + fileFormatConfig: + format: ini + iniConfig: + sectionName: vttablet diff --git a/addons/apecloud-mysql/templates/pd-wescale.yaml b/addons/apecloud-mysql/templates/pd-wescale.yaml new file mode 100644 index 000000000..1453e6ea2 --- /dev/null +++ b/addons/apecloud-mysql/templates/pd-wescale.yaml @@ -0,0 +1,45 @@ +{{- $vtgatecc := .Files.Get "config/mysql-scale-vtgate-config-effect-scope.yaml" | fromYaml }} +apiVersion: parameters.kubeblocks.io/v1alpha1 +kind: ParametersDefinition +metadata: + name: {{ include "apecloud-mysql.wescaleParamsDefName" . }} + labels: + {{- include "apecloud-mysql.labels" . | nindent 4 }} +spec: + reloadAction: + autoTrigger: + processName: vtgate + + fileName: vtgate.cnf + parametersSchema: + topLevelKey: VtGateParameter + + cue: |- + {{- .Files.Get "config/mysql-scale-vtgate-config-constraint.cue" | nindent 6 }} + + ## define static parameter list + {{- if hasKey $vtgatecc "staticParameters" }} + staticParameters: + {{- $params := get $vtgatecc "staticParameters" }} + {{- range $params }} + - {{ . }} + {{- end }} + {{- end}} + + ## define dynamic parameter list + {{- if hasKey $vtgatecc "dynamicParameters" }} + dynamicParameters: + {{- $params := get $vtgatecc "dynamicParameters" }} + {{- range $params }} + - {{ . }} + {{- end }} + {{- end}} + + ## define immutable parameter list, this feature is not currently supported. + {{- if hasKey $vtgatecc "immutableParameters" }} + immutableParameters: + {{- $params := get $vtgatecc "immutableParameters" }} + {{- range $params }} + - {{ . }} + {{- end }} + {{- end}} \ No newline at end of file diff --git a/addons/apecloud-mysql/templates/pd-wesql-vttablet.yaml b/addons/apecloud-mysql/templates/pd-wesql-vttablet.yaml new file mode 100644 index 000000000..9dc9959fd --- /dev/null +++ b/addons/apecloud-mysql/templates/pd-wesql-vttablet.yaml @@ -0,0 +1,45 @@ +{{- $vttabletcc := .Files.Get "config/mysql-scale-vttablet-config-effect-scope.yaml" | fromYaml }} +apiVersion: parameters.kubeblocks.io/v1alpha1 +kind: ParametersDefinition +metadata: + name: {{ include "apecloud-mysql.wesqlVttabletParamsDefName" . }} + + labels: + {{- include "apecloud-mysql.labels" . | nindent 4 }} +spec: + reloadAction: + autoTrigger: + processName: vttablet + + fileName: vttablet.cnf + parametersSchema: + topLevelKey: VtTabletParameter + cue: |- + {{- .Files.Get "config/mysql-scale-vttablet-config-constraint.cue" | nindent 6 }} + + ## define static parameter list + {{- if hasKey $vttabletcc "staticParameters" }} + staticParameters: + {{- $params := get $vttabletcc "staticParameters" }} + {{- range $params }} + - {{ . }} + {{- end }} + {{- end}} + + ## define dynamic parameter list + {{- if hasKey $vttabletcc "dynamicParameters" }} + dynamicParameters: + {{- $params := get $vttabletcc "dynamicParameters" }} + {{- range $params }} + - {{ . }} + {{- end }} + {{- end}} + + ## define immutable parameter list, this feature is not currently supported. + {{- if hasKey $vttabletcc "immutableParameters" }} + immutableParameters: + {{- $params := get $vttabletcc "immutableParameters" }} + {{- range $params }} + - {{ . }} + {{- end }} + {{- end}} \ No newline at end of file diff --git a/addons/apecloud-mysql/templates/pd-wesql.yaml b/addons/apecloud-mysql/templates/pd-wesql.yaml new file mode 100644 index 000000000..8cfc3cc4b --- /dev/null +++ b/addons/apecloud-mysql/templates/pd-wesql.yaml @@ -0,0 +1,54 @@ +{{- $cc := .Files.Get "config/mysql8-config-effect-scope.yaml" | fromYaml }} +apiVersion: parameters.kubeblocks.io/v1alpha1 +kind: ParametersDefinition +metadata: + name: {{ include "apecloud-mysql.wesqlParamsDefName" . }} + labels: + {{- include "apecloud-mysql.labels" . | nindent 4 }} +spec: + # configmap reference + # tplRef: mysql-3node-tpl-8.0 + reloadAction: + tplScriptTrigger: + sync: true + scriptConfigMapRef: {{ include "apecloud-mysql.cmReloadScriptName" .}} + namespace: {{ .Release.Namespace }} + + + fileName: my.cnf + # ConfigurationSchema that impose restrictions on engine parameter's rule + parametersSchema: + # top level mysql configuration type + topLevelKey: MysqlParameter + + # schemaInJSON: auto generate from cue scripts + # example: ../../pkg/configuration/testdata/mysql_openapi.json + cue: |- + {{- .Files.Get "config/mysql8-config-constraint.cue" | nindent 6 }} + + ## define static parameter list + {{- if hasKey $cc "staticParameters" }} + staticParameters: + {{- $params := get $cc "staticParameters" }} + {{- range $params }} + - {{ . }} + {{- end }} + {{- end}} + + ## define dynamic parameter list + {{- if hasKey $cc "dynamicParameters" }} + dynamicParameters: + {{- $params := get $cc "dynamicParameters" }} + {{- range $params }} + - {{ . }} + {{- end }} + {{- end}} + + ## define immutable parameter list, this feature is not currently supported. + {{- if hasKey $cc "immutableParameters" }} + immutableParameters: + {{- $params := get $cc "immutableParameters" }} + {{- range $params }} + - {{ . }} + {{- end }} + {{- end}} \ No newline at end of file