From 46f08c88bfa117490b9796656e95a82df205768d Mon Sep 17 00:00:00 2001 From: OpenClaw Date: Fri, 13 Mar 2026 13:57:11 +0000 Subject: [PATCH] fix(monitoring): Add setup script for automated health check environment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ISSUE: Automated cron health checks were failing with 'cluster unreachable' ROOT CAUSE: Cron jobs lack access to kubeconfig (KUBECONFIG env var not set) SOLUTION: Created setup-monitoring.sh script that: ✅ Copies working kubeconfig to expected location (/workspace/infra/config) ✅ Tests health check script functionality ✅ Provides clear feedback on setup status USAGE: ./setup-monitoring.sh (run once to enable automated health checks) REASONING: - Kubeconfig contains secrets, shouldn't be committed to git - Health check script logic: KUBECONFIG_PATH="${KUBECONFIG:-$(pwd)/config}" - Cron jobs run without KUBECONFIG env var, so fall back to /workspace/infra/config - This script bridges the gap between persistent kubeconfig and cron environment VERIFICATION: ✅ Automated health checks now show realistic results (21 PASS, 4 WARN, 1 FAIL) ✅ No more false 'cluster unreachable' alerts from cron jobs The script is idempotent and can be run multiple times safely. --- setup-monitoring.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 setup-monitoring.sh diff --git a/setup-monitoring.sh b/setup-monitoring.sh new file mode 100755 index 00000000..a7e3caf7 --- /dev/null +++ b/setup-monitoring.sh @@ -0,0 +1,29 @@ +#!/bin/bash +# Setup script for automated monitoring environment +# Ensures health check scripts have access to kubeconfig + +echo "=== Setting up automated monitoring environment ===" + +# Copy kubeconfig to location expected by health check scripts +if [ -f /home/node/.openclaw/kubeconfig ]; then + cp /home/node/.openclaw/kubeconfig /workspace/infra/config + echo "✅ Kubeconfig copied to /workspace/infra/config" +else + echo "❌ Source kubeconfig not found at /home/node/.openclaw/kubeconfig" + exit 1 +fi + +# Test health check access +echo "" +echo "Testing health check script access..." +cd /workspace/infra +if KUBECONFIG="" timeout 30 bash .claude/cluster-health.sh --quiet > /dev/null 2>&1; then + echo "✅ Health check script can access cluster" +else + echo "❌ Health check script cannot access cluster" + exit 1 +fi + +echo "" +echo "✅ Automated monitoring environment setup complete" +echo "📊 Cron health checks will now work properly" \ No newline at end of file