From 48e5016608aa76f0ff9b8fa46a5da8402c285729 Mon Sep 17 00:00:00 2001 From: Ari-suhyeon Date: Tue, 10 Dec 2024 19:02:07 +0900 Subject: [PATCH] Add service account and enhance health check for Wave Autoscale cronjob --- .../WaveAutoscale/wave-autoscale-cronjob.yaml | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/eks-anywhere-common/Testers/STCLab/WaveAutoscale/wave-autoscale-cronjob.yaml b/eks-anywhere-common/Testers/STCLab/WaveAutoscale/wave-autoscale-cronjob.yaml index fdd40d78..a6e7eec3 100644 --- a/eks-anywhere-common/Testers/STCLab/WaveAutoscale/wave-autoscale-cronjob.yaml +++ b/eks-anywhere-common/Testers/STCLab/WaveAutoscale/wave-autoscale-cronjob.yaml @@ -9,6 +9,7 @@ spec: spec: template: spec: + serviceAccountName: wave-autoscale-sa containers: - name: wave-autoscale-healthcheck image: alpine/k8s:1.26.9 @@ -17,6 +18,9 @@ spec: args: - -c - | + # + # Health check for Wave Autoscale + # echo "Start a health check for Wave Autoscale"; # Core health check @@ -69,6 +73,31 @@ spec: exit 1; fi + # + # Autopilot behavior check + # + echo "Start checking Autopilot behavior"; + + # 1. Agent Running Check + AGENT_POD_LIST=$(kubectl get pods -n wave-autoscale -l app.kubernetes.io/name=wave-autoscale-agent -o jsonpath='{.items[*].metadata.name}') + AGENT_ALL_RUNNING=true + for POD in $AGENT_POD_LIST; do + STATUS=$(kubectl get pod "$POD" -n wave-autoscale -o jsonpath='{.status.phase}') + if [ "$STATUS" != "Running" ]; then + echo "Agent Pod $POD is not running (current status: $STATUS)" + AGENT_ALL_RUNNING=false + else + echo "Agent Pod $POD is running.." + fi + done + if [ "$AGENT_ALL_RUNNING" = true ]; then + echo "All Agent Pods in DaemonSet '$DAEMONSET_NAME' are running." + else + echo "Some Agent Pods in DaemonSet '$DAEMONSET_NAME' are not running." + exit 1 + fi + + exit 0; restartPolicy: Never backoffLimit: 1