-
Notifications
You must be signed in to change notification settings - Fork 41.2k
[Carry 133278] kubelet: Don't ignore idsPerPod config #133278 #133373
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
The idsPerPod where completely ignored since they were introduced in PR: kubernetes#130028 The problem was the following: 1. The userns manager (as well as all managers) is created before the config is copied to the kubelet object[1] 2. The userns manager on creation is calling the kubelet_getter GetUserNamespacesIDsPerPod to get the idsPerPod 3. The getter checks the configuration stored in the kubelet object, which hasn't been set at that point. 4. As the config is nil (unset), it returns the default value. Therefore, the value was ignored. To solve this, let's just pass the idsPerPod as a parameter to MakeUserNsManager(). This is the common pattern already used in the kubelet initialization. [1]: https://github.com/kubernetes/kubernetes/blob/461ba83084ab7cb91ab692687bb7aedb05c6eb65/pkg/kubelet/kubelet.go#L1078-L1087 [2]: https://github.com/kubernetes/kubernetes/blob/461ba83084ab7cb91ab692687bb7aedb05c6eb65/pkg/kubelet/kubelet_getters.go#L145 Signed-off-by: Rodrigo Campos <[email protected]>
The first UID used for userns mappings needs to be at least the idsPerPod. When idsPerPod is extended to be 65536*2, for example, then the default UID of 65536 doesn't work. While this can be configured by the user, let's just improve the default first UID to be the same as idsPerPod. This makes the default first UID work out of the box if the user just wants to tune that. This also simplifies testing, as we don't need to create a system user and /etc/subuid and /etc/subgid files to test the idsPerPod setting. Signed-off-by: Rodrigo Campos <[email protected]>
Golang allows to call methods on a nil object, as long as the methods don't dereference the nil object. This is what we do here. This makes all the userns configurations (idsPerPod or mapping configs in /etc/subuid or /etc/subgid) to be ignored if the feature is off. Signed-off-by: Rodrigo Campos <[email protected]>
Signed-off-by: Rodrigo Campos <[email protected]> Signed-off-by: Akihiro Suda <[email protected]>
/retest |
2 similar comments
/retest |
/retest |
/test pull-kubernetes-node-crio-cgrpv2-userns-e2e-serial |
@AkihiroSuda Thanks for improving the tests! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@SergeyKanzhelev can you please add this one to the milestone?
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: AkihiroSuda, rata The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/triage accepted |
Carry #133278, so as to address my own comments (tests/e2e_node: Add test for userNamespaces.idsPerPod)
(Below is copied from #133278)
The idsPerPod where completely ignored since they were introduced in PR: #130028
The problem was the following:
Therefore, the value was ignored.
To solve this, let's just pass the idsPerPod as a parameter to MakeUserNsManager(). This is the common pattern already used in the kubelet initialization.
cc @AkihiroSuda @giuseppe
What type of PR is this?
/kind bug
What this PR does / why we need it:
We now honor the idsPerPod config from the kubelet.
Which issue(s) this PR is related to:
Fixes: #133144
Special notes for your reviewer:
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: