如何确定正在运行的Kubernetes pod的当前短暂存储使用情况?

问题描述 投票:2回答:1

我如何告诉kubectl目前使用的pod有多少ephemeral storage

在Kubernetes pod规范中,我可以指定CPU,内存和临时存储的资源请求和限制:

resources:
  requests:
    memory: "60Mi"
    cpu: "70m"
    ephemeral-storage: "2Gi"
  limits:
    memory: "65Mi"
    cpu: "75m"
    ephemeral-storage: "4Gi"

但是,为了设置短暂存储的良好请求和限制,我需要知道这个值实际上对于正在运行的pod是什么,我无法弄清楚。我可以使用kubectl top pod获得CPU和内存使用量,但是,据我所知,ephemeral storage usage is only actually calculated when making an actual eviction decision

kubernetes kubectl diskusage
1个回答
1
投票

纯粹的原始方法是使用disk usage(du)Unix命令行。

shell进入你的pod:

$ kubectl exec -it <pod-id> sh

将dirs更改为临时存储的安装点(如果使用的是卷安装):

$ mount # check mount points if you'd like
$ cd /mnt/of/ephemeral
$ du .

如果您没有使用卷安装:

$ du .

您还可以使用其他工具来获取指标:

  • cAdvisor也嵌入到kubelet代码中,暴露在/stats/summary/metrics端点下。更多信息here。示例输出: $ curl -k -H 'Authorization: Bearer <Redacted>' \ https://node-hostname:10250/stats/summary { "node": { "nodeName": "node-hostname", "systemContainers": [ { "name": "kubelet", ... "volume": [ { "time": "2018-11-08T23:52:03Z", "availableBytes": 1969168384, "capacityBytes": 1969180672, "usedBytes": 12288, "inodesFree": 480748, "inodes": 480757, "inodesUsed": 9, "name": "kube-proxy-token-pprwb" } ], "ephemeral-storage": { "time": "2018-11-09T00:05:10Z", "availableBytes": 31057477632, "capacityBytes": 41567858688, "inodesFree": 4873887, "inodes": 5120000 } ... } 同理: $ curl -k -H 'Authorization: Bearer <Redacted>' \ https://node-hostname:10250/stats/summary # HELP apiserver_audit_event_total Counter of audit events generated and sent to the audit backend. # TYPE apiserver_audit_event_total counter apiserver_audit_event_total 0 # HELP apiserver_client_certificate_expiration_seconds Distribution of the remaining lifetime on the certificate used to authenticate a request. # TYPE apiserver_client_certificate_expiration_seconds histogram apiserver_client_certificate_expiration_seconds_bucket{le="0"} 0 apiserver_client_certificate_expiration_seconds_bucket{le="21600"} 0 apiserver_client_certificate_expiration_seconds_bucket{le="43200"} 0 ... 有关kubelet authentication/authorization的更多信息。
  • Prometheus

有关K8s指标here的更多信息。

© www.soinside.com 2019 - 2024. All rights reserved.