diff --git a/addons/mysql-cluster/8.0/chart/mysql-cluster/templates/_helpers.tpl b/addons/mysql-cluster/8.0/chart/mysql-cluster/templates/_helpers.tpl index bb2ba662..b350f2de 100644 --- a/addons/mysql-cluster/8.0/chart/mysql-cluster/templates/_helpers.tpl +++ b/addons/mysql-cluster/8.0/chart/mysql-cluster/templates/_helpers.tpl @@ -99,6 +99,17 @@ Return the configmap with the MySQL Primary configuration {{- end -}} {{- end -}} +{{/* +Return the configmap with the MySQL Router configuration +*/}} +{{- define "mysql.router.configmapName" -}} +{{- if .Values.router.existingConfigmap -}} + {{- printf "%s" (tpl .Values.router.existingConfigmap $) -}} +{{- else -}} + {{- printf "%s-router" (include "common.names.fullname" .) -}} +{{- end -}} +{{- end -}} + {{/* Return true if a configmap object should be created for MySQL Secondary */}} @@ -109,6 +120,16 @@ Return true if a configmap object should be created for MySQL Secondary {{- end -}} {{- end -}} +{{/* +Return true if a configmap object should be created for MySQL router +*/}} +{{- define "mysql.router.createConfigmap" -}} +{{- if and .Values.router.configuration (not .Values.router.existingConfigmap) }} + {{- true -}} +{{- else -}} +{{- end -}} +{{- end -}} + {{/* Return the configmap with the MySQL Primary configuration */}} diff --git a/addons/mysql-cluster/8.0/chart/mysql-cluster/templates/networkpolicy.yaml b/addons/mysql-cluster/8.0/chart/mysql-cluster/templates/networkpolicy.yaml index b792b024..7571e48b 100644 --- a/addons/mysql-cluster/8.0/chart/mysql-cluster/templates/networkpolicy.yaml +++ b/addons/mysql-cluster/8.0/chart/mysql-cluster/templates/networkpolicy.yaml @@ -20,6 +20,7 @@ spec: podSelector: matchLabels: {{- include "common.labels.matchLabels" . | nindent 6 }} + {{- if eq .Values.router.service.type "ClusterIP" }} ingress: # Allow inbound connections - ports: @@ -27,10 +28,10 @@ spec: - port: {{ .Values.router.service.portro }} - port: 24901 - port: 33061 - {{- if and .Values.metrics.enabled }} + {{- if and .Values.metrics.enabled }} - port: {{ .Values.metrics.service.port }} - {{ end }} - {{- if or .Values.networkPolicy.allowCurrentNamespace .Values.networkPolicy.allowNamespaces }} + {{- end }} + {{- if or .Values.networkPolicy.allowCurrentNamespace .Values.networkPolicy.allowNamespaces }} from: {{- if .Values.networkPolicy.allowCurrentNamespace }} - namespaceSelector: @@ -38,11 +39,16 @@ spec: kubernetes.io/metadata.name: {{ .Release.Namespace }} {{- end }} {{- range $namespace := .Values.networkPolicy.allowNamespaces }} - {{- if $namespace }} + {{- if $namespace }} - namespaceSelector: matchLabels: kubernetes.io/metadata.name: {{ $namespace }} + {{- end }} {{- end }} - {{- end }} + {{- end }} {{- end }} + {{- if eq .Values.router.service.type "LoadBalancer" }} + ingress: + - {} + {{- end}} {{- end }} diff --git a/addons/mysql-cluster/8.0/chart/mysql-cluster/templates/router/configmap.yaml b/addons/mysql-cluster/8.0/chart/mysql-cluster/templates/router/configmap.yaml new file mode 100644 index 00000000..3e5b02b5 --- /dev/null +++ b/addons/mysql-cluster/8.0/chart/mysql-cluster/templates/router/configmap.yaml @@ -0,0 +1,23 @@ +{{- /* +Copyright Drycc Community. +SPDX-License-Identifier: APACHE-2.0 +*/}} + +{{- if (include "mysql.router.createConfigmap" .) }} +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "mysql.router.fullname" . }} + namespace: {{ include "common.names.namespace" . | quote }} + labels: {{- include "common.labels.standard" . | nindent 4 }} + app.kubernetes.io/component: router + {{- if .Values.commonLabels }} + {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }} + {{- end }} + {{- if .Values.commonAnnotations }} + annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }} + {{- end }} +data: + extra-router.conf: |- + {{- include "common.tplvalues.render" ( dict "value" .Values.router.configuration "context" $ ) | nindent 4 }} +{{- end -}} diff --git a/addons/mysql-cluster/8.0/chart/mysql-cluster/templates/router/statefulset.yaml b/addons/mysql-cluster/8.0/chart/mysql-cluster/templates/router/statefulset.yaml index 9134cbfe..9ef9e93e 100644 --- a/addons/mysql-cluster/8.0/chart/mysql-cluster/templates/router/statefulset.yaml +++ b/addons/mysql-cluster/8.0/chart/mysql-cluster/templates/router/statefulset.yaml @@ -157,7 +157,7 @@ spec: - -ec - | ln -sf /dev/stdout /opt/drycc/mysql/conf/router/log/mysqlrouter.log - mysqlrouter -c /opt/drycc/mysql/conf/router/mysqlrouter.conf + mysqlrouter -c /opt/drycc/mysql/conf/router/mysqlrouter.conf -a /opt/drycc/mysql/conf/router/extra/extra-router.conf env: - name: MYSQL_HOST value: {{ include "mysql.primary.fullname" . }} @@ -174,7 +174,8 @@ spec: volumeMounts: - name: router-volume mountPath: /opt/drycc/mysql/conf - + - name: extra-config + mountPath: /opt/drycc/mysql/conf/router/extra ports: - name: routerrw containerPort: 6446 @@ -222,3 +223,6 @@ spec: volumes: - name: router-volume emptyDir: {} + - name: extra-config + configMap: + name: {{ include "mysql.router.configmapName" . }} diff --git a/addons/mysql-cluster/8.0/chart/mysql-cluster/values.yaml b/addons/mysql-cluster/8.0/chart/mysql-cluster/values.yaml index ce87fd76..79c58704 100644 --- a/addons/mysql-cluster/8.0/chart/mysql-cluster/values.yaml +++ b/addons/mysql-cluster/8.0/chart/mysql-cluster/values.yaml @@ -179,9 +179,7 @@ initdbScripts: echo loose-group_replication_local_address=$mgr_host:24901 >> $base_conf_file echo report_host=$mgr_host >> $base_conf_file echo loose-group_replication_group_seeds="$svc_mgr_host-0:24901,$svc_mgr_host-1:24901,$svc_mgr_host-2:24901" >> $base_conf_file - - echo plugin_load_add='group_replication.so' >> $base_conf_file - + echo loose-group_replication_start_on_boot='OFF' >> $base_conf_file echo max_connections=$MAX_CONNECTION_LIMIT >> $base_conf_file ## @param initdbScriptsConfigMap ConfigMap with the initdb scripts (Note: Overrides `initdbScripts`) @@ -218,7 +216,6 @@ primary: configuration: |- [mysqld] # server - max_connections=10000 default_authentication_plugin=caching_sha2_password skip-name-resolve relay-log=relay-log @@ -260,7 +257,6 @@ primary: # Multi-threaded Replication replica_preserve_commit_order=ON replica_parallel_workers=8 - replica_parallel_type=LOGICAL_CLOCK # Group Replication Settings @@ -610,6 +606,10 @@ router: ## replicaCount: 2 + configuration: |- + [routing:bootstrap_rw] + max_connections=1000 + ## @param primary.existingConfigmap Name of existing ConfigMap with MySQL Primary configuration. ## NOTE: When it's set the 'configuration' parameter is ignored ## @@ -716,13 +716,17 @@ router: ## cpu: 250m ## memory: 256Mi ## - limits: {} + limits: + cpu: 250m + memory: 256Mi ## Examples: ## requests: ## cpu: 250m ## memory: 256Mi ## - requests: {} + requests: + cpu: 250m + memory: 256Mi ## Configure extra options for liveness probe ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/#configure-probes ## @param secondary.livenessProbe.enabled Enable livenessProbe @@ -1117,12 +1121,16 @@ metrics: ## limits: ## cpu: 100m ## memory: 256Mi - limits: {} + limits: + cpu: 100m + memory: 256Mi ## Examples: ## requests: ## cpu: 100m ## memory: 256Mi - requests: {} + requests: + cpu: 100m + memory: 256Mi containerSecurityContext: enabled: true runAsUser: 1001 diff --git a/addons/mysql-cluster/8.0/meta.yaml b/addons/mysql-cluster/8.0/meta.yaml index 273e3a55..5c748c3b 100644 --- a/addons/mysql-cluster/8.0/meta.yaml +++ b/addons/mysql-cluster/8.0/meta.yaml @@ -21,4 +21,7 @@ allow_parameters: - name: "router.service.type" required: false description: "service type config for values.yaml" +- name: "router.configuration" + required: false + description: "router config for values.yaml" archive: false \ No newline at end of file