简体   繁体   English

如何计算 kubernetes 节点上的磁盘使用率?

[英]how to calculate disk usage on a kubernetes node?

I have a service on my kubernetes cluster that generates massive assets to my machine's hard disk.我的 kubernetes 集群上有一项服务,可以为我的机器硬盘生成大量资产。 Some of that information could also be served statically by a different service in my system.其中一些信息也可以由我系统中的不同服务静态提供。 The save location is mapped to an actual folder on my disk.保存位置映射到我磁盘上的实际文件夹。

I already found that I can see some information about my "ephemral" storage capacity and allocatbility through kubectl describe node but the data doesn't align with what I see when I run df -h on my machine's terminal.我已经发现我可以通过kubectl describe node看到一些关于我的“临时”存储容量和可分配性的信息,但是数据与我在机器终端上运行df -h时看到的不一致。 on the node, I can see that I could allocate 147GB and on my terminal I can see that I could only allocate 98GB (this means we probably have some reserved space by Kubernetes in our deployments).在节点上,我可以看到我可以分配 147GB,而在我的终端上我可以看到我只能分配 98GB(这意味着我们在部署中可能有一些 Kubernetes 保留的空间)。 I would like my metrics to reflect the actual state of the hard drive.我希望我的指标能够反映硬盘驱动器的实际 state。

My Question:我的问题:
How do I check through Kubernetes's python package what's the status of the storage on my machine without mounting my root path into the relevant container ?如何检查 Kubernetes 的 python package 我的机器上的存储状态是什么而不将我的根路径安装到相关容器中 Is there an API to the metrics service that shows me the status of my machine's actual storage?指标服务是否有 API 向我显示我的机器的实际存储状态? I tried looking at the Python API and couldn't find it.我尝试查看Python API并找不到它。 What am I missing?我错过了什么?

Kubernetes does not track overall storage available. Kubernetes 不跟踪可用的整体存储空间。 It only knows things about emptyDir volumes and the filesystem backing those.它只知道 emptyDir 卷和支持这些卷的文件系统。 If you're using a hostPath mount (which it sounds like you are), that is outside of Kube's view of the world.如果您使用的是 hostPath 挂载(听起来像您),那么这超出了 Kube 的世界观。 You can use something like node_exporter to gather those statistics yourself.您可以使用 node_exporter 之类的工具自己收集这些统计信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM