File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed
staging/src/k8s.io/kubectl/pkg/util/resource Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -28,7 +28,9 @@ import (
28
28
)
29
29
30
30
// PodRequestsAndLimits returns a dictionary of all defined resources summed up for all
31
- // containers of the pod.
31
+ // containers of the pod. If pod overhead is non-nil, the pod overhead is added to the
32
+ // total container resource requests and to the total container limits which have a
33
+ // non-zero quantity.
32
34
func PodRequestsAndLimits (pod * corev1.Pod ) (reqs , limits corev1.ResourceList ) {
33
35
reqs , limits = corev1.ResourceList {}, corev1.ResourceList {}
34
36
for _ , container := range pod .Spec .Containers {
@@ -40,6 +42,18 @@ func PodRequestsAndLimits(pod *corev1.Pod) (reqs, limits corev1.ResourceList) {
40
42
maxResourceList (reqs , container .Resources .Requests )
41
43
maxResourceList (limits , container .Resources .Limits )
42
44
}
45
+
46
+ // Add overhead for running a pod to the sum of requests and to non-zero limits:
47
+ if pod .Spec .Overhead != nil {
48
+ addResourceList (reqs , pod .Spec .Overhead )
49
+
50
+ for name , quantity := range pod .Spec .Overhead {
51
+ if value , ok := limits [name ]; ok && ! value .IsZero () {
52
+ value .Add (quantity )
53
+ limits [name ] = value
54
+ }
55
+ }
56
+ }
43
57
return
44
58
}
45
59
You can’t perform that action at this time.
0 commit comments