From cde1ecce7eda73783a433d0fe245d460d5859a31 Mon Sep 17 00:00:00 2001 From: Todd Neal Date: Mon, 27 Feb 2023 08:11:57 -0600 Subject: [PATCH 1/2] document the PodAndContainerStatsFromCRI feature --- .../cri-pod-container-metrics.md | 40 +++++++++++++++++++ .../reference/instrumentation/node-metrics.md | 14 ++----- content/en/docs/reference/node/_index.md | 2 +- 3 files changed, 45 insertions(+), 11 deletions(-) create mode 100644 content/en/docs/reference/instrumentation/cri-pod-container-metrics.md diff --git a/content/en/docs/reference/instrumentation/cri-pod-container-metrics.md b/content/en/docs/reference/instrumentation/cri-pod-container-metrics.md new file mode 100644 index 0000000000..61b41b2e36 --- /dev/null +++ b/content/en/docs/reference/instrumentation/cri-pod-container-metrics.md @@ -0,0 +1,40 @@ +--- +title: CRI Pod & Container Metrics +content_type: reference +weight: 50 +description: >- + Collection of Pod & Container metrics via the CRI. +--- + + + + +{{< feature-state for_k8s_version="v1.23" state="alpha" >}} + +The [kubelet](/docs/reference/command-line-tools-reference/kubelet/) collects pod and +container metrics via [cAdvisor](https://github.com/google/cadvisor). As an alpha feature, +Kubernetes lets you configure the collection of pod and container +metrics via the {{< glossary_tooltip term_id="cri" text="Container Runtime Interface">}} (CRI). You +must enable the `PodAndContainerStatsFromCRI` [feature gate](/docs/reference/command-line-tools-reference/feature-gates/) and +use a compatible CRI implementation (containerd >= 1.6.0, CRI-O >= 1.23.0) to +use the CRI based collection mechanism. + + + +## CRI Pod & Container Metrics + +With `PodAndContainerStatsFromCRI` enabled, the kubelet will poll the underlying container +runtime for pod and container stats instead of inspecting the host system directly using cAdvisor. +The benefits of relying on the container runtime for this information as opposed to direct +collection with cAdvisor include: + +- Potential improved performance if the container runtime already collects this information + during normal operations. In this case, the data can be re-used instead of being aggregated + again by the kubelet. + +- It further decouples the kubelet and the container runtime allowing collection of metrics for + container runtimes that don't run processes directly on the host with kubelet where they are + observable by cAdvisor (e.g. VM based runtimes). + +Collecting this information from the CRI will become the default and the current cAdvisor collection +of metrics from the host will become fully deprecated in a future Kubernetes release. diff --git a/content/en/docs/reference/instrumentation/node-metrics.md b/content/en/docs/reference/instrumentation/node-metrics.md index ce5984e5ed..32eab955bd 100644 --- a/content/en/docs/reference/instrumentation/node-metrics.md +++ b/content/en/docs/reference/instrumentation/node-metrics.md @@ -37,17 +37,11 @@ kubelet endpoint, and not `/stats/summary`. ## Summary metrics API source {#summary-api-source} By default, Kubernetes fetches node summary metrics data using an embedded -[cAdvisor](https://github.com/google/cadvisor) that runs within the kubelet. - -## Summary API data via CRI {#pod-and-container-stats-from-cri} - -{{< feature-state for_k8s_version="v1.23" state="alpha" >}} - -If you enable the `PodAndContainerStatsFromCRI` -[feature gate](/docs/reference/command-line-tools-reference/feature-gates/) in your -cluster, and you use a container runtime that supports statistics access via +[cAdvisor](https://github.com/google/cadvisor) that runs within the kubelet. If you +enable the `PodAndContainerStatsFromCRI` [feature gate](/docs/reference/command-line-tools-reference/feature-gates/) +in your cluster, and you use a container runtime that supports statistics access via {{< glossary_tooltip term_id="cri" text="Container Runtime Interface">}} (CRI), then -the kubelet fetches Pod- and container-level metric data using CRI, and not via cAdvisor. +the kubelet [fetches Pod- and container-level metric data using CRI](/docs/reference/instrumentation/cri-pod-container-metrics), and not via cAdvisor. ## {{% heading "whatsnext" %}} diff --git a/content/en/docs/reference/node/_index.md b/content/en/docs/reference/node/_index.md index 9d015e7e3c..13363202a5 100644 --- a/content/en/docs/reference/node/_index.md +++ b/content/en/docs/reference/node/_index.md @@ -14,4 +14,4 @@ Kubernetes documentation, including: * [Node Metrics Data](/docs/reference/instrumentation/node-metrics). - +* [CRI Pod & Container Metrics](/docs/reference/instrumentation/cri-pod-container-metrics). \ No newline at end of file From 99721e51b5146972be0ec19958755a277e9c6e28 Mon Sep 17 00:00:00 2001 From: Todd Neal Date: Mon, 27 Feb 2023 10:11:52 -0600 Subject: [PATCH 2/2] pr comments --- .../instrumentation/cri-pod-container-metrics.md | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/content/en/docs/reference/instrumentation/cri-pod-container-metrics.md b/content/en/docs/reference/instrumentation/cri-pod-container-metrics.md index 61b41b2e36..c526d4b20e 100644 --- a/content/en/docs/reference/instrumentation/cri-pod-container-metrics.md +++ b/content/en/docs/reference/instrumentation/cri-pod-container-metrics.md @@ -23,7 +23,7 @@ use the CRI based collection mechanism. ## CRI Pod & Container Metrics -With `PodAndContainerStatsFromCRI` enabled, the kubelet will poll the underlying container +With `PodAndContainerStatsFromCRI` enabled, the kubelet polls the underlying container runtime for pod and container stats instead of inspecting the host system directly using cAdvisor. The benefits of relying on the container runtime for this information as opposed to direct collection with cAdvisor include: @@ -34,7 +34,5 @@ collection with cAdvisor include: - It further decouples the kubelet and the container runtime allowing collection of metrics for container runtimes that don't run processes directly on the host with kubelet where they are - observable by cAdvisor (e.g. VM based runtimes). - -Collecting this information from the CRI will become the default and the current cAdvisor collection -of metrics from the host will become fully deprecated in a future Kubernetes release. + observable by cAdvisor (for example: container runtimes that use virtualization). + \ No newline at end of file