diff --git a/pkg/kubelet/cm/helpers_linux.go b/pkg/kubelet/cm/helpers_linux.go index ce2d9a9670f..9b115ab5380 100644 --- a/pkg/kubelet/cm/helpers_linux.go +++ b/pkg/kubelet/cm/helpers_linux.go @@ -38,8 +38,11 @@ import ( ) const ( - // Taken from lmctfy https://github.com/google/lmctfy/blob/master/lmctfy/controllers/cpu_controller.cc - MinShares = 2 + // These limits are defined in the kernel: + // https://github.com/torvalds/linux/blob/0bddd227f3dc55975e2b8dfa7fc6f959b062a2c7/kernel/sched/sched.h#L427-L428 + MinShares = 2 + MaxShares = 262144 + SharesPerCPU = 1024 MilliCPUToCPU = 1000 @@ -88,6 +91,9 @@ func MilliCPUToShares(milliCPU int64) uint64 { if shares < MinShares { return MinShares } + if shares > MaxShares { + return MaxShares + } return uint64(shares) }