The k8s cluster checks the name of the pod through the application process PID - the road to dream building

For example, the process with the highest CPU resources in the current system is:

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

Guess you like

Origin blog.csdn.net/qq_34777982/article/details/130800268