kubernetes - 如何将/kubepods/besteffort/pod<uuid> 解析为 pod 名称?

标签 kubernetes prometheus grafana

我正在 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 名称?

我已经尝试运行 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)

/Grafana Screenshot

感谢您的阅读。

埃里克

最佳答案

好的,现在我已经做了一些挖掘,我将尝试回答我自己的所有 3 个问题。我希望这对其他人有帮助。

如何将此 ID 映射到运行 kubectl get pods 时看到的 pod 名称?

鉴于以下内容,/kubepods/burstable/pod99b2fe2a-104d-11e8-baa7-06145aa73a4c,最后一位是 pod UID,可以通过查看解析为 pod Pod list 上的 >metadata.uid 属性:

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 匹配来将其解析为容器 list :

~$ 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 分配分配给 Pod 的服务质量 (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 层次结构文件系统中都有自己的位置,并且每个资源子目录中都有/kubepods 子目录。有关 cgroup 和 Docker 容器的更多信息:https://docs.docker.com/config/containers/runmetrics/#control-groups

关于kubernetes - 如何将/kubepods/besteffort/pod<uuid> 解析为 pod 名称?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49035724/

相关文章:

kubernetes - 将 Dockerfile 转换为 Kubernetes yaml

kubernetes - 自动配置不创建新的节点池

docker - 将用户添加到现有的Kubernetes集群

grafana - 如何使用 Grafana-cli 安装特定版本的插件?

kubernetes - kubernetes 上的多个 secret

kubernetes - 如何从 istio-envoy 容器中抓取数据

monitoring - 是否可以使用Prometheus监控Jboss或apache服务器?

grafana - 普罗米修斯查询以计算唯一标签值

java - Micrometer Timer.start/stop 和 Timer.record 之间的区别

kubernetes - CPU 资源单位 (millicore/millicpu) 是如何计算的?