Skip to content

Commit e741dca

Browse files
K8SPXC-1781: Fix custom ProxySQL config (#2325)
* fix proxysql custom config errors Signed-off-by: Mayank Shah <mayank.shah@percona.com> * update example Signed-off-by: Mayank Shah <mayank.shah@percona.com> * add e2e test proxysql custom cfg Signed-off-by: Mayank Shah <mayank.shah@percona.com> * update e2e tests Signed-off-by: Mayank Shah <mayank.shah@percona.com> * check crVersion while setting mount path Signed-off-by: Mayank Shah <mayank.shah@percona.com> --------- Signed-off-by: Mayank Shah <mayank.shah@percona.com>
1 parent 6c52d9b commit e741dca

File tree

9 files changed

+97
-8
lines changed

9 files changed

+97
-8
lines changed

build/proxysql-entrypoint.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ function sed_in_place() {
1414
}
1515

1616
cp /opt/percona/proxysql.cnf /etc/proxysql
17+
if [[ -f /etc/proxysql/custom/proxysql.cnf ]]; then
18+
cp /etc/proxysql/custom/proxysql.cnf /etc/proxysql/proxysql.cnf
19+
fi
20+
1721
cp /opt/percona/proxysql-admin.cnf /etc
1822

1923
MYSQL_INTERFACES='0.0.0.0:3306;0.0.0.0:33062'

deploy/cr.yaml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -404,12 +404,14 @@ spec:
404404
#
405405
# admin_variables =
406406
# {
407-
# admin_credentials="proxyadmin:admin_password"
407+
# admin_credentials="admin:admin"
408408
# mysql_ifaces="0.0.0.0:6032"
409409
# refresh_interval=2000
410+
# restapi_enabled=true
411+
# restapi_port=6070
410412
#
411-
# cluster_username="proxyadmin"
412-
# cluster_password="admin_password"
413+
# cluster_username="admin"
414+
# cluster_password="admin"
413415
# checksum_admin_variables=false
414416
# checksum_ldap_variables=false
415417
# checksum_mysql_variables=false
@@ -444,11 +446,12 @@ spec:
444446
# ping_timeout_server=200
445447
# commands_stats=true
446448
# sessions_sort=true
447-
# have_ssl=true
448-
# ssl_p2s_ca="/etc/proxysql/ssl-internal/ca.crt"
449-
# ssl_p2s_cert="/etc/proxysql/ssl-internal/tls.crt"
450-
# ssl_p2s_key="/etc/proxysql/ssl-internal/tls.key"
449+
# have_ssl=false
450+
# ssl_p2s_ca=""
451+
# ssl_p2s_cert=""
452+
# ssl_p2s_key=""
451453
# ssl_p2s_cipher="ECDHE-RSA-AES128-GCM-SHA256"
454+
# default_authentication_plugin="caching_sha2_password"
452455
# }
453456
# scheduler:
454457
# enabled: false
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
4000

e2e-tests/proxysql-scheduler/compare/statefulset_some-name-proxysql.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ spec:
110110
name: ssl
111111
- mountPath: /etc/proxysql/ssl-internal
112112
name: ssl-internal
113+
- mountPath: /etc/proxysql/custom
114+
name: config
113115
- mountPath: /opt/percona
114116
name: bin
115117
- args:
@@ -221,6 +223,11 @@ spec:
221223
defaultMode: 420
222224
optional: false
223225
secretName: some-name-ssl
226+
- configMap:
227+
defaultMode: 420
228+
name: some-name-proxysql
229+
optional: true
230+
name: config
224231
- emptyDir: {}
225232
name: bin
226233
updateStrategy:

e2e-tests/proxysql-scheduler/conf/some-name.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,56 @@ spec:
4444
resources:
4545
requests:
4646
storage: 2Gi
47+
configuration: |
48+
datadir="/var/lib/proxysql"
49+
admin_variables =
50+
{
51+
admin_credentials="admin:admin"
52+
mysql_ifaces="0.0.0.0:6032"
53+
refresh_interval=2000
54+
restapi_enabled=true
55+
restapi_port=6070
56+
57+
cluster_username="admin"
58+
cluster_password="admin"
59+
checksum_admin_variables=false
60+
checksum_ldap_variables=false
61+
checksum_mysql_variables=false
62+
cluster_check_interval_ms=200
63+
cluster_check_status_frequency=100
64+
cluster_mysql_query_rules_save_to_disk=true
65+
cluster_mysql_servers_save_to_disk=true
66+
cluster_mysql_users_save_to_disk=true
67+
cluster_proxysql_servers_save_to_disk=true
68+
cluster_mysql_query_rules_diffs_before_sync=1
69+
cluster_mysql_servers_diffs_before_sync=1
70+
cluster_mysql_users_diffs_before_sync=1
71+
cluster_proxysql_servers_diffs_before_sync=1
72+
}
73+
74+
mysql_variables=
75+
{
76+
monitor_password="monitor"
77+
monitor_galera_healthcheck_interval=1000
78+
threads=2
79+
max_connections=2048
80+
default_query_delay=0
81+
default_query_timeout=10000
82+
poll_timeout=4000
83+
interfaces="0.0.0.0:3306"
84+
default_schema="information_schema"
85+
stacksize=1048576
86+
connect_timeout_server=10000
87+
monitor_history=60000
88+
monitor_connect_interval=20000
89+
monitor_ping_interval=10000
90+
ping_timeout_server=200
91+
commands_stats=true
92+
sessions_sort=true
93+
have_ssl=false
94+
ssl_p2s_ca=""
95+
ssl_p2s_cert=""
96+
ssl_p2s_key=""
97+
ssl_p2s_cipher="ECDHE-RSA-AES128-GCM-SHA256"
98+
default_authentication_plugin="caching_sha2_password"
99+
}

e2e-tests/proxysql-scheduler/run

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@ function compare_scheduler() {
1919
${pod}
2020
}
2121

22+
function compare_proxysql_cfg() {
23+
local pod=$1
24+
local compare_file=$2
25+
26+
local query='SELECT variable_value from global_variables WHERE variable_name='\'mysql-poll_timeout\'''
27+
compare_mysql_cmd_local ${compare_file} "${query}" \
28+
"-h127.0.0.1 -P6032 -uproxyadmin -padmin_password" ${pod}
29+
}
30+
2231
function compare_mysql_servers() {
2332
local pod=$1
2433
local compare_file=$2
@@ -59,6 +68,9 @@ desc "create PXC cluster: ${cluster}"
5968
spinup_pxc "${cluster}" "${test_dir}/conf/${cluster}.yml"
6069
wait_cluster_consistency "${cluster}" 3 2
6170

71+
desc 'check proxysql custom config'
72+
compare_proxysql_cfg "${cluster}-proxysql-0" "proxysql-cfg"
73+
6274
desc 'check if service and statefulset created with expected config'
6375
compare_kubectl statefulset/${cluster}-pxc
6476
compare_kubectl statefulset/${cluster}-proxysql
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
test-password

e2e-tests/users-scheduler/run

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ sleep 15
6868
compare_mysql_cmd_local "$tables_cmp_file" "SHOW TABLES;" "-h127.0.0.1 -P6032 -uproxyadmin -p'$newpass'" "$cluster-proxysql-0" "" 'proxysql'
6969
compare_mysql_cmd_local "$tables_cmp_file" "SHOW TABLES;" "-h127.0.0.1 -P6032 -uproxyadmin -p'$newpass'" "$cluster-proxysql-1" "" 'proxysql'
7070
compare_mysql_cmd_local "$tables_cmp_file" "SHOW TABLES;" "-h127.0.0.1 -P6032 -uproxyadmin -p'$newpass'" "$cluster-proxysql-2" "" 'proxysql'
71+
compare_mysql_cmd_local "proxysql-cfg" "SELECT variable_value from global_variables WHERE variable_name='admin-cluster_password';" \
72+
"-h127.0.0.1 -P6032 -uproxyadmin -p'$newpass'" "$cluster-proxysql-2" "" 'proxysql'
7173

7274
desc 'test xtrabackup'
7375
kubectl_bin patch pxc some-name --type=merge -p="{\"spec\":{\"proxysql\":{\"size\":2}}}"
@@ -83,6 +85,8 @@ wait_for_password_propagation "my-cluster-secrets" "monitor" "$cluster"
8385
wait_cluster_consistency "$cluster" 3 2
8486
sleep 15 # give some time for proxy-admin --syncusers
8587
compare_mysql_cmd "select-4" "SHOW TABLES;" "-h $cluster-proxysql -umonitor -p'$newpass'"
88+
compare_mysql_cmd_local "proxysql-cfg" "SELECT variable_value from global_variables WHERE variable_name='mysql-monitor_password';" \
89+
"-h127.0.0.1 -P6032 -uproxyadmin -p'$newpass'" "$cluster-proxysql-1" "" 'proxysql'
8690

8791
desc 'test operator'
8892
patch_secret "my-cluster-secrets" "operator" "$newpassencrypted"

pkg/pxc/app/statefulset/proxysql.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,14 @@ func (c *Proxy) AppContainer(ctx context.Context, _ client.Client, spec *api.Pod
143143
},
144144
}
145145

146+
proxyConfigMountPath := "/etc/proxysql"
147+
if cr.CompareVersionWith("1.19.0") >= 0 {
148+
proxyConfigMountPath = "/etc/proxysql/custom"
149+
}
146150
if api.ContainsVolume(availableVolumes, proxyConfigVolumeName) {
147151
appc.VolumeMounts = append(appc.VolumeMounts, corev1.VolumeMount{
148152
Name: proxyConfigVolumeName,
149-
MountPath: "/etc/proxysql/",
153+
MountPath: proxyConfigMountPath,
150154
})
151155
}
152156

0 commit comments

Comments
 (0)