Skip to content

Instantly share code, notes, and snippets.

@zulhfreelancer
Last active November 1, 2023 04:34
Show Gist options
  • Save zulhfreelancer/7ad6b6ca02382d909047120ba2371058 to your computer and use it in GitHub Desktop.
Save zulhfreelancer/7ad6b6ca02382d909047120ba2371058 to your computer and use it in GitHub Desktop.
Kubectl get nodes, sort by types (control-planes & workers)
kubectl get nodes -o json | jq -r '.items | map({name: (.metadata.name + ""), type: (if (.metadata.labels | has("node-role.kubernetes.io/control-plane")) then "control-plane" else "worker" end), status: (.status.conditions[] | select(.type=="Ready") | if .status == "True" then "Ready" else "NotReady" end)}) | group_by(.type) | (["NODE_NAME", "NODE_TYPE", "NODE_STATUS"] | (., map(length*"-"))), (.[][] | [.name,.type,.status]) | @tsv' | column -ts $'\t'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment