kubernetes - 如何确定正在运行的 Kubernetes pod 的当前临时存储使用情况?

标签 kubernetes kubectl disk-access

我怎么知道 kubectl多少钱ephemeral storage pod 正在使用?

在 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 .

最佳答案

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

进入你的 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 .

    关于kubernetes - 如何确定正在运行的 Kubernetes pod 的当前临时存储使用情况?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53217227/

    相关文章:

    docker - [HTCONDOR][kubernetes/k8s] : Unable to start minicondor image within k8s - condor_master not working

    mysql - 如何在 k8s 中连接到我的 mysql pod 或 mysql 节点?

    Kubernetes CI 应用程序/Pod 中可变数量的容器

    kubernetes - 自动设置具有多个Pod的kubernetes集群

    kubernetes - 如何在 k8s 服务 yaml 中启用端口转发

    MySQL 记录磁盘使用计算 |我对吗?

    kubernetes - 如何通过 API 推出重启部署?

    azure - 如何使用多个 azure kubernetes 上下文

    linux - 为什么 du 命令在文件夹和父文件夹中显示不同的总数