Skip to content

Commit 95bf3cc

Browse files
authored
K8SPXC-1473 (#213)
Documented new exposed ports for HAProxy and ProxySQL Added a section with all available ports and services Updated config file samples new file: docs/assets/fragments/haproxy-config.txt new file: docs/assets/fragments/proxysql-config.txt modified: docs/haproxy-conf.md modified: docs/proxysql-conf.md
1 parent 1a5a818 commit 95bf3cc

File tree

4 files changed

+167
-176
lines changed

4 files changed

+167
-176
lines changed

Diff for: docs/assets/fragments/haproxy-config.txt

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
```default
2+
global
3+
maxconn 2048
4+
external-check
5+
stats socket /var/run/haproxy.sock mode 600 expose-fd listeners level user
6+
defaults
7+
log global
8+
mode tcp
9+
retries 10
10+
timeout client 10000
11+
timeout connect 100500
12+
timeout server 10000
13+
frontend galera-in
14+
bind *:3309 accept-proxy
15+
bind *:3306
16+
mode tcp
17+
option clitcpka
18+
default_backend galera-nodes
19+
frontend galera-admin-in
20+
bind *:33062
21+
mode tcp
22+
option clitcpka
23+
default_backend galera-admin-nodes
24+
frontend galera-replica-in
25+
bind *:3307
26+
mode tcp
27+
option clitcpka
28+
default_backend galera-replica-nodes
29+
frontend galera-mysqlx-in
30+
bind *:33060
31+
mode tcp
32+
option clitcpka
33+
default_backend galera-mysqlx-nodes
34+
frontend stats
35+
bind *:8404
36+
mode http
37+
http-request use-service prometheus-exporter if { path /metrics }
38+
```

Diff for: docs/assets/fragments/proxysql-config.txt

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
```default
2+
datadir="/var/lib/proxysql"
3+
4+
admin_variables =
5+
{
6+
admin_credentials="proxyadmin:admin_password"
7+
mysql_ifaces="0.0.0.0:6032"
8+
refresh_interval=2000
9+
restapi_enabled=true
10+
restapi_port=6070
11+
12+
cluster_username="proxyadmin"
13+
cluster_password="admin_password"
14+
cluster_check_interval_ms=200
15+
cluster_check_status_frequency=100
16+
cluster_mysql_query_rules_save_to_disk=true
17+
cluster_mysql_servers_save_to_disk=true
18+
cluster_mysql_users_save_to_disk=true
19+
cluster_proxysql_servers_save_to_disk=true
20+
cluster_mysql_query_rules_diffs_before_sync=1
21+
cluster_mysql_servers_diffs_before_sync=1
22+
cluster_mysql_users_diffs_before_sync=1
23+
cluster_proxysql_servers_diffs_before_sync=1
24+
}
25+
26+
mysql_variables=
27+
{
28+
monitor_password="monitor"
29+
monitor_galera_healthcheck_interval=1000
30+
threads=2
31+
max_connections=2048
32+
default_query_delay=0
33+
default_query_timeout=10000
34+
poll_timeout=2000
35+
interfaces="0.0.0.0:3306"
36+
default_schema="information_schema"
37+
stacksize=1048576
38+
connect_timeout_server=10000
39+
monitor_history=60000
40+
monitor_connect_interval=20000
41+
monitor_ping_interval=10000
42+
ping_timeout_server=200
43+
commands_stats=true
44+
sessions_sort=true
45+
have_ssl=true
46+
ssl_p2s_ca="/etc/proxysql/ssl-internal/ca.crt"
47+
ssl_p2s_cert="/etc/proxysql/ssl-internal/tls.crt"
48+
ssl_p2s_key="/etc/proxysql/ssl-internal/tls.key"
49+
ssl_p2s_cipher="ECDHE-RSA-AES128-GCM-SHA256"
50+
}
51+
```

Diff for: docs/haproxy-conf.md

+57-69
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Configuring Load Balancing with HAProxy
22

3-
Percona Operator for MySQL based on Percona XtraDB Cluster provides a choice of two cluster components to
4-
provide load balancing and proxy service: you can use either [HAProxy :octicons-link-external-16:](https://haproxy.org) or [ProxySQL :octicons-link-external-16:](https://proxysql.com/).
3+
You can use either [HAProxy :octicons-link-external-16:](https://haproxy.org) or [ProxySQL :octicons-link-external-16:](https://proxysql.com/) for load balancing and proxy services.
4+
55
You can control which one to use, if any, by enabling or disabling via the
66
`haproxy.enabled` and `proxysql.enabled` options in the `deploy/cr.yaml`
77
configuration file.
@@ -25,27 +25,46 @@ $ kubectl patch pxc cluster1 --type=merge --patch '{
2525
restart. Switching from HAProxy to ProxySQL is not possible, and if you need
2626
ProxySQL, this should be configured at cluster creation time.
2727

28-
The resulting HAProxy setup normally contains two services:
28+
## HAProxy services
29+
30+
The Operator creates two services for HAProxy:
31+
32+
### `cluster1-haproxy` service
33+
34+
The `cluster1-haproxy` service listens on the following ports:
35+
36+
* `3306` is the default MySQL port. It is used by the mysql client, MySQL Connectors, and utilities such as mysqldump and mysqlpump
37+
38+
* `3309` is the [proxy protocol :octicons-link-external-16:](https://www.haproxy.com/blog/haproxy/proxy-protocol/) port. Proxy protocol is used to store the client's IP address
39+
40+
* `33062` is the port to connect to the MySQL Administrative Interface
2941

30-
* `cluster1-haproxy` service listening on ports 3306 (MySQL) and 3309 (the [proxy protocol :octicons-link-external-16:](https://www.haproxy.com/blog/haproxy/proxy-protocol/) useful for operations such as asynchronous calls).
31-
This service is pointing to the number zero Percona XtraDB Cluster member
32-
(`cluster1-pxc-0`) by default when this member is available. If a zero
33-
member is not available, members are selected in descending order of their
34-
numbers (e.g. `cluster1-pxc-2`, then `cluster1-pxc-1`, etc.). This service
35-
can be used for both read and write load, or it can also be used just for
36-
write load (single writer mode) in setups with split write and read loads.
42+
* `33060` is the port for the [MySQLX protocol :octicons-link-external-16:](https://dev.mysql.com/doc/dev/mysql-server/8.4.3/PAGE_PROTOCOL.html). It is supported by clients such as MySQL Shell, MySQL Connectors and MySQL Router
3743

38-
[haproxy.enabled](operator.md#haproxyexposeprimaryenabled)
44+
* `8404` is the port to connect to the [HAProxy statistics page :octicons-link-external-16:](https://www.haproxy.com/blog/exploring-the-haproxy-stats-page)
45+
46+
The [haproxy.enabled](operator.md#haproxyexposeprimaryenabled)
3947
Custom Resource option enables or disables `cluster1-haproxy` service.
4048

41-
* `cluster1-haproxy-replicas` listening on port 3306 (MySQL).
42-
This service selects Percona XtraDB Cluster members to serve queries following
43-
the Round Robin load balancing algorithm.
44-
It **should not be used for write requests**.
49+
By default, the `cluster1-haproxy` service points to the number zero Percona XtraDB Cluster member (`cluster1-pxc-0`), when this member is available. If a zero member is not available, members are selected in descending order of their
50+
numbers: `cluster1-pxc-2`, then `cluster1-pxc-1`. This service
51+
can be used for both read and write load, or it can also be used just for
52+
write load (single writer mode) in setups with split write and read loads.
53+
54+
The [haproxy.exposePrimary.enabled](operator.md#haproxyexposeprimaryenabled)
55+
Custom Resource option enables or disables the `cluster1-haproxy` service.
56+
57+
### `cluster1-haproxy-replicas` service
4558

46-
[haproxy.exposeReplicas.enabled](operator.md#haproxyexposereplicasenabled)
47-
Custom Resource option enables or disables `cluster1-haproxy-replicas`
48-
service (on by default).
59+
The `cluster1-haproxy-replicas` service listens on port 3306 (MySQL).
60+
61+
This service selects Percona XtraDB Cluster members to serve queries following
62+
the Round Robin load balancing algorithm.
63+
64+
**Don't use it for write requests**.
65+
66+
The [haproxy.exposeReplicas.enabled](operator.md#haproxyexposereplicasenabled)
67+
Custom Resource option enables or disables `cluster1-haproxy-replicas` service (on by default).
4968

5069
!!! note
5170

@@ -149,12 +168,29 @@ haproxy:
149168
mode tcp
150169
option clitcpka
151170
default_backend galera-nodes
171+
172+
frontend galera-admin-in
173+
bind *:33062
174+
mode tcp
175+
option clitcpka
176+
default_backend galera-admin-nodes
177+
152178
frontend galera-replica-in
153-
bind *:3309 accept-proxy
154179
bind *:3307
155180
mode tcp
156181
option clitcpka
157182
default_backend galera-replica-nodes
183+
184+
frontend galera-mysqlx-in
185+
bind *:33060
186+
mode tcp
187+
option clitcpka
188+
default_backend galera-mysqlx-nodes
189+
190+
frontend stats
191+
bind *:8404
192+
mode http
193+
http-request use-service prometheus-exporter if { path /metrics }
158194
```
159195

160196
### Use a ConfigMap
@@ -170,31 +206,7 @@ ConfigMap :octicons-link-external-16:](https://kubernetes.io/docs/tasks/configur
170206
For example, you define a `haproxy.cfg` configuration file with the following
171207
setting:
172208

173-
```default
174-
global
175-
maxconn 2048
176-
external-check
177-
stats socket /var/run/haproxy.sock mode 600 expose-fd listeners level user
178-
defaults
179-
log global
180-
mode tcp
181-
retries 10
182-
timeout client 10000
183-
timeout connect 100500
184-
timeout server 10000
185-
frontend galera-in
186-
bind *:3309 accept-proxy
187-
bind *:3306
188-
mode tcp
189-
option clitcpka
190-
default_backend galera-nodes
191-
frontend galera-replica-in
192-
bind *:3309 accept-proxy
193-
bind *:3307
194-
mode tcp
195-
option clitcpka
196-
default_backend galera-replica-nodes
197-
```
209+
--8<-- "haproxy-config.txt"
198210

199211
You can create a configmap from the `haproxy.cfg` file with the
200212
`kubectl create configmap` command.
@@ -250,31 +262,7 @@ Actual options should be encoded with [Base64 :octicons-link-external-16:](https
250262
For example, let’s define a `haproxy.cfg` configuration file and put there
251263
options we used in the previous example:
252264

253-
```default
254-
global
255-
maxconn 2048
256-
external-check
257-
stats socket /var/run/haproxy.sock mode 600 expose-fd listeners level user
258-
defaults
259-
log global
260-
mode tcp
261-
retries 10
262-
timeout client 10000
263-
timeout connect 100500
264-
timeout server 10000
265-
frontend galera-in
266-
bind *:3309 accept-proxy
267-
bind *:3306
268-
mode tcp
269-
option clitcpka
270-
default_backend galera-nodes
271-
frontend galera-replica-in
272-
bind *:3309 accept-proxy
273-
bind *:3307
274-
mode tcp
275-
option clitcpka
276-
default_backend galera-replica-nodes
277-
```
265+
--8<-- "haproxy-config.txt"
278266

279267
You can get a Base64 encoded string from your options via the command line as
280268
follows:

0 commit comments

Comments
 (0)