Add healthcheck to proxysql

This commit is contained in:
Micke Nordin 2023-08-15 14:01:08 +02:00
parent 3e2bb251ee
commit 072f762a0d
2 changed files with 29 additions and 0 deletions

View file

@ -406,3 +406,10 @@ data:
{ hostname = "proxysql-1.proxysqlcluster", port = 6032, weight = 1 },
{ hostname = "proxysql-2.proxysqlcluster", port = 6032, weight = 1 }
)
healthcheck.sh: |
#!/bin/bash
num_servers=$(mysql -NB -u admin -h 127.0.0.1 -P 6032 -e "select count(*) from main.mysql_servers")
if [[ ${num_servers} -lt 1 ]]; then
exit 1
fi
exit 0

View file

@ -50,11 +50,27 @@ spec:
- name: proxysql-etc
mountPath: /etc
subPath: etc
- name: proxysql-healthcheck
mountPath: /usr/local/bin/healthcheck.sh
subPath: healthcheck.sh
ports:
- containerPort: 6033
name: proxysql-mysql
- containerPort: 6032
name: proxysql-admin
env:
- name: MYSQL_PWD
valueFrom:
secretKeyRef:
name: proxysql-secret
key: "proxysql_admin_password"
livenessProbe:
exec:
command:
- /bin/bash
- /usr/local/bin/healthcheck.sh
initialDelaySeconds: 5
periodSeconds: 5
initContainers:
- image: docker.sunet.se/sunet/docker-jinja:latest
name: init-config
@ -309,3 +325,9 @@ spec:
items:
- key: "proxysql.cnf"
path: "proxysql.cnf"
- name: proxysql-healthcheck
configMap:
name: proxysql-configmap
items:
- key: "healthcheck.sh"
path: "healthcheck.sh"