|
| 1 | +--- |
| 2 | +title: CRI Pod 和容器指标 |
| 3 | +content_type: reference |
| 4 | +weight: 50 |
| 5 | +description: >- |
| 6 | + 通过 CRI 收集 Pod 和容器指标 |
| 7 | +--- |
| 8 | +<!-- |
| 9 | +title: CRI Pod & Container Metrics |
| 10 | +content_type: reference |
| 11 | +weight: 50 |
| 12 | +description: >- |
| 13 | + Collection of Pod & Container metrics via the CRI. |
| 14 | +--> |
| 15 | + |
| 16 | +<!-- overview --> |
| 17 | + |
| 18 | +{{< feature-state for_k8s_version="v1.23" state="alpha" >}} |
| 19 | +<!-- |
| 20 | +The [kubelet](/docs/reference/command-line-tools-reference/kubelet/) collects pod and |
| 21 | +container metrics via [cAdvisor](https://github.com/google/cadvisor). As an alpha feature, |
| 22 | +Kubernetes lets you configure the collection of pod and container |
| 23 | +metrics via the {{< glossary_tooltip term_id="cri" text="Container Runtime Interface">}} (CRI). You |
| 24 | +must enable the `PodAndContainerStatsFromCRI` [feature gate](/docs/reference/command-line-tools-reference/feature-gates/) and |
| 25 | +use a compatible CRI implementation (containerd >= 1.6.0, CRI-O >= 1.23.0) to |
| 26 | +use the CRI based collection mechanism. |
| 27 | +--> |
| 28 | +[kubelet](/zh-cn/docs/reference/command-line-tools-reference/kubelet/) 通过 |
| 29 | +[cAdvisor](https://github.com/google/cadvisor) 收集 Pod 和容器指标。作为一个 Alpha 特性, |
| 30 | +Kubernetes 允许你通过{{< glossary_tooltip term_id="cri" text="容器运行时接口">}}(CRI) |
| 31 | +配置收集 Pod 和容器指标。要使用基于 CRI 的收集机制,你必须启用 `PodAndContainerStatsFromCRI` |
| 32 | +[特性门控](/zh-cn/docs/reference/command-line-tools-reference/feature-gates/) |
| 33 | +并使用兼容的 CRI 实现(containerd >= 1.6.0, CRI-O >= 1.23.0)。 |
| 34 | + |
| 35 | +<!-- body --> |
| 36 | + |
| 37 | +<!-- |
| 38 | +## CRI Pod & Container Metrics |
| 39 | +
|
| 40 | +With `PodAndContainerStatsFromCRI` enabled, the kubelet polls the underlying container |
| 41 | +runtime for pod and container stats instead of inspecting the host system directly using cAdvisor. |
| 42 | +The benefits of relying on the container runtime for this information as opposed to direct |
| 43 | +collection with cAdvisor include: |
| 44 | +--> |
| 45 | +## CRI Pod 和容器指标 {#cri-pod-container-metrics} |
| 46 | + |
| 47 | +当启用 `PodAndContainerStatsFromCRI` 时,Kubelet 轮询底层容器运行时以获取 |
| 48 | +Pod 和容器统计信息,而不是直接使用 cAdvisor 检查主机系统。同直接使用 cAdvisor |
| 49 | +收集信息相比,依靠容器运行时获取这些信息的好处包括: |
| 50 | + |
| 51 | +<!-- |
| 52 | +- Potential improved performance if the container runtime already collects this information |
| 53 | + during normal operations. In this case, the data can be re-used instead of being aggregated |
| 54 | + again by the kubelet. |
| 55 | +--> |
| 56 | +- 潜在的性能改善,如果容器运行时在正常操作中已经收集了这些信息。 |
| 57 | + 在这种情况下,这些数据可以被重用,而不是由 Kubelet 再次进行聚合。 |
| 58 | + |
| 59 | +<!-- |
| 60 | +- It further decouples the kubelet and the container runtime allowing collection of metrics for |
| 61 | + container runtimes that don't run processes directly on the host with kubelet where they are |
| 62 | + observable by cAdvisor (for example: container runtimes that use virtualization). |
| 63 | +--> |
| 64 | +- 这种做法进一步解耦了 Kubelet 和容器运行时。 |
| 65 | + 对于使用 Kubelet 来在主机上运行进程的容器运行时,其行为可用 cAdvisor 观测; |
| 66 | + 对于其他运行时(例如,使用虚拟化的容器运行时)而言, |
| 67 | + 这种做法提供了允许收集容器运行时指标的可能性。 |
0 commit comments