-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #494 from appuio/haproxy/http_checks
Adding https checks for HAproxy and Galera
- Loading branch information
Showing
10 changed files
with
105 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ apiVersion: v1 | |
appVersion: 2.7.3 | ||
description: A Helm chart for HAProxy which can be customized by a config map. | ||
name: haproxy | ||
version: 2.3.1 | ||
version: 2.4.0 | ||
maintainers: | ||
- name: APPUiO Team | ||
email: [email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from haproxytech/haproxy-debian:2.8.3 | ||
|
||
RUN curl -o mysql.deb https://dev.mysql.com/get/mysql-apt-config_0.8.26-1_all.deb || exit 1 \ | ||
dpkg -i mysql.deb || exit 1 ; \ | ||
apt-get update || exit 1 ; \ | ||
apt-get install -y default-mysql-client || exit 1 ; \ | ||
rm -rf /var/lib/apt/lists/* mysql.deb ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/bin/bash | ||
|
||
#==================================================================================================== | ||
### This script is used to check the status of the Galera cluster by HAProxy | ||
### Maintainer: https://github.com/wejdross | ||
### It's sh/dash compatible, because it's used in a haproxy container and bash shell has serious issues to spawn | ||
### logic is simple, it takes 4 parameters and check if they are equal to the expected value | ||
### parameters are returned always in the same manner thanks to ORDER BY, if any of the parameters is not equal to the expected value, script will exit with 1 | ||
#==================================================================================================== | ||
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin | ||
pass=$(/bin/cat /secrets/mariadb-root-password) | ||
|
||
if [ -z "$pass" ]; then | ||
echo "Error: password is empty, please check mount and permission declared in haproxy deployment" | ||
exit 1 | ||
fi | ||
|
||
# sample return -> "WSREP_CLUSTER_STATUS Primary WSREP_CONNECTED ON WSREP_LOCAL_STATE 4 WSREP_READY ON" | ||
return_val=$(/usr/bin/mysql -h $3 -u root -p"$pass" -e "SELECT VARIABLE_NAME, VARIABLE_VALUE FROM information_schema.global_status WHERE VARIABLE_NAME IN ('wsrep_cluster_status','wsrep_ready','wsrep_local_state','wsrep_connected') ORDER BY VARIABLE_NAME ASC;" -Ns) | ||
if [ $? -ne 0 ]; then | ||
exit 1 | ||
else | ||
to_check=$(echo $return_val | cut -d' ' -f2) | ||
|
||
if [ $to_check != "Primary" ]; then | ||
echo "Error: WSREP_CLUSTER_STATUS is not 'Primary' it's: $to_check" | ||
exit 1 | ||
fi | ||
|
||
to_check=$(echo $return_val | cut -d' ' -f4) | ||
|
||
if [ $to_check != "ON" ]; then | ||
echo "Error: WSREP_CONNECTED is not 'ON' it's: $to_check" | ||
exit 1 | ||
fi | ||
|
||
to_check=$(echo $return_val | cut -d' ' -f6) | ||
|
||
if [ $to_check != 4 ]; then | ||
echo "Error: WSREP_LOCAL_STATE is not '4' it's: $to_check" | ||
exit 1 | ||
fi | ||
|
||
to_check=$(echo $return_val | cut -d' ' -f8) | ||
if [ $to_check != "ON" ]; then | ||
echo "Error: WSREP_READY is not 'ON' it's: $to_check" | ||
exit 1 | ||
fi | ||
fi | ||
exit 0 |
17 changes: 17 additions & 0 deletions
17
appuio/haproxy/templates/configmap-galera-checkscript.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{{- if or (eq .Values.haproxy.config "galera") (eq .Values.haproxy.config "galerak8s") }} | ||
|
||
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: |- | ||
{{ range .Files.Lines "files/galera-check.sh" }} | ||
{{ . | indent 2 }} | ||
{{- end}} | ||
{{- end}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters