deploy: add 110 proxysql canary manifests
This commit is contained in:
parent
d2579f3f0f
commit
9637fb5bb3
143
ops/110-proxysql/00-host-mysql-entrypoints.yaml
Normal file
143
ops/110-proxysql/00-host-mysql-entrypoints.yaml
Normal file
@ -0,0 +1,143 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: mysql-prd-primary
|
||||
namespace: prd
|
||||
labels:
|
||||
app.kubernetes.io/name: mysql-prd-primary
|
||||
app.kubernetes.io/part-of: mes-prd-database
|
||||
spec:
|
||||
type: ClusterIP
|
||||
ports:
|
||||
- name: mysql
|
||||
port: 3306
|
||||
targetPort: 3316
|
||||
protocol: TCP
|
||||
---
|
||||
apiVersion: discovery.k8s.io/v1
|
||||
kind: EndpointSlice
|
||||
metadata:
|
||||
name: mysql-prd-primary-hosts
|
||||
namespace: prd
|
||||
labels:
|
||||
kubernetes.io/service-name: mysql-prd-primary
|
||||
app.kubernetes.io/name: mysql-prd-primary
|
||||
app.kubernetes.io/part-of: mes-prd-database
|
||||
addressType: IPv4
|
||||
ports:
|
||||
- name: mysql
|
||||
protocol: TCP
|
||||
port: 3316
|
||||
endpoints:
|
||||
- addresses:
|
||||
- "192.168.110.208"
|
||||
conditions:
|
||||
ready: true
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: mysql-prd-replica-1
|
||||
namespace: prd
|
||||
labels:
|
||||
app.kubernetes.io/name: mysql-prd-replica-1
|
||||
app.kubernetes.io/part-of: mes-prd-database
|
||||
spec:
|
||||
type: ClusterIP
|
||||
ports:
|
||||
- name: mysql
|
||||
port: 3306
|
||||
targetPort: 3306
|
||||
protocol: TCP
|
||||
---
|
||||
apiVersion: discovery.k8s.io/v1
|
||||
kind: EndpointSlice
|
||||
metadata:
|
||||
name: mysql-prd-replica-1-hosts
|
||||
namespace: prd
|
||||
labels:
|
||||
kubernetes.io/service-name: mysql-prd-replica-1
|
||||
app.kubernetes.io/name: mysql-prd-replica-1
|
||||
app.kubernetes.io/part-of: mes-prd-database
|
||||
addressType: IPv4
|
||||
ports:
|
||||
- name: mysql
|
||||
protocol: TCP
|
||||
port: 3306
|
||||
endpoints:
|
||||
- addresses:
|
||||
- "192.168.110.73"
|
||||
conditions:
|
||||
ready: true
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: mysql-prd-replica-2
|
||||
namespace: prd
|
||||
labels:
|
||||
app.kubernetes.io/name: mysql-prd-replica-2
|
||||
app.kubernetes.io/part-of: mes-prd-database
|
||||
spec:
|
||||
type: ClusterIP
|
||||
ports:
|
||||
- name: mysql
|
||||
port: 3306
|
||||
targetPort: 3306
|
||||
protocol: TCP
|
||||
---
|
||||
apiVersion: discovery.k8s.io/v1
|
||||
kind: EndpointSlice
|
||||
metadata:
|
||||
name: mysql-prd-replica-2-hosts
|
||||
namespace: prd
|
||||
labels:
|
||||
kubernetes.io/service-name: mysql-prd-replica-2
|
||||
app.kubernetes.io/name: mysql-prd-replica-2
|
||||
app.kubernetes.io/part-of: mes-prd-database
|
||||
addressType: IPv4
|
||||
ports:
|
||||
- name: mysql
|
||||
protocol: TCP
|
||||
port: 3306
|
||||
endpoints:
|
||||
- addresses:
|
||||
- "192.168.110.13"
|
||||
conditions:
|
||||
ready: true
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: mysql-prd-backup
|
||||
namespace: prd
|
||||
labels:
|
||||
app.kubernetes.io/name: mysql-prd-backup
|
||||
app.kubernetes.io/part-of: mes-prd-database
|
||||
spec:
|
||||
type: ClusterIP
|
||||
ports:
|
||||
- name: mysql
|
||||
port: 3306
|
||||
targetPort: 3306
|
||||
protocol: TCP
|
||||
---
|
||||
apiVersion: discovery.k8s.io/v1
|
||||
kind: EndpointSlice
|
||||
metadata:
|
||||
name: mysql-prd-backup-hosts
|
||||
namespace: prd
|
||||
labels:
|
||||
kubernetes.io/service-name: mysql-prd-backup
|
||||
app.kubernetes.io/name: mysql-prd-backup
|
||||
app.kubernetes.io/part-of: mes-prd-database
|
||||
addressType: IPv4
|
||||
ports:
|
||||
- name: mysql
|
||||
protocol: TCP
|
||||
port: 3306
|
||||
endpoints:
|
||||
- addresses:
|
||||
- "192.168.110.64"
|
||||
conditions:
|
||||
ready: true
|
||||
119
ops/110-proxysql/10-proxysql.yaml
Normal file
119
ops/110-proxysql/10-proxysql.yaml
Normal file
@ -0,0 +1,119 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: proxysql-prd
|
||||
namespace: prd
|
||||
labels:
|
||||
app: proxysql-prd
|
||||
app.kubernetes.io/name: proxysql
|
||||
app.kubernetes.io/part-of: mes-prd-database
|
||||
spec:
|
||||
replicas: 2
|
||||
strategy:
|
||||
type: RollingUpdate
|
||||
rollingUpdate:
|
||||
maxUnavailable: 0
|
||||
maxSurge: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: proxysql-prd
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: proxysql-prd
|
||||
app.kubernetes.io/name: proxysql
|
||||
app.kubernetes.io/part-of: mes-prd-database
|
||||
spec:
|
||||
affinity:
|
||||
podAntiAffinity:
|
||||
preferredDuringSchedulingIgnoredDuringExecution:
|
||||
- weight: 100
|
||||
podAffinityTerm:
|
||||
topologyKey: kubernetes.io/hostname
|
||||
labelSelector:
|
||||
matchLabels:
|
||||
app: proxysql-prd
|
||||
containers:
|
||||
- name: proxysql
|
||||
image: 192.168.100.49:30002/prd/proxysql:3.0.9-debian@sha256:7082d349bfe4e9ac7341bd43833ef085bac6b414a7a3d58bdb6f58c5887cccaf
|
||||
imagePullPolicy: IfNotPresent
|
||||
command:
|
||||
- proxysql
|
||||
args:
|
||||
- --initial
|
||||
- -f
|
||||
- -c
|
||||
- /etc/proxysql.cnf
|
||||
ports:
|
||||
- name: mysql
|
||||
containerPort: 6033
|
||||
resources:
|
||||
requests:
|
||||
cpu: 250m
|
||||
memory: 256Mi
|
||||
limits:
|
||||
cpu: "2"
|
||||
memory: 1Gi
|
||||
startupProbe:
|
||||
tcpSocket:
|
||||
port: mysql
|
||||
failureThreshold: 30
|
||||
periodSeconds: 2
|
||||
readinessProbe:
|
||||
tcpSocket:
|
||||
port: mysql
|
||||
periodSeconds: 5
|
||||
timeoutSeconds: 2
|
||||
livenessProbe:
|
||||
tcpSocket:
|
||||
port: mysql
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 2
|
||||
failureThreshold: 3
|
||||
securityContext:
|
||||
allowPrivilegeEscalation: false
|
||||
capabilities:
|
||||
drop:
|
||||
- ALL
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: /etc/proxysql.cnf
|
||||
subPath: proxysql.cnf
|
||||
readOnly: true
|
||||
- name: data
|
||||
mountPath: /var/lib/proxysql
|
||||
volumes:
|
||||
- name: config
|
||||
secret:
|
||||
secretName: proxysql-prd-config
|
||||
defaultMode: 0400
|
||||
- name: data
|
||||
emptyDir: {}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: proxysql-prd-canary
|
||||
namespace: prd
|
||||
labels:
|
||||
app.kubernetes.io/name: proxysql
|
||||
app.kubernetes.io/part-of: mes-prd-database
|
||||
spec:
|
||||
selector:
|
||||
app: proxysql-prd
|
||||
ports:
|
||||
- name: mysql
|
||||
port: 3306
|
||||
targetPort: mysql
|
||||
protocol: TCP
|
||||
---
|
||||
apiVersion: policy/v1
|
||||
kind: PodDisruptionBudget
|
||||
metadata:
|
||||
name: proxysql-prd
|
||||
namespace: prd
|
||||
spec:
|
||||
minAvailable: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: proxysql-prd
|
||||
36
ops/110-proxysql/README.md
Normal file
36
ops/110-proxysql/README.md
Normal file
@ -0,0 +1,36 @@
|
||||
# 110 ProxySQL canary
|
||||
|
||||
This directory contains the manually applied ProxySQL resources for the
|
||||
`10.10.11.110` production cluster. The topology matches the `10.10.11.10`
|
||||
cluster: MySQL runs natively on the hosts and two stateless ProxySQL pods run
|
||||
in Kubernetes.
|
||||
|
||||
## Backends
|
||||
|
||||
| Hostgroup | Role | Endpoint |
|
||||
| --- | --- | --- |
|
||||
| 10 | Writer | `192.168.110.208:3316` |
|
||||
| 20 | Reader 1 | `192.168.110.73:3306` |
|
||||
| 20 | Reader 2 | `192.168.110.13:3306` |
|
||||
| excluded | Backup replica | `192.168.110.64:3306` |
|
||||
|
||||
The writer is also present in hostgroup 20 at weight 1, matching the existing
|
||||
10-cluster configuration. The backup replica is deliberately excluded from
|
||||
ProxySQL traffic.
|
||||
|
||||
## Deployment safety
|
||||
|
||||
Create `proxysql-prd-config` from `proxysql.cnf.template` outside Git. Replace
|
||||
both password placeholders and never commit the rendered file. Apply the
|
||||
selectorless MySQL Services first, then the ProxySQL Deployment and canary
|
||||
Service.
|
||||
|
||||
```bash
|
||||
kubectl apply -f 00-host-mysql-entrypoints.yaml
|
||||
kubectl apply -f 10-proxysql.yaml
|
||||
```
|
||||
|
||||
Only `proxysql-prd-canary.prd.svc:3306` is created. Do not create or replace
|
||||
the production `mysql-prd` Service, change Rainbond environment variables, or
|
||||
retire MaxScale until canary routing has passed and a separate cutover is
|
||||
approved.
|
||||
132
ops/110-proxysql/proxysql.cnf.template
Normal file
132
ops/110-proxysql/proxysql.cnf.template
Normal file
@ -0,0 +1,132 @@
|
||||
datadir="/var/lib/proxysql"
|
||||
|
||||
admin_variables=
|
||||
{
|
||||
admin_credentials="admin:__ADMIN_PASSWORD__";
|
||||
mysql_ifaces="0.0.0.0:6032"
|
||||
}
|
||||
|
||||
mysql_variables=
|
||||
{
|
||||
threads=4
|
||||
max_connections=4096
|
||||
default_query_delay=0
|
||||
default_query_timeout=36000000
|
||||
have_compress=true
|
||||
poll_timeout=2000
|
||||
interfaces="0.0.0.0:6033"
|
||||
default_schema="information_schema"
|
||||
server_version="8.0.46"
|
||||
connect_timeout_server=3000
|
||||
connect_retries_on_failure=3
|
||||
ping_interval_server_msec=10000
|
||||
ping_timeout_server=1000
|
||||
monitor_username="wip"
|
||||
monitor_password="__MYSQL_PASSWORD__"
|
||||
monitor_history=600000
|
||||
monitor_connect_interval=2000
|
||||
monitor_ping_interval=2000
|
||||
monitor_read_only_interval=2000
|
||||
monitor_read_only_timeout=1000
|
||||
monitor_writer_is_also_reader=false
|
||||
commands_stats=true
|
||||
sessions_sort=true
|
||||
}
|
||||
|
||||
mysql_servers=
|
||||
(
|
||||
{
|
||||
address="mysql-prd-primary"
|
||||
port=3306
|
||||
hostgroup=10
|
||||
weight=100
|
||||
max_connections=500
|
||||
},
|
||||
{
|
||||
address="mysql-prd-primary"
|
||||
port=3306
|
||||
hostgroup=20
|
||||
weight=1
|
||||
max_connections=500
|
||||
},
|
||||
{
|
||||
address="mysql-prd-replica-1"
|
||||
port=3306
|
||||
hostgroup=20
|
||||
weight=100
|
||||
max_connections=500
|
||||
},
|
||||
{
|
||||
address="mysql-prd-replica-2"
|
||||
port=3306
|
||||
hostgroup=20
|
||||
weight=100
|
||||
max_connections=500
|
||||
}
|
||||
)
|
||||
|
||||
mysql_users=
|
||||
(
|
||||
{
|
||||
username="wip"
|
||||
password="__MYSQL_PASSWORD__"
|
||||
default_hostgroup=10
|
||||
default_schema="information_schema"
|
||||
transaction_persistent=1
|
||||
max_connections=4096
|
||||
active=1
|
||||
}
|
||||
)
|
||||
|
||||
mysql_query_rules=
|
||||
(
|
||||
{
|
||||
rule_id=10
|
||||
active=1
|
||||
match_digest="^SELECT .* FOR UPDATE"
|
||||
destination_hostgroup=10
|
||||
apply=1
|
||||
},
|
||||
{
|
||||
rule_id=20
|
||||
active=1
|
||||
match_digest="^SELECT .* FOR SHARE"
|
||||
destination_hostgroup=10
|
||||
apply=1
|
||||
},
|
||||
{
|
||||
rule_id=30
|
||||
active=1
|
||||
match_digest="^SELECT .* LOCK IN SHARE MODE"
|
||||
destination_hostgroup=10
|
||||
apply=1
|
||||
},
|
||||
{
|
||||
rule_id=40
|
||||
active=1
|
||||
match_digest="^SELECT (LAST_INSERT_ID|GET_LOCK|RELEASE_LOCK|IS_USED_LOCK|IS_FREE_LOCK|FOUND_ROWS|ROW_COUNT)"
|
||||
destination_hostgroup=10
|
||||
apply=1
|
||||
},
|
||||
{
|
||||
rule_id=50
|
||||
active=1
|
||||
match_digest="^SELECT @@"
|
||||
destination_hostgroup=10
|
||||
apply=1
|
||||
},
|
||||
{
|
||||
rule_id=60
|
||||
active=1
|
||||
match_digest="^SELECT .* SQL_CALC_FOUND_ROWS"
|
||||
destination_hostgroup=10
|
||||
apply=1
|
||||
},
|
||||
{
|
||||
rule_id=100
|
||||
active=1
|
||||
match_digest="^SELECT"
|
||||
destination_hostgroup=20
|
||||
apply=1
|
||||
}
|
||||
)
|
||||
Loading…
Reference in New Issue
Block a user