You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: keps/sig-node/2371-cri-pod-container-stats/README.md
+55-20
Original file line number
Diff line number
Diff line change
@@ -78,7 +78,7 @@ There are two main APIs that consumers use to gather stats about running contain
78
78
The Kubelet is responsible for implementing the summary API, and cadvisor is responsible for fulfilling `/metrics/cadvisor`.
79
79
80
80
The [CRI API](https://github.com/kubernetes/cri-api) currently does not provide enough metrics to fully supply all the fields for either endpoint, however is used to fill some fields of the summary API.
81
-
This results in an unclear origin of metrics, duplication of work done between cAdvisor and CRI, and performance implications.
81
+
This results in an unclear origin of metrics, duplication of work done between cAdvisor and CRI, and performance implications.
82
82
83
83
This KEP aims to enhance CRI implementations to be able to fulfill all the stats needs of Kubernetes.
84
84
At a high level, there are two pieces of this:
@@ -176,6 +176,7 @@ Below is a table describing which stats come from what source now, as well a pro
176
176
||N/A |container_last_seen |N/A |cAdvisor |CRI or N/A |
177
177
|||||cAdvisor |CRI or N/A |
178
178
179
+
179
180
## Motivation
180
181
181
182
We want to avoid using cAdvisor for container & pod level stats and move metric collection to the CRI implementation for the following reasons:
@@ -225,7 +226,7 @@ As such, this proposal will be broken up into what needs to be done for each of
225
226
2. Add CRI Pod Level Stats message to CRI protobuf that includes all [Pod Level Stats](#summary-pod-stats-object) metrics from Summary API.
226
227
3. Add support for the new CRI additions in supported container runtimes (CRI-O and containerd).
227
228
4. Switch Kubelet's CRI stats provider from querying container and pod level stats from cAdvisor to newly added CRI pod and container level stats
228
-
5. cAdvisor should stop collecting container and pod level stats. If any other components need container or pod level stats from cAdvisor, the CRI implementation should be queried instead.
229
+
5. cAdvisor should be updated to support no longer collecting stats that are duplicated with CRI implementation. Any client that requires the metrics that are reported by the CRI should gather them from the CRI instead of cAdvisor.
229
230
230
231
This will be described in more detail in the [design details section](#design-details)
231
232
@@ -234,7 +235,7 @@ This will be described in more detail in the [design details section](#design-de
234
235
### /metrics/cadvisor
235
236
236
237
1. Expose the metric fields provided in `/metrics/cadvisor` in an analogous Prometheus endpoint directly from the CRI implementation.
237
-
2. cAdvisor should stop collecting container and pod level stats, as well as stop broadcasting from `/metrics/cadvisor`.
238
+
5. cAdvisor should be updated to support no longer collecting stats that are duplicated with CRI implementation, and omit them from the report sent to`/metrics/cadvisor`.
238
239
3. The precise endpoint can change, but all the fields should be duplicated (so custom rules can be maintained).
239
240
4. Kubelet does not collect nor expose pod and container level metrics that were formally collected for and exposed by `/metrics/cadvisor`.
240
241
@@ -515,13 +516,11 @@ Each compliant CRI implementation must:
515
516
516
517
Below is the proposed strategy for doing so:
517
518
518
-
1. The Alpha release will strictly cover research, performance testing and the creation of conformance tests.
519
+
1. The Alpha release will focus solely on `/stats/summary` endpoint, and `/metrics/cadvisor` support will follow in Beta.
520
+
2. For the Beta release, add initial support for CRI implementations to report these metrics
519
521
- Initial research on the set of metrics required should be done. This will, possibly, allow the community to declare metrics that are not required to be moved to the CRI implementations.
520
522
- Testing on how performant cAdvisor+Kubelet are today should be done, to find a target, acceptable threshold of performance for the CRI implementations
521
523
- Creation of tests verifying the metrics are reported correctly should be created and verified with the existing cAdvisor implementation.
522
-
2. For the Beta release, add initial support for CRI implementations to report these metrics
523
-
- This set of metrics will be based on the research done in alpha
524
-
- Each will be validated against the conformance and performance tests created in alpha.
525
524
3. For the GA release, the CRI implementation should be the source of truth for all pod and container level metrics that external parties rely on (no matter how many endpoints the Kubelet advertises).
526
525
527
526
#### cAdvisor
@@ -540,19 +539,19 @@ As a requirement for the Beta stage, cAdvisor must support optionally collecting
540
539
541
540
- CRI should be extended to provide required stats for `/stats/summary`
542
541
- Kubelet should be extended to provide the required stats from CRI implementation for `/stats/summary`.
543
-
- cAdvisor should be updated to support no longer collecting stats that are duplicated with CRI implementation.
544
542
- This new behavior will be gated by a feature gate to prevent regressions for users that rely on the old behavior.
545
-
- Conduct research to find the set of metrics from `/metrics/cadvisor` that compliant CRI implementations must expose.
546
-
- Conformance tests for the fields in `/metrics/cadvisor` should be created
547
-
- Performance tests for CPU/memory usage between Kubelet/cAdvisor/CRI implementation should be added.
543
+
548
544
#### Alpha -> Beta Graduation
549
545
550
-
- CRI implementations should report any difficulties collecting the stats, and by Beta the CRI stats implementation should perform better than they did with CRI+cAdvisor.
551
-
- CRI implementations should support their equivalent of `/metrics/cadvisor`, passing the performance and conformance suite created in Alpha.
546
+
- Conduct research to find the set of metrics from `/metrics/cadvisor` that compliant CRI implementations must expose.
547
+
- Conformance tests for the fields in `/metrics/cadvisor` should be created.
548
+
- Validate performance impact of this feature is within allowable margin (or non-existent, ideally).
549
+
- The CRI stats implementation should perform better than they did with CRI+cAdvisor.
552
550
- cAdvisor stats provider may be marked as deprecated (depending on stability of new CRI based implementations).
553
551
- cAdvisor should be able to optionally not report the metrics needed for both summary API and `/metrics/cadvisor`. This behavior will be toggled by the Kubelet feature gate.
554
552
555
553
#### Beta -> GA Graduation
554
+
556
555
- The CRI stats provider in the Kubelet should be fully formed, and able to satisfy all the needs of downstream consumers
557
556
- cAdvisor stats provider will likely be marked as deprecated (depending on dockershim deprecation).
558
557
- Feature gate removed and the CRI stats provider will no longer rely on cAdvisor for container/pod level metrics.
@@ -561,8 +560,8 @@ As a requirement for the Beta stage, cAdvisor must support optionally collecting
561
560
562
561
- There needs to be a way for the Kubelet to verify the CRI provider is capable of providing the correct metrics.
563
562
Upon upgrading to a version that relies on this new behavior (assuming the feature gate is enabled),
564
-
Kubelet should fail early if the CRI implementation won't report the expected metrics.
565
-
- For Beta/GA releases, components that rely on `/metrics/cadvisor` should take the decided action (use `/stats/summary`, or use the Kubelet provided `/metrics/cadvisor`).
563
+
Kubelet should fallback to use cAdvisor if the CRI implementation won't report the expected metrics.
564
+
- For Beta/GA releases, components that rely on `/metrics/cadvisor` should take the decided action (use `/stats/summary`, or use the CRI provided replacement for`/metrics/cadvisor`).
566
565
567
566
### Version Skew Strategy
568
567
@@ -631,17 +630,35 @@ _This section must be completed when targeting beta graduation to a release._
631
630
Try to be as paranoid as possible - e.g., what if some components will restart
632
631
mid-rollout?
633
632
633
+
If the CRI implementation doesn't support the required metrics, and cAdvisor has container metrics collection turned off,
634
+
it is possible the node comes up with no metrics about pods and containers. This should be mitigated by making sure that
635
+
the kubelet probes the CRI implementation and enables cAdvisor metrics collection even if the feature gate is on.
636
+
634
637
***What specific metrics should inform a rollback?**
635
638
639
+
The lack of any metrics reported for pods and containers is the worst case scenerio here, and would require either a rollback or for the feature gate to be disabled.
640
+
636
641
***Were upgrade and rollback tested? Was the upgrade->downgrade->upgrade path tested?**
637
642
Describe manual testing that was done and the outcomes.
638
643
Longer term, we may want to require automated upgrade/rollback tests, but we
639
644
are missing a bunch of machinery and tooling and can't do that now.
640
645
646
+
The source of the metrics is a private matter between the kubelet, CRI implementation and cAdvisor. Since cAdvisor
647
+
in embedded in the kubelet, the two pieces that could move disjointly are kubelet and CRI implementation. The
648
+
quality of the metrics reported by the kubelet/CRI are dependent solely on the Kubelet's configuration at runtime. In other
649
+
words, rolling back and upgrading should have no affect--if the upgrade broke metrics because the CRI didn't support them
650
+
(and measures weren't taken to cause kubelet to fallback to cAdvisor), then a rollback (or toggling of the feature gate)
651
+
would return the metrics from cAdvisor.
652
+
641
653
***Is the rollout accompanied by any deprecations and/or removals of features, APIs,
642
654
fields of API types, flags, etc.?**
643
655
Even if applying deprecation policies, they may still surprise some users.
644
656
657
+
A piece of work for Beta is moving the source of the contents of `/metrics/cadvisor`. If users toggle the feature gate,
658
+
prometheus collectors will have to move the URL. However, it's an expressed intention of the implementation to have the CRI
659
+
report metrics previously reported by cAdvisor, so the contents should not change.
660
+
661
+
645
662
### Monitoring Requirements
646
663
647
664
_This section must be completed when targeting beta graduation to a release._
@@ -651,12 +668,17 @@ _This section must be completed when targeting beta graduation to a release._
651
668
checking if there are objects with field X set) may be a last resort. Avoid
652
669
logs or events for this purpose.
653
670
671
+
The source of the pod and container metrics previously reported to Prometheus by `/metrics/cadvisor` is the CRI implementation, not cAdvisor.
672
+
Further, if the CRI implementation was using the old CRI stats provider, then the memory usage of the cgroup the kubelet and runtime
673
+
were in should go down--as some duplicated work should be unduplicated.
674
+
654
675
***What are the SLIs (Service Level Indicators) an operator can use to determine
655
676
the health of the service?**
656
-
-[] Metrics
677
+
-[x] Metrics
657
678
- Metric name:
658
-
-[Optional] Aggregation method:
679
+
- all pod and container level stats coming from cAdvisor `container_*`
659
680
- Components exposing the metric:
681
+
- Previously cAdvisor, now CRI implementation.
660
682
-[ ] Other (treat as last resort)
661
683
- Details:
662
684
@@ -669,6 +691,9 @@ the health of the service?**
669
691
job creation time) for cron job <= 10%
670
692
- 99,9% of /health requests per day finish with 200 code
671
693
694
+
- Reduction of CPU and memory usage between kubelet and CRI (if previously using CRI stats provider).
695
+
- Minimal (< 2%) of performance hit between CPU and memory between CRI and kubelet (if previously using cAdvisor stats provider).
696
+
672
697
***Are there any missing metrics that would be useful to have to improve observability
673
698
of this feature?**
674
699
Describe the metrics themselves and the reasons why they weren't added (e.g., cost,
@@ -693,6 +718,12 @@ _This section must be completed when targeting beta graduation to a release._
693
718
- Impact of its degraded performance or high-error rates on the feature:
694
719
695
720
721
+
- CRI implementation
722
+
- Usage description:
723
+
- Impact of its outage on the feature: The feature, as well as many other pieces of Kubernetes, would not work, as the CRI implementation is vital to the creation and running of Pods.
724
+
- Impact of its degraded performance or high-error rates on the feature: All Kuberetes operations will slow down if the CRI spends too much energy in getting the stats.
725
+
726
+
696
727
### Scalability
697
728
698
729
_For alpha, this section is encouraged: reviewers should consider these questions
@@ -731,11 +762,11 @@ operations covered by [existing SLIs/SLOs]?**
731
762
- This may come because cAdvisor's performance has been fine-tuned, and changing the location of work may loose some optimizations.
732
763
- However, it is explicitly stated that a requirement for transition from Alpha->Beta is little to no performance degradation.
733
764
- The existence of the feature gate will allow users to mitigate this potential blip in performance (by not opting-in).
734
-
***Will enabling / using this feature result in non-negligible increase of
765
+
***Will enabling / using this feature result in non-negligible increase of
735
766
resource usage (CPU, RAM, disk, IO, ...) in any components?**
736
767
- It most likely will reduce resource utilization. Right now, there is duplicate work being done between CRI and cAdvisor.
737
768
This will not happen anymore.
738
-
- The CRI implementation may scrape the metrics less efficiently than cAdvisor currently does. This should be measured and evaluated before Beta.
769
+
- The CRI implementation may scrape the metrics less efficiently than cAdvisor currently does. This should be measured and evaluated as a requirement of Beta.
739
770
740
771
### Troubleshooting
741
772
@@ -748,7 +779,7 @@ _This section must be completed when targeting beta graduation to a release._
748
779
***How does this feature react if the API server and/or etcd is unavailable?**
749
780
- Should not change.
750
781
***What are other known failure modes?**
751
-
- Kubelet should fail early if problems are detected with version skew. Nothing else should be affected.
782
+
- Kubelet should fall back to using cAdvisor if errors are detected with version skew. Nothing else should be affected.
752
783
753
784
***What steps should be taken if SLOs are not being met to determine the problem?**
754
785
@@ -758,6 +789,10 @@ _This section must be completed when targeting beta graduation to a release._
758
789
## Implementation History
759
790
760
791
2021-1-27: KEP opened
792
+
2021-5-12: KEP merged, targeted at Alpha in 1.22
793
+
2021-7-8: KEP deemed not ready for Alpha in 1.22
794
+
2021-12-07: KEP successfully implemented at Alpha in 1.23
0 commit comments