Skip to content

Commit

Permalink
chore: support parameters api for wesql
Browse files Browse the repository at this point in the history
  • Loading branch information
sophon-zt committed Dec 12, 2024
1 parent 68cd6cd commit 197c320
Show file tree
Hide file tree
Showing 9 changed files with 223 additions and 17 deletions.
40 changes: 31 additions & 9 deletions addons/apecloud-mysql/templates/_names.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 -}}

Expand Down Expand Up @@ -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 -}}
4 changes: 0 additions & 4 deletions addons/apecloud-mysql/templates/cmpd-apecloudmysql.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 0 additions & 1 deletion addons/apecloud-mysql/templates/cmpd-wescale.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions addons/apecloud-mysql/templates/configconstraint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
apiVersion: apps.kubeblocks.io/v1beta1
kind: ConfigConstraint
metadata:
name: {{ include "apecloud-mysql.configConstraintName" . }}
name: {{ include "apecloud-mysql.wesqlParamsDefName" . }}
labels:
{{- include "apecloud-mysql.labels" . | nindent 4 }}
spec:
Expand Down Expand Up @@ -63,7 +63,7 @@ spec:
apiVersion: apps.kubeblocks.io/v1beta1
kind: ConfigConstraint
metadata:
name: {{ include "apecloud-mysql.configConstraintVttabletName" . }}
name: {{ include "apecloud-mysql.wesqlVttabletParamsDefName" . }}

labels:
{{- include "apecloud-mysql.labels" . | nindent 4 }}
Expand Down Expand Up @@ -114,7 +114,7 @@ spec:
apiVersion: apps.kubeblocks.io/v1beta1
kind: ConfigConstraint
metadata:
name: {{ include "apecloud-mysql.configConstraintVtgateName" . }}
name: {{ include "apecloud-mysql.wescaleParamsDefName" . }}
labels:
{{- include "apecloud-mysql.labels" . | nindent 4 }}
spec:
Expand Down
18 changes: 18 additions & 0 deletions addons/apecloud-mysql/templates/pcr-wescale.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
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
templateName: vtgate-config
fileFormatConfig:
format: ini
iniConfig:
sectionName: vtgate
27 changes: 27 additions & 0 deletions addons/apecloud-mysql/templates/pcr-wesql.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
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
templateName: mysql-consensusset-config
fileFormatConfig:
format: ini
iniConfig:
sectionName: mysqld
reRenderResourceTypes:
- vscale
- name: vttablet.cnf
templateName: vttablet-config
fileFormatConfig:
format: ini
iniConfig:
sectionName: vttablet
45 changes: 45 additions & 0 deletions addons/apecloud-mysql/templates/pd-wescale.yaml
Original file line number Diff line number Diff line change
@@ -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}}
45 changes: 45 additions & 0 deletions addons/apecloud-mysql/templates/pd-wesql-vttablet.yaml
Original file line number Diff line number Diff line change
@@ -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}}
54 changes: 54 additions & 0 deletions addons/apecloud-mysql/templates/pd-wesql.yaml
Original file line number Diff line number Diff line change
@@ -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}}

0 comments on commit 197c320

Please sign in to comment.