k8s 度量服务器 api 结果中 'window' 的含义是什么

what is the meaning of 'window' in results from k8s metric server api

当我在 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"
      }
    }
  ]
}

“window”项是什么意思? 我真的很想知道它到底是什么。

根据 k8s source code:

// 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
}

您很可能对此评论感兴趣:

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

因此使用结果是在此 window/interval 上收集的平均数据。