Skip to content

Commit

Permalink
fixing haproxy checkscript
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] committed Sep 26, 2023
1 parent 1d81364 commit aa25f98
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 17 deletions.
16 changes: 16 additions & 0 deletions appuio/haproxy/files/galera-check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

# Run the MySQL query and store the result in a Bash variable

wsrep_ready=`/bin/cat /secrets/mariadb-root-password | /usr/bin/mysql -h $3 -u root -p -e "SELECT VARIABLE_VALUE FROM information_schema.global_status WHERE VARIABLE_NAME = 'wsrep_ready';" -N`
if [ $? -ne 0 ]; then
echo Error: Unable to connect to MySQL or query failed
exit 1
fi

if [ $wsrep_ready != "ON" ]; then
echo Error: wsrep_ready is not ON, actual status is: $WSREP_READY
exit 1
fi

exit 0
28 changes: 11 additions & 17 deletions appuio/haproxy/templates/configmap-galera-checkscript.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,16 @@

kind: ConfigMap
apiVersion: v1
metadata:
labels:
app.kubernetes.io/name: {{ include "haproxy.name" . }}
helm.sh/chart: {{ include "haproxy.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
name: haproxy-script
data:
script.sh: |
#!/bin/bash
# Run the MySQL query and store the result in a Bash variable
wsrep_ready=$(/bin/cat /secrets/mariadb-root-password | /usr/bin/mysql-h $3 -u root -p -e SELECT VARIABLE_VALUE FROM information_schema.global_status WHERE VARIABLE_NAME = 'wsrep_ready'; -N)
if [ $? -ne 0 ]; then
echo Error: Unable to connect to MySQL or query failed
exit 1
fi
if [ $wsrep_ready != "ON" ]; then
echo Error: wsrep_ready is not ON, actual status is: $WSREP_READY
exit 1
fi
exit 0
script.sh: |-
{{ range .Files.Lines "files/galera-check.sh" }}
{{ . | indent 2 }}
{{- end}}
{{- end}}

0 comments on commit aa25f98

Please sign in to comment.