|
| 1 | +--- |
| 2 | +title: 节点指标数据 |
| 3 | +content_type: reference |
| 4 | +weight: 50 |
| 5 | +description: >- |
| 6 | + 访问 kubelet 所观测到的节点、卷、Pod 和容器级别指标的机制。 |
| 7 | +--- |
| 8 | +<!-- |
| 9 | +title: Node metrics data |
| 10 | +content_type: reference |
| 11 | +weight: 50 |
| 12 | +description: >- |
| 13 | + Mechanisms for accessing metrics at node, volume, pod and container level, |
| 14 | + as seen by the kubelet. |
| 15 | +--> |
| 16 | + |
| 17 | +<!-- |
| 18 | +The [kubelet](/docs/reference/command-line-tools-reference/kubelet/) |
| 19 | +gathers metric statistics at the node, volume, pod and container level, |
| 20 | +and emits this information in the |
| 21 | +[Summary API](http://github.com/kubernetes/kubernetes/blob/7d309e0104fedb57280b261e5677d919cb2a0e2d/staging/src/k8s.io/kubelet/pkg/apis/stats/v1alpha1/types.go). |
| 22 | +--> |
| 23 | +[kubelet](/zh-cn/docs/reference/command-line-tools-reference/kubelet/) |
| 24 | +在节点、卷、Pod 和容器级别收集统计信息,并在 |
| 25 | +[概要 API](http://github.com/kubernetes/kubernetes/blob/7d309e0104fedb57280b261e5677d919cb2a0e2d/staging/src/k8s.io/kubelet/pkg/apis/stats/v1alpha1/types.go) |
| 26 | +中输出这些信息。 |
| 27 | + |
| 28 | +<!-- |
| 29 | +You can send a proxied request to the stats summary API via the |
| 30 | +Kubernetes API server. |
| 31 | +
|
| 32 | +Here is an example of a Summary API request for a node named `minikube`: |
| 33 | +--> |
| 34 | +你可以通过 Kubernetes API 服务器将代理的请求发送到 stats 概要 API。 |
| 35 | + |
| 36 | +下面是一个名为 `minikube` 的节点的概要 API 请求示例: |
| 37 | + |
| 38 | +```shell |
| 39 | +kubectl get --raw "/api/v1/nodes/minikube/proxy/stats/summary" |
| 40 | +``` |
| 41 | + |
| 42 | +<!-- |
| 43 | +Here is the same API call using `curl`: |
| 44 | +
|
| 45 | +# You need to run "kubectl proxy" first |
| 46 | +# Change 8080 to the port that "kubectl proxy" assigns |
| 47 | +--> |
| 48 | +下面是使用 `curl` 所执行的相同 API 调用: |
| 49 | + |
| 50 | +```shell |
| 51 | +# 你需要先运行 "kubectl proxy" |
| 52 | +# 更改 8080 为 "kubectl proxy" 指派的端口 |
| 53 | +curl http://localhost:8080/api/v1/nodes/minikube/proxy/stats/summary |
| 54 | +``` |
| 55 | + |
| 56 | +{{< note >}} |
| 57 | +<!-- |
| 58 | +Beginning with `metrics-server` 0.6.x, `metrics-server` queries the `/metrics/resource` |
| 59 | +kubelet endpoint, and not `/stats/summary`. |
| 60 | +--> |
| 61 | +从 `metrics-server` 0.6.x 开始,`metrics-server` 查询 `/metrics/resource` kubelet 端点, |
| 62 | +不查询 `/stats/summary`。 |
| 63 | +{{< /note >}} |
| 64 | + |
| 65 | +<!-- |
| 66 | +## Summary metrics API source {#summary-api-source} |
| 67 | +
|
| 68 | +By default, Kubernetes fetches node summary metrics data using an embedded |
| 69 | +[cAdvisor](http://github.com/google/cadvisor) that runs within the kubelet. |
| 70 | +
|
| 71 | +## Summary API data via CRI {#pod-and-container-stats-from-cri} |
| 72 | +--> |
| 73 | +## 概要指标 API 源 {#summary-api-source} |
| 74 | + |
| 75 | +默认情况下,Kubernetes 使用 kubelet 内运行的嵌入式 [cAdvisor](http://github.com/google/cadvisor) |
| 76 | +获取节点概要指标数据。 |
| 77 | + |
| 78 | +## 通过 CRI 获得概要 API 数据 {#pod-and-container-stats-from-cri} |
| 79 | + |
| 80 | +{{< feature-state for_k8s_version="v1.23" state="alpha" >}} |
| 81 | + |
| 82 | +<!-- |
| 83 | +If you enable the `PodAndContainerStatsFromCRI` |
| 84 | +[feature gate](/docs/reference/command-line-tools-reference/feature-gates/) in your |
| 85 | +cluster, and you use a container runtime that supports statistics access via |
| 86 | +{{< glossary_tooltip term_id="cri" text="Container Runtime Interface">}} (CRI), then |
| 87 | +the kubelet fetches Pod- and container-level metric data using CRI, and not via cAdvisor. |
| 88 | +--> |
| 89 | +如果你在自己的集群中启用 `PodAndContainerStatsFromCRI` |
| 90 | +[特性门控](/zh-cn/docs/reference/command-line-tools-reference/feature-gates/), |
| 91 | +且你通过{{< glossary_tooltip term_id="cri" text="容器运行时接口">}} (CRI) 使用支持统计访问的容器运行时, |
| 92 | +则 kubelet 将使用 CRI 而不是 cAdvisor 来获取 Pod 和容器级别的指标数据。 |
| 93 | + |
| 94 | +## {{% heading "whatsnext" %}} |
| 95 | + |
| 96 | +<!-- |
| 97 | +The task pages for [Troubleshooting Clusters](/docs/tasks/debug/debug-cluster/) discuss |
| 98 | +how to use a metrics pipeline that rely on these data. |
| 99 | +--> |
| 100 | +[集群故障排查](/zh-cn/docs/tasks/debug/debug-cluster/)任务页面讨论了如何使用依赖这些数据的指标管道。 |
0 commit comments