Update container insights to account for InitContainers/Pod Overhead #145
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description:
Kubernetes currently supports a concept called “init containers" which run to completion before the main container(s) of a pod are started. Starting with EKS 1.29, a new feature "SidecarContainers" will be introduced which allows init containers to run indefinitely, alongside the main application container(s) - thus acting as sidecars. A sidecar container is an init container with a restart policy.
https://github.com/kubernetes/enhancements/tree/master/keps/sig-node/753-sidecar-containers#exposing-pod-resource-requirements.
https://kubernetes.io/docs/concepts/scheduling-eviction/pod-overhead/
The current Container Insights implementation does not take into account initContainers(sidecar or regular) when reporting metrics. This will result in incorrect metrics values and therefore affect customer observability in EKS 1.29 clusters. This issue will only affect customers who choose to use the new sidecar containers feature.
This PR updates container insights to be accurate for EKS 1.29, by implementing resource calculations (cpu/mem limits/requests) in the same way kubernetes does.
Kubernetes code for reference: https://github.com/kubernetes/kubernetes/blob/e2afa175e4077d767745246662170acd86affeaf/pkg/api/v1/resource/helpers.go#L50
TLDR: With EKS 1.29 the formula for computing resource usage for Pods will need to be changed to account for init containers (sidecar/regular) and pod overhead if set.
The old formula was just
Sum(Container)
when it should have beenMax ( Max (Init Containers), Sum(Containers))
. As of EKS 1.29 the formula will be:where
InitContainerUse(i) = Sum(sidecar containers with index < i) + InitContainer(i)
Testing: