Created
December 10, 2020 10:12
-
-
Save zackijack/eb5ef5eea1fe28d26ded991e1888ccf2 to your computer and use it in GitHub Desktop.
kubectl + jq
This file contains hidden or 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
# Getting the list of nodes and their memory size | |
kubectl get nodes -o json | \ | |
jq -r '.items | sort_by(.status.capacity.memory)[] | [.metadata.name,.status.capacity.memory] | @tsv' | |
# Getting the list of nodes and the number of pods running on them | |
kubectl get pods -o json --all-namespaces | \ | |
jq '.items | group_by(.spec.nodeName) | map({"nodeName": .[0].spec.nodeName, "count": length}) | sort_by(.count)' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment