kubelet: add initial support for cgroupv2

do a conversion from the cgroups v1 limits to cgroups v2.

e.g. cpu.shares on cgroups v1 has a range of [2-262144] while the
equivalent on cgroups v2 is cpu.weight that uses a range [1-10000].

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
Giuseppe Scrivano
2019-07-01 17:16:06 +02:00
parent d8077e9ba6
commit bb5ed1b797
4 changed files with 105 additions and 22 deletions

View File

@@ -161,6 +161,10 @@ func validateSystemRequirements(mountUtil mount.Interface) (features, error) {
return f, fmt.Errorf("%s - %v", localErr, err)
}
if cgroups.IsCgroup2UnifiedMode() {
return f, nil
}
expectedCgroups := sets.NewString("cpu", "cpuacct", "cpuset", "memory")
for _, mountPoint := range mountPoints {
if mountPoint.Type == cgroupMountType {
@@ -884,6 +888,11 @@ func getContainer(pid int) (string, error) {
return "", err
}
if cgroups.IsCgroup2UnifiedMode() {
c, _ := cgs[""]
return c, nil
}
cpu, found := cgs["cpu"]
if !found {
return "", cgroups.NewNotFoundError("cpu")