0

当我在 cli 上键入此命令时:

kubectl get --raw /apis/metrics.k8s.io/v1beta1/namespaces/<NAMESPACE>/pods/<POD_NAME> | jq

我可以得到如下结果:

{
  "kind": "PodMetrics",
  "apiVersion": "metrics.k8s.io/v1beta1",
  "metadata": {
    "name": "busybox",
    "namespace": "default",
    "selfLink": "/apis/metrics.k8s.io/v1beta1/namespaces/default/pods/busybox",
    "creationTimestamp": "2019-12-10T18:23:20Z"
  },
  "timestamp": "2019-12-10T18:23:12Z",
  "window": "30s",
  "containers": [
    {
      "name": "busybox",
      "usage": {
        "cpu": "0",
        "memory": "364Ki"
      }
    }
  ]
}

那个“窗口”项目是什么意思?我真的很想知道它到底是什么。

4

1 回答 1

0

根据k8s源代码

// PodMetrics sets resource usage metrics of a pod.
type PodMetrics struct {
    metav1.TypeMeta
    metav1.ObjectMeta

    // The following fields define time interval from which metrics were
    // collected from the interval [Timestamp-Window, Timestamp].
    Timestamp metav1.Time
    Window    metav1.Duration

    // Metrics for all containers are collected within the same time window.
    Containers []ContainerMetrics
}

您最有可能对此评论感兴趣:

以下字段定义从间隔 [Timestamp-Window, Timestamp] 收集指标的时间间隔。

因此,使用结果是在此窗口/时间间隔内收集的平均数据。

于 2021-06-18T11:38:32.333 回答