Find Kubernetes pod info from cri-o host process id

Jbn1233
1 min readJul 14, 2020

--

On my worker node top command found that PID: 222906 using a lot of memory.

top sort by memory use

From this PID, I need to know the pod and namespace name.

Normal “crictl ps” output didn’t show mush information,So I need a simple script.

#!/bin/bashPIX=$(cat /proc/$1/mountinfo |grep hosts |awk -F / {'print $5'})
crictl ps --output json | jq '.[][] | select (.labels["io.kubernetes.pod.uid"] == "'$PIX'")'

get “io.kubernetes.pod.uid” from mountinfo and match it on “crictl ps — output json”.

./podinfo.sh 222906

This is all.

--

--

Jbn1233
Jbn1233

Written by Jbn1233

Very short and simple notes for CKA/SRE and may not works on your environment | jbn1233@gmail.com | Bangkok, Thailand |

No responses yet