Partial proposal for #4234 (cgroups inheritance when using k0s in docker) #5059
+221
−9
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
In the issue #4234 we discussed the lack of cgroup inheritance when k0s is launched inside a container and the fact that the kubelet does not use the limits set for the container.
Here is what I've tested so far and does not work:
Here is what I propose in a partial solution to this problem. To make the kubelet aware of it's cgroup limits the system reserved resources are set for the kubelet inside the
kubelet-config.yaml
file by k0s with its current limits.What it basically does is k0s takes its limits from the cgroup it belongs to, then from those limitations and the system capacity it calculates the amount of resources the kubelet should left untouched for the system.
Note: it is not a docker specific solution, it may also be suitable for #4319 and #4255
For example if the container is launched with
--cpuset-cpus="3,4" --memory 1G --cpus="0.2"
then the following configuration is pushed inkubelet-config.yaml
file:The node will then have the following configuration:
This is a partial solution as the kubelet and created pods are not inside a cgroup with some limitations and thus the limitations relies on the kubelet eviction mechanism instead of the kernel one.
This proposal need to be discussed as it imposes that we remove the two following configs from
kubelet-config.yaml
which are incompatible with the proposal (see https://kubernetes.io/docs/reference/config-api/kubelet-config.v1beta1/):Fixes #4234
Type of change
How Has This Been Tested?
Here is the script I launched to test the code, with a home built version of the k0s container:
Checklist: