如何将 /kubepods/besteffort/pod<uuid> 解析为 pod 名称?
How do I resolve /kubepods/besteffort/pod<uuid> to a pod name?
我正在查看 Grafana 仪表板中的 Prometheus 指标,我对一些基于我不熟悉的 ID 显示指标的面板感到困惑。我假设 /kubepods/burstable/pod99b2fe2a-104d-11e8-baa7-06145aa73a4c
指向一个 pod,并且我假设 /kubepods/burstable/pod99b2fe2a-104d-11e8-baa7-06145aa73a4c/<another-long-string>
解析为 pod 中的一个容器,但是我如何将此 ID 解析为 pod 名称和一个容器,即我该怎么做将此 ID 映射到我在 运行 kubectl get pods
?
时看到的 pod 名称
我已经尝试了 运行ning kubectl describe pods --all-namespaces | grep "99b2fe2a-104d-11e8-baa7-06145aa73a4c"
,但没有任何结果。
此外,/kubepods
中还有几个子路径,如/kubepods/burstable
和/kubepods/besteffort
。这些是什么意思,给定的 pod 如何落入这些子路径中的一个或另一个?
最后,我在哪里可以了解更多有关管理 /kubepods
的内容?
普罗米修斯查询:
sum (container_memory_working_set_bytes{id!="/",kubernetes_io_hostname=~"^$Node$"}) by (id)
/
感谢阅读。
埃里克
好的,既然我已经做了一些深入研究,我将尝试回答我自己的所有 3 个问题。我希望这对其他人有帮助。
如何将此 ID 映射到我在 运行 kubectl get pods?
时看到的 pod 名称
鉴于以下内容,/kubepods/burstable/pod99b2fe2a-104d-11e8-baa7-06145aa73a4c
,最后一位是 pod UID,可以通过查看 pod 清单上的 metadata.uid
属性 来解析为 pod:
kubectl get pod --all-namespaces -o json | jq '.items[] | select(.metadata.uid == "99b2fe2a-104d-11e8-baa7-06145aa73a4c")'
将 UID 解析为 pod 后,我们可以通过将第二个 UID(容器 ID)与 pod 清单中的 .status.containerStatuses[].containerID
匹配来将其解析为容器:
~$ kubectl get pod my-pod-6f47444666-4nmbr -o json | jq '.status.containerStatuses[] | select(.containerID == "docker://5339636e84de619d65e1f1bd278c5007904e4993bc3972df8628668be6a1f2d6")'
此外,/kubepods中还有几个子路径,比如/kubepods/burstable和/kubepods/besteffort。这些是什么意思,给定的 pod 如何落入这些子路径中的一个或另一个?
Burstable、BestEffort 和 Guaranteed 是 Kubernetes 根据 pod 规范中的内存和 cpu 分配分配给 pods 的服务质量 (QoS) 类。有关 QoS 类 的更多信息,请参见此处 https://kubernetes.io/docs/tasks/configure-pod-container/quality-service-pod/。
引用:
For a Pod to be given a QoS class of Guaranteed:
Every Container in the Pod must have a memory limit and a memory request, and they must be the same.
Every Container in the Pod must have a cpu limit and a cpu request, and they must be the same.
A Pod is given a QoS class of Burstable if:
The Pod does not meet the criteria for QoS class Guaranteed.
At least one Container in the Pod has a memory or cpu request.
For a Pod to be given a QoS class of BestEffort, the Containers in the
Pod must not have any memory or cpu limits or requests.
最后,我在哪里可以了解更多关于管理 /kubepods 的内容?
/kubepods/burstable
、/kubepods/besteffort
和 /kubepods/guaranteed
都是 cgroups 层次结构的一部分,位于 /sys/fs/cgroup 目录中。 Cgroups 管理容器进程的资源使用,例如 CPU、内存、磁盘 I/O 和网络。每个资源在 cgroup 层次结构文件系统中都有自己的位置,每个资源 sub-directory 是 /kubepods 子目录。有关 cgroups 和 Docker 容器的更多信息,请点击此处:https://docs.docker.com/config/containers/runmetrics/#control-groups
我正在查看 Grafana 仪表板中的 Prometheus 指标,我对一些基于我不熟悉的 ID 显示指标的面板感到困惑。我假设 /kubepods/burstable/pod99b2fe2a-104d-11e8-baa7-06145aa73a4c
指向一个 pod,并且我假设 /kubepods/burstable/pod99b2fe2a-104d-11e8-baa7-06145aa73a4c/<another-long-string>
解析为 pod 中的一个容器,但是我如何将此 ID 解析为 pod 名称和一个容器,即我该怎么做将此 ID 映射到我在 运行 kubectl get pods
?
我已经尝试了 运行ning kubectl describe pods --all-namespaces | grep "99b2fe2a-104d-11e8-baa7-06145aa73a4c"
,但没有任何结果。
此外,/kubepods
中还有几个子路径,如/kubepods/burstable
和/kubepods/besteffort
。这些是什么意思,给定的 pod 如何落入这些子路径中的一个或另一个?
最后,我在哪里可以了解更多有关管理 /kubepods
的内容?
普罗米修斯查询:
sum (container_memory_working_set_bytes{id!="/",kubernetes_io_hostname=~"^$Node$"}) by (id)
/
感谢阅读。
埃里克
好的,既然我已经做了一些深入研究,我将尝试回答我自己的所有 3 个问题。我希望这对其他人有帮助。
如何将此 ID 映射到我在 运行 kubectl get pods?
时看到的 pod 名称鉴于以下内容,/kubepods/burstable/pod99b2fe2a-104d-11e8-baa7-06145aa73a4c
,最后一位是 pod UID,可以通过查看 pod 清单上的 metadata.uid
属性 来解析为 pod:
kubectl get pod --all-namespaces -o json | jq '.items[] | select(.metadata.uid == "99b2fe2a-104d-11e8-baa7-06145aa73a4c")'
将 UID 解析为 pod 后,我们可以通过将第二个 UID(容器 ID)与 pod 清单中的 .status.containerStatuses[].containerID
匹配来将其解析为容器:
~$ kubectl get pod my-pod-6f47444666-4nmbr -o json | jq '.status.containerStatuses[] | select(.containerID == "docker://5339636e84de619d65e1f1bd278c5007904e4993bc3972df8628668be6a1f2d6")'
此外,/kubepods中还有几个子路径,比如/kubepods/burstable和/kubepods/besteffort。这些是什么意思,给定的 pod 如何落入这些子路径中的一个或另一个?
Burstable、BestEffort 和 Guaranteed 是 Kubernetes 根据 pod 规范中的内存和 cpu 分配分配给 pods 的服务质量 (QoS) 类。有关 QoS 类 的更多信息,请参见此处 https://kubernetes.io/docs/tasks/configure-pod-container/quality-service-pod/。
引用:
For a Pod to be given a QoS class of Guaranteed:
Every Container in the Pod must have a memory limit and a memory request, and they must be the same.
Every Container in the Pod must have a cpu limit and a cpu request, and they must be the same.
A Pod is given a QoS class of Burstable if:
The Pod does not meet the criteria for QoS class Guaranteed.
At least one Container in the Pod has a memory or cpu request.
For a Pod to be given a QoS class of BestEffort, the Containers in the Pod must not have any memory or cpu limits or requests.
最后,我在哪里可以了解更多关于管理 /kubepods 的内容?
/kubepods/burstable
、/kubepods/besteffort
和 /kubepods/guaranteed
都是 cgroups 层次结构的一部分,位于 /sys/fs/cgroup 目录中。 Cgroups 管理容器进程的资源使用,例如 CPU、内存、磁盘 I/O 和网络。每个资源在 cgroup 层次结构文件系统中都有自己的位置,每个资源 sub-directory 是 /kubepods 子目录。有关 cgroups 和 Docker 容器的更多信息,请点击此处:https://docs.docker.com/config/containers/runmetrics/#control-groups