Get kubectl top pods in .csv format
Feb 3, 2022
Hi, this is a short post, as a friendly reminder for me.
This command gets all the pods in all namespaces in a cluster, sorted by memory, and as an output a file .csv “resources-pod.csv” you can change it.
kubectl top pods -A - sort-by=memory | awk '{print $1 ", " $2 ", "$3–1"," $4–2}' | tee resources-pod.csv
More scripts: https://github.com/GloriaPG/kubernetes-scripts