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 24, 2024
1 parent 68cd6cd commit e56fdb9
Show file tree
Hide file tree
Showing 9 changed files with 217 additions and 176 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
162 changes: 0 additions & 162 deletions addons/apecloud-mysql/templates/configconstraint.yaml

This file was deleted.

17 changes: 17 additions & 0 deletions addons/apecloud-mysql/templates/pcr-wescale.yaml
Original file line number Diff line number Diff line change
@@ -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
25 changes: 25 additions & 0 deletions addons/apecloud-mysql/templates/pcr-wesql.yaml
Original file line number Diff line number Diff line change
@@ -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
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}}
Loading

0 comments on commit e56fdb9

Please sign in to comment.