video-iac/scripts/list-build-runners.sh

47 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
# Simple script to list Gitea Build Runners in Staging or Production
ENVIRONMENT=""
NAMESPACE="jam-cloud-infra"
APP_LABEL="app=act-runner"
case "$1" in
--stg)
ENVIRONMENT="stg"
source ~/bin/activate-stg
;;
--prd)
ENVIRONMENT="prd"
source ~/bin/activate-prd
;;
*)
echo "Usage: $0 --stg|--prd"
exit 1
;;
esac
echo "--------------------------------------------------------"
echo "🔍 Checking Build Runners in [$ENVIRONMENT]"
echo "--------------------------------------------------------"
# 1. Check Deployment Replicas
REPLICAS=$(kubectl get deployment act-runner -n $NAMESPACE -o jsonpath='{.spec.replicas}' 2>/dev/null)
READY=$(kubectl get deployment act-runner -n $NAMESPACE -o jsonpath='{.status.readyReplicas}' 2>/dev/null)
if [ -z "$REPLICAS" ]; then
echo "❌ Deployment 'act-runner' not found in $NAMESPACE"
else
echo "📈 Deployment Status: $REPLICAS total replicas (Ready: ${READY:-0})"
fi
echo ""
echo "📦 Pod Details:"
# 2. List Individual Pods
kubectl get pods -n $NAMESPACE -l $APP_LABEL -o custom-columns="NAME:.metadata.name,STATUS:.status.phase,AGE:.metadata.creationTimestamp,NODE:.spec.nodeName" --no-headers 2>/dev/null || echo "No active runner pods found."
if [ "$REPLICAS" -eq "0" ] && [ -z "$(kubectl get pods -n $NAMESPACE -l $APP_LABEL --no-headers 2>/dev/null)" ]; then
echo "✅ Scale-to-Zero: Success (0 active runners)"
fi
echo "--------------------------------------------------------"