fix: include init containers when determining pod QoS that keep consistent with kubelet

Signed-off-by: thomassong <thomassong2012@gmail.com>
Co-authored-by: Paco Xu <paco.xu@daocloud.io>

Kubernetes-commit: 285e43d208a29acc9d19c47099699fe13d012f8a
This commit is contained in:
thomassong 2021-02-05 09:30:00 +08:00 committed by Kubernetes Publisher
parent 0a152f103a
commit 6847974534
1 changed files with 4 additions and 1 deletions

View File

@ -37,7 +37,10 @@ func GetPodQOS(pod *corev1.Pod) corev1.PodQOSClass {
limits := corev1.ResourceList{}
zeroQuantity := resource.MustParse("0")
isGuaranteed := true
for _, container := range pod.Spec.Containers {
allContainers := []corev1.Container{}
allContainers = append(allContainers, pod.Spec.Containers...)
allContainers = append(allContainers, pod.Spec.InitContainers...)
for _, container := range allContainers {
// process requests
for name, quantity := range container.Resources.Requests {
if !isSupportedQoSComputeResource(name) {