@@ -10,4 +10,55 @@ metadata:
1010 {{ $key }}: {{ $value }}
1111 {{- end }}
1212data :
13- {{ tpl (.Files.Glob "config/proxysql.cnf").AsConfig . | indent 2 }}
13+ proxysql.tmpl : |-
14+ {{- $proxysql := .Values.configmap }}
15+ datadir = "{{ $proxysql.datadir }}"
16+ errorlog = "{{ $proxysql.errorlog }}"
17+
18+ admin_variables = { {{- range $key, $value := $proxysql.admin_variables }}
19+ {{- if eq $key "admin_credentials" }}
20+ {{ $key }} = "{{ $value.username }}:{{ (lookup "v1" "Secret" $.Release.Namespace $value.password).data.value }}" {{- else }}
21+ {{ $key }} = "{{ $value }}" {{- end }}{{- end }}
22+ }
23+
24+ mysql_variables = { {{- range $key, $value := $proxysql.mysql_variables }}
25+ {{- if eq $key "monitor_password" }}
26+ {{ $key }} = "{{ (lookup "v1" "Secret" $.Release.Namespace $value).data.value }}" {{- else }}
27+ {{ $key }} = "{{ $value }}" {{- end }}{{- end }}
28+ }
29+
30+ mysql_users = ( {{- range $key, $mysql_user := $proxysql.mysql_users }}
31+ {
32+ username = "{{ default $key $mysql_user.username }}"
33+ default_hostgroup = "{{ default 0 $mysql_user.default_hostgroup }}"
34+ active = "{{ default 1 $mysql_user.active }}"
35+ password = "{{ (lookup "v1" "Secret" $.Release.Namespace $mysql_user.password).data.value }}"
36+ }, {{- end }}
37+ )
38+
39+ mysql_servers = ( {{- range $key, $mysql_server := $proxysql.mysql_servers }}
40+ {
41+ hostgroup_id = "{{ default 0 $mysql_server.hostgroup_id }}"
42+ hostname = "{{ default $key $mysql_server.hostname}}"
43+ port = "{{ default 3306 $mysql_server.port }}"
44+ use_ssl = "{{ default 1 $mysql_server.use_ssl }}"
45+ weight = "{{ default 1 $mysql_server.weight }}"
46+ comment = "{{ $mysql_server.comment }}"
47+ }, {{- end }}
48+ )
49+
50+ mysql_query_rules = ( {{- range $key, $value := $proxysql.mysql_query_rules }}
51+ {{ $key }} = "{{ $value }}" {{- end }}
52+ )
53+
54+ scheduler = ( {{- range $key, $value := $proxysql.scheduler }}
55+ {{ $key }} = "{{ $value }}" {{- end }}
56+ )
57+
58+ mysql_replication_hostgroups = ( {{- range $mysql_replication_hostgroup := $proxysql.mysql_replication_hostgroups }}
59+ {
60+ writer_hostgroup = "{{ default 0 $mysql_replication_hostgroup.writer_hostgroup }}"
61+ reader_hostgroup = "{{ default 1 $mysql_replication_hostgroup.reader_hostgroup }}"
62+ comment = "{{ $mysql_replication_hostgroup.comment }}"
63+ }, {{- end }}
64+ )
0 commit comments