shell - 根据k8s节点输出pod资源使用情况

2021-09-01
#!/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,$2,$1}' >> ${temp_file}
done

cat ${temp_file} | sort -nk1

标题:shell - 根据k8s节点输出pod资源使用情况
地址:https://blog.nijianqiang.xyz:8443/articles/2021/09/01/1630473716766.html