diff --git a/k8s/debug-redis.sh b/k8s/debug-redis.sh index b625fb6b..1fa5886f 100755 --- a/k8s/debug-redis.sh +++ b/k8s/debug-redis.sh @@ -4,10 +4,11 @@ set -e NAMESPACE="${1:-towerops}" -POD_NAME=$(kubectl get pods -n "$NAMESPACE" -l app=towerops -o jsonpath='{.items[0].metadata.name}' 2>/dev/null) +# Get a running pod (not terminating) +POD_NAME=$(kubectl get pods -n "$NAMESPACE" -l app=towerops --field-selector=status.phase=Running -o jsonpath='{.items[0].metadata.name}' 2>/dev/null) if [ -z "$POD_NAME" ]; then - echo "Error: No towerops pods found in namespace $NAMESPACE" + echo "Error: No running towerops pods found in namespace $NAMESPACE" exit 1 fi