From 5dafcfec0e647022f853cfd225ab4bb4aac5745f Mon Sep 17 00:00:00 2001 From: "s0wlz (Matthias Puchstein)" Date: Wed, 22 Apr 2026 01:04:42 +0200 Subject: [PATCH] k8s-widget: add k8s-status.sh --- .../scripts/executable_k8s-status.sh | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100755 dot_config/quickshell/scripts/executable_k8s-status.sh diff --git a/dot_config/quickshell/scripts/executable_k8s-status.sh b/dot_config/quickshell/scripts/executable_k8s-status.sh new file mode 100755 index 0000000..183a952 --- /dev/null +++ b/dot_config/quickshell/scripts/executable_k8s-status.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +# Outputs pod ready status for a namespace as JSON. +# Usage: k8s-status.sh +set -euo pipefail + +NS="${1:-tenant-5}" + +pods_json=$(kubectl get pods -n "$NS" -o json 2>/dev/null) || exit 0 + +echo "$pods_json" | jq -c ' + [.items[] | { + app: (.metadata.labels["app.kubernetes.io/instance"] // .metadata.name), + ready: ((.status.conditions // []) + | map(select(.type == "Ready")) + | if length > 0 then .[0].status == "True" else false end) + }] as $pods | + { + pods: $pods, + readyCount: ($pods | map(select(.ready)) | length), + totalCount: ($pods | length) + } +'