Skip to content

Instantly share code, notes, and snippets.

@davidxia
Last active February 8, 2019 18:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidxia/550fa301258daacd00730f55bf324c65 to your computer and use it in GitHub Desktop.
Save davidxia/550fa301258daacd00730f55bf324c65 to your computer and use it in GitHub Desktop.
kubectl tricks
# total memory usage (Mi mebibytes 1,048,576 bytes) of all pods in a namespace
kubectl -n $namespace top pod | \
tail -n +2 | \
awk '{print $3}' | \
tr -d 'Mi' | \
awk '{s+=$1} END {print s}'
# total CPU usage (millicores) of all pods in a namespace
kubectl -n $namespace top pod | \
tail -n +2 | \
awk '{print $2}' | \
tr -d 'm' | \
awk '{s+=$1} END {print s}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment