<p>I was trying to debug some mount problems and the mount logs led me to paths under <code>/var/lib/kubelet/pods</code>, i.e</p>
<p><code>/var/lib/kubelet/pods/f6affad1-941d-4df1-a0b7-38e3f2ab99d5/volumes/kubernetes.io~nfs/my-pv-e0dbe341a6fe475c9029fb372e</code></p>
<p>How can I map the guid of the root directory under <code>pods</code> to the actual running pod or container?</p>
<p>(<code>f6affad1-941d-4df1-a0b7-38e3f2ab99d5</code> in the example above)</p>
<p>I don't see any correlation to the values returned by <code>kubectl</code> or <code>crictl</code>.</p>

Mugen
<p>They're the <code>.metadata.uid</code> of the Pod; one can map them back by using your favorite mechanism for querying all pods and filtering on its <code>.metadata.uid</code>, and optionally restricting to just those pods scheduled on that Node if you have a so many Pods as to make the <code>-A</code> infeasible</p>
<pre class="lang-sh prettyprint-override"><code>for d in /var/lib/kubelet/pods/*; do
  p_u=$(basename &quot;$d&quot;)
  kubectl get po -A -o json | \
    jq --arg pod_uuid &quot;$p_u&quot; -r '.items[] 
      | select(.metadata.uid == $pod_uuid) 
      | &quot;uuid \($pod_uuid) is \(.metadata.name)&quot;'
done
</code></pre>
<p>I'm sure there is a <code>-o jsonpath=</code> or <code>-o gotemplate=</code> form that removes the need for <code>jq</code> but that'd be a lot more work to type out in a textarea</p>
<p>with regard to your <code>crictl</code> question, I don't this second have access to my containerd cluster, but the docker based one labels the local containers with <code>io.kubernetes.pod.uid</code> so I would guess containerd does something similar:</p>
<pre class="lang-json prettyprint-override"><code>            &quot;Labels&quot;: {
                &quot;annotation.io.kubernetes.container.hash&quot;: &quot;e44bee94&quot;,
                &quot;annotation.io.kubernetes.container.restartCount&quot;: &quot;4&quot;,
                &quot;annotation.io.kubernetes.container.terminationMessagePath&quot;: &quot;/dev/termination-log&quot;,
                &quot;annotation.io.kubernetes.container.terminationMessagePolicy&quot;: &quot;File&quot;,
                &quot;annotation.io.kubernetes.pod.terminationGracePeriod&quot;: &quot;30&quot;,
                &quot;io.kubernetes.container.logpath&quot;: &quot;/var/log/pods/kube-system_storage-provisioner_b4aa3b1c-62c1-4661-a302-4c06b305b7c0/storage-provisioner/4.log&quot;,
                &quot;io.kubernetes.container.name&quot;: &quot;storage-provisioner&quot;,
                &quot;io.kubernetes.docker.type&quot;: &quot;container&quot;,
                &quot;io.kubernetes.pod.name&quot;: &quot;storage-provisioner&quot;,
                &quot;io.kubernetes.pod.namespace&quot;: &quot;kube-system&quot;,
                &quot;io.kubernetes.pod.uid&quot;: &quot;b4aa3b1c-62c1-4661-a302-4c06b305b7c0&quot;,
                &quot;io.kubernetes.sandbox.id&quot;: &quot;3950ec60121fd13116230cad388a4c6c4e417c660b7da475436f9ad5c9cf6738&quot;
            }
</code></pre>
