Bash public

Kubernetes Node Status

Share this script safely, inspect its metadata, and copy the exact command you need.

Dashboard

Ready to run

One-liner

Copy the command, then review before execution.
curl -fsSL https://runny.sh/r/WQPXEDXFXC58 | bash

Current version: 1.1 · Updated by Godmode · 2026-09-07 02:38:59.354

At a glance

Script metadata

Slug
WQPXEDXFXC58
Fetches
0
Size
1778 B · 76 lines
Expires
never
Last fetch
Created
2026-09-07 00:35:59.916
Description
Ready vs NotReady nodes from kubectl

Readable before runnable

Preview

#!/usr/bin/env bash
# Kubernetes node status
# Read-only: kubectl get nodes. Warns on SchedulingDisabled, critical on NotReady.
# Exit 0 if all Ready, 1 if degraded or kubectl missing, 2 if a node is NotReady.
# Hosted on Runny.sh. Review the script page before you run it.

set -u

status=0
note() { printf '%s\n' "$*"; }
bump() {
  case $1 in
    crit) status=2 ;;
    warn) [ "$status" -lt 1 ] && status=1 ;;
  esac
}

note "=== Kubernetes nodes ==="
if ! command -v kubectl >/dev/null 2>&1; then
  note "kubectl:  not found in PATH"
  note "Result: WARNING"
  exit 1
fi

note "Context:  $(kubectl config current-context 2>/dev/null || printf unknown)"
note ""
if ! nodes=$(kubectl get nodes --no-headers 2>&1); then
  note "$nodes"
  note "          CRITICAL: kubectl get nodes failed"
  note "Result: CRITICAL"
  exit 2
fi

if [ -z "${nodes}" ]; then
  note "No nodes returned"
  bump warn
else
  note "NAME                           STATUS"
  printf '%s\n' "$nodes" | while IFS= read -r row; do
    note "  ${row}"
  done
  note ""
  while IFS= read -r row; do
    [ -z "$row" ] && continue
    cond=$(printf '%s\n' "$row" | awk '{print $2}')
    name=$(printf '%s\n' "$row" | awk '{print $1}')
    case "$cond" in
      Ready)
        note "${name}: OK"
        ;;
      Ready,SchedulingDisabled|Ready,SchedulingDisabled,*)
        note "${name}: WARNING (Ready but SchedulingDisabled)"
        bump warn
        ;;
      *NotReady*)
        note "${name}: CRITICAL (NotReady)"
        bump crit
        ;;
      *)
        note "${name}: WARNING (status ${cond})"
        bump warn
        ;;
    esac
  done <<EOF
${nodes}
EOF
fi
note ""

case $status in
  0) note "Result: HEALTHY" ;;
  1) note "Result: WARNING" ;;
  *) note "Result: CRITICAL" ;;
esac
exit "$status"

Raw endpointhttps://runny.sh/r/WQPXEDXFXC58

See something unsafe?

Report this script

Tell us why it should come down. Anyone can also report a URL at /abuse.

Restore revision