shell - k8s节点维度查看pod资源使用情况

2021-07-05
#!/bin/bash
kubectl top node | grep -v NAME | sort -nk 5
echo -n "请输入node节点名"
read NODE

temp_file="/tmp/pod-resource"
cat /dev/null > ${temp_file}
kubectl get pod -o wide -A| grep ${NODE} | awk '{print $1,$2}' | while read line
do
    line=($line)
    namespace=${line[0]}
    pod=${line[1]}
    kubectl -n ${namespace} top pod ${pod} | grep -v NAME | awk '{print $3,$1}' >> ${temp_file}
done

cat ${temp_file} | sort -nk1

标题:shell - k8s节点维度查看pod资源使用情况
地址:https://blog.njqhome.com:8443/articles/2021/07/05/1625473313624.html