Skip to content

Commit 0d90c1f

Browse files
committed
chore(mysql-cluster): add router configmap , add resources limits to router and metrics
1 parent a7a2a9f commit 0d90c1f

5 files changed

Lines changed: 70 additions & 11 deletions

File tree

addons/mysql-cluster/8.0/chart/mysql-cluster/templates/_helpers.tpl

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,17 @@ Return the configmap with the MySQL Primary configuration
9999
{{- end -}}
100100
{{- end -}}
101101

102+
{{/*
103+
Return the configmap with the MySQL Router configuration
104+
*/}}
105+
{{- define "mysql.router.configmapName" -}}
106+
{{- if .Values.router.existingConfigmap -}}
107+
{{- printf "%s" (tpl .Values.router.existingConfigmap $) -}}
108+
{{- else -}}
109+
{{- printf "%s-router" (include "common.names.fullname" .) -}}
110+
{{- end -}}
111+
{{- end -}}
112+
102113
{{/*
103114
Return true if a configmap object should be created for MySQL Secondary
104115
*/}}
@@ -109,6 +120,16 @@ Return true if a configmap object should be created for MySQL Secondary
109120
{{- end -}}
110121
{{- end -}}
111122

123+
{{/*
124+
Return true if a configmap object should be created for MySQL router
125+
*/}}
126+
{{- define "mysql.router.createConfigmap" -}}
127+
{{- if and .Values.router.configuration (not .Values.router.existingConfigmap) }}
128+
{{- true -}}
129+
{{- else -}}
130+
{{- end -}}
131+
{{- end -}}
132+
112133
{{/*
113134
Return the configmap with the MySQL Primary configuration
114135
*/}}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{{- /*
2+
Copyright Drycc Community.
3+
SPDX-License-Identifier: APACHE-2.0
4+
*/}}
5+
6+
{{- if (include "mysql.router.createConfigmap" .) }}
7+
apiVersion: v1
8+
kind: ConfigMap
9+
metadata:
10+
name: {{ include "mysql.router.fullname" . }}
11+
namespace: {{ include "common.names.namespace" . | quote }}
12+
labels: {{- include "common.labels.standard" . | nindent 4 }}
13+
app.kubernetes.io/component: router
14+
{{- if .Values.commonLabels }}
15+
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
16+
{{- end }}
17+
{{- if .Values.commonAnnotations }}
18+
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
19+
{{- end }}
20+
data:
21+
extra-router.conf: |-
22+
{{- include "common.tplvalues.render" ( dict "value" .Values.router.configuration "context" $ ) | nindent 4 }}
23+
{{- end -}}

addons/mysql-cluster/8.0/chart/mysql-cluster/templates/router/statefulset.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ spec:
157157
- -ec
158158
- |
159159
ln -sf /dev/stdout /opt/drycc/mysql/conf/router/log/mysqlrouter.log
160-
mysqlrouter -c /opt/drycc/mysql/conf/router/mysqlrouter.conf
160+
mysqlrouter -c /opt/drycc/mysql/conf/router/mysqlrouter.conf -a /opt/drycc/mysql/conf/router/extra/extra-router.conf
161161
env:
162162
- name: MYSQL_HOST
163163
value: {{ include "mysql.primary.fullname" . }}
@@ -174,7 +174,8 @@ spec:
174174
volumeMounts:
175175
- name: router-volume
176176
mountPath: /opt/drycc/mysql/conf
177-
177+
- name: extra-config
178+
mountPath: /opt/drycc/mysql/conf/router/extra
178179
ports:
179180
- name: routerrw
180181
containerPort: 6446
@@ -222,3 +223,6 @@ spec:
222223
volumes:
223224
- name: router-volume
224225
emptyDir: {}
226+
- name: extra-config
227+
configMap:
228+
name: {{ include "mysql.router.configmapName" . }}

addons/mysql-cluster/8.0/chart/mysql-cluster/values.yaml

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,7 @@ initdbScripts:
179179
echo loose-group_replication_local_address=$mgr_host:24901 >> $base_conf_file
180180
echo report_host=$mgr_host >> $base_conf_file
181181
echo loose-group_replication_group_seeds="$svc_mgr_host-0:24901,$svc_mgr_host-1:24901,$svc_mgr_host-2:24901" >> $base_conf_file
182-
183-
echo plugin_load_add='group_replication.so' >> $base_conf_file
184-
182+
echo loose-group_replication_start_on_boot='OFF' >> $base_conf_file
185183
echo max_connections=$MAX_CONNECTION_LIMIT >> $base_conf_file
186184
187185
## @param initdbScriptsConfigMap ConfigMap with the initdb scripts (Note: Overrides `initdbScripts`)
@@ -218,7 +216,6 @@ primary:
218216
configuration: |-
219217
[mysqld]
220218
# server
221-
max_connections=10000
222219
default_authentication_plugin=caching_sha2_password
223220
skip-name-resolve
224221
relay-log=relay-log
@@ -260,7 +257,6 @@ primary:
260257
# Multi-threaded Replication
261258
replica_preserve_commit_order=ON
262259
replica_parallel_workers=8
263-
replica_parallel_type=LOGICAL_CLOCK
264260
265261
# Group Replication Settings
266262
@@ -610,6 +606,10 @@ router:
610606
##
611607
replicaCount: 2
612608

609+
configuration: |-
610+
[routing:bootstrap_rw]
611+
max_connections=1000
612+
613613
## @param primary.existingConfigmap Name of existing ConfigMap with MySQL Primary configuration.
614614
## NOTE: When it's set the 'configuration' parameter is ignored
615615
##
@@ -716,13 +716,17 @@ router:
716716
## cpu: 250m
717717
## memory: 256Mi
718718
##
719-
limits: {}
719+
limits:
720+
cpu: 250m
721+
memory: 256Mi
720722
## Examples:
721723
## requests:
722724
## cpu: 250m
723725
## memory: 256Mi
724726
##
725-
requests: {}
727+
requests:
728+
cpu: 250m
729+
memory: 256Mi
726730
## Configure extra options for liveness probe
727731
## ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/#configure-probes
728732
## @param secondary.livenessProbe.enabled Enable livenessProbe
@@ -1117,12 +1121,16 @@ metrics:
11171121
## limits:
11181122
## cpu: 100m
11191123
## memory: 256Mi
1120-
limits: {}
1124+
limits:
1125+
cpu: 100m
1126+
memory: 256Mi
11211127
## Examples:
11221128
## requests:
11231129
## cpu: 100m
11241130
## memory: 256Mi
1125-
requests: {}
1131+
requests:
1132+
cpu: 100m
1133+
memory: 256Mi
11261134
containerSecurityContext:
11271135
enabled: true
11281136
runAsUser: 1001

addons/mysql-cluster/8.0/meta.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,7 @@ allow_parameters:
2121
- name: "router.service.type"
2222
required: false
2323
description: "service type config for values.yaml"
24+
- name: "router.configuration"
25+
required: false
26+
description: "router config for values.yaml"
2427
archive: false

0 commit comments

Comments
 (0)