From edc616391a4236d1563f22d6c21cf34dd88a3219 Mon Sep 17 00:00:00 2001 From: Ari-suhyeon Date: Mon, 2 Dec 2024 09:42:18 +0900 Subject: [PATCH] Add CronJob for Wave Autoscale health checks --- .../WaveAutoscale/wave-autoscale-cronjob.yaml | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 eks-anywhere-common/Testers/STCLab/WaveAutoscale/wave-autoscale-cronjob.yaml diff --git a/eks-anywhere-common/Testers/STCLab/WaveAutoscale/wave-autoscale-cronjob.yaml b/eks-anywhere-common/Testers/STCLab/WaveAutoscale/wave-autoscale-cronjob.yaml new file mode 100644 index 00000000..10e08f8b --- /dev/null +++ b/eks-anywhere-common/Testers/STCLab/WaveAutoscale/wave-autoscale-cronjob.yaml @@ -0,0 +1,64 @@ +apiVersion: batch/v1 +kind: CronJob +metadata: + name: wave-autoscale-healthcheck + namespace: wave-autoscale +spec: + schedule: "*/10 * * * *" + jobTemplate: + spec: + template: + spec: + containers: + - name: wave-autoscale-healthcheck + image: alpine/k8s:1.26.9 + command: + - /bin/sh + args: + - -c + - >- + echo Start a health check for Wave Autoscale; + response=$(curl -sL http://wave-autoscale-svc.wave-autoscale.svc.cluster.local:3024/); + code=$(echo ${response} | jq .code); + if [ "$code" -eq 200 ]; then + echo "Wave Autoscale Core working Successful." + exit 0 + else + echo "Failed to fetch Wave Autoscale Core. Response was $response" + exit 1 + fi + response=$(curl -sL http://wave-autoscale-svc.wave-autoscale.svc.cluster.local:3024/api/info); + code=$(echo ${response} | jq .code); + if [ "$code" -eq 200 ]; then + license=$(echo "$response" | jq -r '.license') + if [[ "$license" == "{}" ]]; then + echo "Wave Autoscale License is invalid: empty map detected." + exit 1 + else + echo "Wave Autoscale License is valid." + exit 0 + fi + else + echo "Wave Autoscale License is is invalid." + exit 1 + fi + response=$(curl -sL http://wave-autoscale-svc.wave-autoscale.svc.cluster.local:3025/); + code=$(echo ${response} | jq .code); + if [ "$code" -eq 200 ]; then + echo "Wave Autoscale Web Console working Successful." + exit 0 + else + echo "Failed to fetch Wave Autoscale Web Console. Response was $response" + exit 1 + fi + response=$(curl -sL http://wave-autoscale-svc.wave-autoscale.svc.cluster.local:3026/); + code=$(echo ${response} | jq .code); + if [ "$code" -eq 200 ]; then + echo "Wave Autoscale Autopilot working Successful." + exit 0 + else + echo "Failed to fetch Wave Autoscale Autopilot. Response was $response" + exit 1 + fi + restartPolicy: Never + backoffLimit: 1