分析 k8s 容器 内存 CPU使用率
安装metrics-server
参考github https://github.com/kubernetes-sigs/metrics-server
如下命令安装
mkdir metrics-server
wget https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml
kubectl apply -f components.yaml
使用如下的命令分析所有容器
kubectl get po -o wide -A |awk '{if ($3 !~ "0|READY") {print $1,$2}}'|while read i;do pod=$(echo $i|awk '{print $2}');ns=$(echo $i|awk '{print $1}'); kubectl top pod $pod -n $ns|grep -v NAME|awk '{printf ("%60s%20s%20s\n",$1,$2,$3)}';done
标签:kubectl,使用率,server,metrics,awk,pod,k8s,CPU
From: https://www.cnblogs.com/faberbeta/p/16869712.html