k8s 集群通过应用进程PID查看pod的名称—— 筑梦之路

比如当前系统占cpu资源最高的进程为:

3353978

1. 根据PID查看对应Pod的UID

cat /proc/3353978/mountinfo |grep "etc-hosts"

cat /proc/3353978/mountinfo |grep "etc-hosts" | awk -F / {'print $4'}

2. 根据UID再查询pod name

crictl ps -o json | jq  '.[][].labels | select (.["io.kubernetes.pod.uid"] == "4844bba8-1155-45f2-9538-66670179407c") | .["io.kubernetes.pod.name"]'|uniq

猜你喜欢

转载自blog.csdn.net/qq_34777982/article/details/130800268