-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdolt-proxysql.yaml
More file actions
137 lines (131 loc) · 3.79 KB
/
dolt-proxysql.yaml
File metadata and controls
137 lines (131 loc) · 3.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
---
apiVersion: v1
kind: ConfigMap
metadata:
name: proxysql-config
namespace: dolt-cluster-example
data:
proxysql.cnf: |
datadir="/var/lib/proxysql"
admin_variables=
{
admin_credentials="admin:admin"
mysql_ifaces="0.0.0.0:6032"
}
mysql_variables=
{
threads=4
}
mysql_servers = (
{ address="dolt", port=3306, hostgroup=10, max_connections=1000 },
{ address="dolt-ro", port=3306, hostgroup=20, max_connections=1000 }
)
mysql_users = (
{ username = "monitor", password = "monitor", default_hostgroup = 10, active = 1 },
{ username = "stnduser", password = "stnduser", default_hostgroup = 10, active = 1 }
)
mysql_replication_hostgroups = (
{ writer_hostgroup=10, reader_hostgroup=20, comment="dolt-cluster" }
)
mysql_monitor =
{
username = "monitor"
password = "monitor"
connect_interval = 2000
ping_interval = 2000
read_only_interval = 2000
}
mysql_query_rules = (
{ rule_id=1, active=1, match_pattern="^SELECT", destination_hostgroup=20, apply=1 },
{ rule_id=2, active=1, match_pattern=".*", destination_hostgroup=10, apply=1 }
)
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: proxysql
namespace: dolt-cluster-example
spec:
replicas: 1
selector:
matchLabels:
app: proxysql
template:
metadata:
labels:
app: proxysql
spec:
initContainers:
- name: create-monitor-user
image: mysql:8
env:
- name: DOLT_USERNAME
valueFrom:
secretKeyRef:
name: dolt-credentials
key: admin-user
- name: DOLT_PASSWORD
valueFrom:
secretKeyRef:
name: dolt-credentials
key: admin-password
command: ["/bin/sh", "-c"]
args:
# note on: for HOST in dolt dolt-ro; do ... dolt-ro is standby replicated,
# is read-only, and already receives the "monitor" user by replication in our case
- |
for HOST in dolt; do
until mysql -h $HOST -u"$DOLT_USERNAME" -p"$DOLT_PASSWORD" -e "SELECT 1;"; do
echo "Waiting for $HOST..." && sleep 2
done
mysql -h $HOST -u"$DOLT_USERNAME" -p"$DOLT_PASSWORD" -e "
CREATE USER IF NOT EXISTS 'monitor'@'%' IDENTIFIED BY 'monitor';
GRANT SELECT ON sys.* TO 'monitor'@'%';
GRANT SELECT ON performance_schema.* TO 'monitor'@'%';
GRANT USAGE, REPLICATION CLIENT ON *.* TO 'monitor'@'%';
CREATE USER IF NOT EXISTS 'stnduser'@'%' IDENTIFIED BY 'stnduser';
GRANT ALL PRIVILEGES ON *.* TO 'stnduser'@'%';
"
done
resources:
requests:
cpu: 10m
memory: 32Mi
limits:
cpu: 50m
memory: 128Mi
containers:
- name: proxysql
image: proxysql/proxysql:2.5.2
imagePullPolicy: IfNotPresent
ports:
- containerPort: 6032 # admin
- containerPort: 6033 # MySQL client port
volumeMounts:
- name: config
mountPath: /etc/proxysql.cnf
subPath: proxysql.cnf
- name: data
mountPath: /var/lib/proxysql
volumes:
- name: config
configMap:
name: proxysql-config
- name: data
emptyDir: {}
---
apiVersion: v1
kind: Service
metadata:
name: proxysql
namespace: dolt-cluster-example
spec:
selector:
app: proxysql
ports:
- name: mysql
port: 3306
targetPort: 6033
- name: admin
port: 6032
targetPort: 6032