他们是 Pod 的.metadata.uid;可以通过使用您最喜欢的机制来将它们映射回来,以查询所有 pod 并在其 .metadata.uid 上进行过滤,如果您有太多 Pod 以使 -A 不可行,则可以选择限制在该节点上调度的那些 pod
for d in /var/lib/kubelet/pods/*; do
p_u=$(basename "$d")
kubectl get po -A -o json | \
jq --arg pod_uuid "$p_u" -r '.items[]
| select(.metadata.uid == $pod_uuid)
| "uuid \($pod_uuid) is \(.metadata.name)"'
done
我确定有一个 -o jsonpath= 或 -o gotemplate= 表单可以消除对 jq 的需要,但是在文本区域中输入会做更多的工作
关于您的 crictl 问题,我现在无法访问我的 containerd 集群,但是基于 docker 的人用 io.kubernetes.pod.uid 标记本地容器,所以我猜 containerd 做了类似的事情:
"Labels": {
"annotation.io.kubernetes.container.hash": "e44bee94",
"annotation.io.kubernetes.container.restartCount": "4",
"annotation.io.kubernetes.container.terminationMessagePath": "/dev/termination-log",
"annotation.io.kubernetes.container.terminationMessagePolicy": "File",
"annotation.io.kubernetes.pod.terminationGracePeriod": "30",
"io.kubernetes.container.logpath": "/var/log/pods/kube-system_storage-provisioner_b4aa3b1c-62c1-4661-a302-4c06b305b7c0/storage-provisioner/4.log",
"io.kubernetes.container.name": "storage-provisioner",
"io.kubernetes.docker.type": "container",
"io.kubernetes.pod.name": "storage-provisioner",
"io.kubernetes.pod.namespace": "kube-system",
"io.kubernetes.pod.uid": "b4aa3b1c-62c1-4661-a302-4c06b305b7c0",
"io.kubernetes.sandbox.id": "3950ec60121fd13116230cad388a4c6c4e417c660b7da475436f9ad5c9cf6738"
}