From fa408712925a18a49614f1e4e295b49e1284cfd5 Mon Sep 17 00:00:00 2001 From: Priyanka Date: Wed, 16 May 2018 04:30:25 +0000 Subject: Clamp DB Health Check Issue-ID: OOM-688 Change-Id: Ied8688fdfa7759b8b5f33b9914195d227eb08e48 Signed-off-by: Priyanka --- .../config/consul-agent-config/clamp-mariadb-health.json | 16 ++++++++++++++++ .../consul-agent-config/scripts/clamp-mariadb-script.sh | 15 +++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 kubernetes/consul/resources/config/consul-agent-config/clamp-mariadb-health.json create mode 100644 kubernetes/consul/resources/config/consul-agent-config/scripts/clamp-mariadb-script.sh (limited to 'kubernetes/consul/resources') diff --git a/kubernetes/consul/resources/config/consul-agent-config/clamp-mariadb-health.json b/kubernetes/consul/resources/config/consul-agent-config/clamp-mariadb-health.json new file mode 100644 index 0000000000..f5ae467d74 --- /dev/null +++ b/kubernetes/consul/resources/config/consul-agent-config/clamp-mariadb-health.json @@ -0,0 +1,16 @@ +{ + "service": { + "name": "Health Check: CLAMP - MariaDb", + "checks": [ + { + "id": "clamp-mariadb", + "name": "CLAMP Mariadb Health Check", + "script": "/consul/scripts/clamp-mariadb-script.sh", + "interval": "10s", + "timeout": "1s" + } + ] + + } +} + diff --git a/kubernetes/consul/resources/config/consul-agent-config/scripts/clamp-mariadb-script.sh b/kubernetes/consul/resources/config/consul-agent-config/scripts/clamp-mariadb-script.sh new file mode 100644 index 0000000000..2cf7fc78c5 --- /dev/null +++ b/kubernetes/consul/resources/config/consul-agent-config/scripts/clamp-mariadb-script.sh @@ -0,0 +1,15 @@ +NAME=$(/consul/bin/kubectl -n {{ include "common.namespace" . }} get pod | grep -o "[^[:space:]]*-clampdb[^[:space:]]*") + + if [ -n "$NAME" ]; then + if /consul/bin/kubectl -n {{ include "common.namespace" . }} exec -it $NAME -- bash -c 'mysqladmin status -u root -p$MYSQL_ROOT_PASSWORD' > /dev/null; then + echo Success. CLAMP DBHost is running. 2>&1 + exit 0 + else + echo Failed. CLAMP DBHost is not running. 2>&1 + exit 1 + fi + else + echo Failed. CLAMP DBHost is offline. 2>&1 + exit 1 + fi + -- cgit 1.2.3-korg