Last active
November 1, 2023 04:34
-
-
Save zulhfreelancer/7ad6b6ca02382d909047120ba2371058 to your computer and use it in GitHub Desktop.
Kubectl get nodes, sort by types (control-planes & workers)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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