如何在Kubernetes中获取容器的磁盘使用情况(不使用docker命令)? [英] How to get container's disk usage in Kubernetes (without docker command)?
问题描述
我有一个Kubernetes集群,想知道我的容器使用多少磁盘空间.我说的不是挂载的卷.
I have a Kubernetes Cluster and want to know how much disk space my containers use. I am not talking about mounted Volumes.
我可以通过使用docker system df -v
或docker ps -s
之类的docker命令来获取此信息,但是我不想连接到每个工作节点.
I can get this information by using docker commands like docker system df -v
or docker ps -s
, but I don't want to connect to every single worker node.
是否可以通过kubectl
获取容器的磁盘使用率,还是可以从kubelet指标中获取此信息?
Is there a way to get a container's disk usage via kubectl
or are there kubelet metrics where I can get this information from?
推荐答案
是的,但当前不适用于kubectl,您可以从 cAdvisor 指标>端点.
Yes, but currently not with kubectl, you can get metrics from the kubelet, either through the kube-apiserver (proxied) or directly calling the kubelet HTTP(s) server endpoint (default port 10250
). Disk metrics are generally available on the /stats/summary
endpoint and you can also find some cAdvisor metrics on the /metrics/cavisor
endpoint.
例如,要获取通过不记名令牌可以是绑定到ClusterRole的服务帐户令牌,如下所示:
The Bearer token can be a service account token tied to a ClusterRole like this:
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
annotations:
name: myrole
rules:
- apiGroups:
- ""
resources:
- nodes
- nodes/proxy
verbs:
- get
- list
- watch
- nonResourceURLs:
- /metrics
- /api/*
verbs:
- get
这篇关于如何在Kubernetes中获取容器的磁盘使用情况(不使用docker命令)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!