Skip to content

Commit 4530b43

Browse files
authored
Merge pull request #3003 from haircommander/stats-3
KEP-2371: clarify plan for cAdvisor and target at Beta for 1.24
2 parents b26c25d + ac9c25d commit 4530b43

File tree

3 files changed

+63
-23
lines changed

3 files changed

+63
-23
lines changed
+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
kep-number: 2371
22
alpha:
33
approver: "@ehashman"
4+
beta:
5+
approver: "@ehashman"

keps/sig-node/2371-cri-pod-container-stats/README.md

+55-20
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ There are two main APIs that consumers use to gather stats about running contain
7878
The Kubelet is responsible for implementing the summary API, and cadvisor is responsible for fulfilling `/metrics/cadvisor`.
7979

8080
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.
8282

8383
This KEP aims to enhance CRI implementations to be able to fulfill all the stats needs of Kubernetes.
8484
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
176176
| |N/A |container_last_seen |N/A |cAdvisor |CRI or N/A |
177177
| | | | |cAdvisor |CRI or N/A |
178178

179+
179180
## Motivation
180181

181182
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
225226
2. Add CRI Pod Level Stats message to CRI protobuf that includes all [Pod Level Stats](#summary-pod-stats-object) metrics from Summary API.
226227
3. Add support for the new CRI additions in supported container runtimes (CRI-O and containerd).
227228
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.
229230

230231
This will be described in more detail in the [design details section](#design-details)
231232

@@ -234,7 +235,7 @@ This will be described in more detail in the [design details section](#design-de
234235
### /metrics/cadvisor
235236

236237
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`.
238239
3. The precise endpoint can change, but all the fields should be duplicated (so custom rules can be maintained).
239240
4. Kubelet does not collect nor expose pod and container level metrics that were formally collected for and exposed by `/metrics/cadvisor`.
240241

@@ -515,13 +516,11 @@ Each compliant CRI implementation must:
515516

516517
Below is the proposed strategy for doing so:
517518

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
519521
- 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.
520522
- Testing on how performant cAdvisor+Kubelet are today should be done, to find a target, acceptable threshold of performance for the CRI implementations
521523
- 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.
525524
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).
526525

527526
#### cAdvisor
@@ -540,19 +539,19 @@ As a requirement for the Beta stage, cAdvisor must support optionally collecting
540539

541540
- CRI should be extended to provide required stats for `/stats/summary`
542541
- 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.
544542
- 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+
548544
#### Alpha -> Beta Graduation
549545

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.
552550
- cAdvisor stats provider may be marked as deprecated (depending on stability of new CRI based implementations).
553551
- 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.
554552

555553
#### Beta -> GA Graduation
554+
556555
- The CRI stats provider in the Kubelet should be fully formed, and able to satisfy all the needs of downstream consumers
557556
- cAdvisor stats provider will likely be marked as deprecated (depending on dockershim deprecation).
558557
- 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
561560

562561
- There needs to be a way for the Kubelet to verify the CRI provider is capable of providing the correct metrics.
563562
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`).
566565

567566
### Version Skew Strategy
568567

@@ -631,17 +630,35 @@ _This section must be completed when targeting beta graduation to a release._
631630
Try to be as paranoid as possible - e.g., what if some components will restart
632631
mid-rollout?
633632

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+
634637
* **What specific metrics should inform a rollback?**
635638

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+
636641
* **Were upgrade and rollback tested? Was the upgrade->downgrade->upgrade path tested?**
637642
Describe manual testing that was done and the outcomes.
638643
Longer term, we may want to require automated upgrade/rollback tests, but we
639644
are missing a bunch of machinery and tooling and can't do that now.
640645

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+
641653
* **Is the rollout accompanied by any deprecations and/or removals of features, APIs,
642654
fields of API types, flags, etc.?**
643655
Even if applying deprecation policies, they may still surprise some users.
644656

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+
645662
### Monitoring Requirements
646663

647664
_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._
651668
checking if there are objects with field X set) may be a last resort. Avoid
652669
logs or events for this purpose.
653670

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+
654675
* **What are the SLIs (Service Level Indicators) an operator can use to determine
655676
the health of the service?**
656-
- [ ] Metrics
677+
- [x] Metrics
657678
- Metric name:
658-
- [Optional] Aggregation method:
679+
- all pod and container level stats coming from cAdvisor `container_*`
659680
- Components exposing the metric:
681+
- Previously cAdvisor, now CRI implementation.
660682
- [ ] Other (treat as last resort)
661683
- Details:
662684

@@ -669,6 +691,9 @@ the health of the service?**
669691
job creation time) for cron job <= 10%
670692
- 99,9% of /health requests per day finish with 200 code
671693

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+
672697
* **Are there any missing metrics that would be useful to have to improve observability
673698
of this feature?**
674699
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._
693718
- Impact of its degraded performance or high-error rates on the feature:
694719

695720

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+
696727
### Scalability
697728

698729
_For alpha, this section is encouraged: reviewers should consider these questions
@@ -731,11 +762,11 @@ operations covered by [existing SLIs/SLOs]?**
731762
- This may come because cAdvisor's performance has been fine-tuned, and changing the location of work may loose some optimizations.
732763
- However, it is explicitly stated that a requirement for transition from Alpha->Beta is little to no performance degradation.
733764
- 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
735766
resource usage (CPU, RAM, disk, IO, ...) in any components?**
736767
- It most likely will reduce resource utilization. Right now, there is duplicate work being done between CRI and cAdvisor.
737768
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.
739770

740771
### Troubleshooting
741772

@@ -748,7 +779,7 @@ _This section must be completed when targeting beta graduation to a release._
748779
* **How does this feature react if the API server and/or etcd is unavailable?**
749780
- Should not change.
750781
* **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.
752783

753784
* **What steps should be taken if SLOs are not being met to determine the problem?**
754785

@@ -758,6 +789,10 @@ _This section must be completed when targeting beta graduation to a release._
758789
## Implementation History
759790

760791
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
795+
2022-1-25: KEP targeted at Beta in 1.24
761796

762797
## Drawbacks
763798

keps/sig-node/2371-cri-pod-container-stats/kep.yaml

+6-3
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,13 @@ approvers:
1616
prr-approvers:
1717
- "@ehashman"
1818
creation-date: 2021-01-27
19-
last-updated: 2021-09-08
19+
last-updated: 2022-01-25
2020
status: implementable
21-
stage: alpha
22-
latest-milestone: "v1.23"
21+
stage: beta
22+
latest-milestone: "v1.24"
23+
milestone:
24+
alpha: "v1.23"
25+
beta: "v1.24"
2326
see-also:
2427
- N/A
2528
replaces:

0 commit comments

Comments
 (0)