Commit Graph

13 Commits

Author SHA1 Message Date
Rodrigo Campos
4bb508dd30 kubelet/userns: Add unit test
Signed-off-by: Rodrigo Campos <rodrigoca@microsoft.com>
2024-03-02 12:15:44 +01:00
Rodrigo Campos
0b69c2bc81 kubelet/userns: Use kubelet maxPods
We don't have the alpha limitation anymore, let's just use the kubelet
maxPods instead of our hardcoded 1024 max.

Signed-off-by: Rodrigo Campos <rodrigoca@microsoft.com>
2024-03-02 12:15:44 +01:00
Rodrigo Campos
39c6815676 kubelet/userns: Remove alpha maxPods limitation
Signed-off-by: Rodrigo Campos <rodrigoca@microsoft.com>
2024-03-02 12:15:44 +01:00
Rodrigo Campos
4180284dc9 pkg/kubelet/userns: Remove outdated test
When we were alocating the whole UID space, the first range was reserved
to the host. Now we don't allocate the whole UID space, but just the
range configured, so the first range doesn't point to [0;65535] anymore,
so no need to test it is always set.

Signed-off-by: Rodrigo Campos <rodrigoca@microsoft.com>
2024-03-02 12:15:43 +01:00
Giuseppe Scrivano
87a057d417 KEP-127: kubelet: honor kubelet user mappings
allow to specify what IDs must be used by the kubelet to create user
namespaces.

If no additional UIDs/GIDs are not allocated to the "kubelet" user,
then the kubelet assumes it can use any ID on the system.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-03-02 12:15:39 +01:00
Rodrigo Campos
0e2b447269 kubelet/userns: Test new functionality with feature gate enabled
Signed-off-by: Rodrigo Campos <rodrigoca@microsoft.com>
2024-02-27 12:01:00 +01:00
Giuseppe Scrivano
b2a92406ef KEP-127: check for runtime handler userns support
block the creation of a pod that requires a user namespace, unless the
runtime handler has support for it.

If the pod requested for a user namespace, and the handler does not
support it then return an error regardless of the feature gate.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-02-27 12:01:00 +01:00
Rodrigo Campos
5a8579a3e4 kubelet/userns: Remove tests that fail as root
For some reason the CI didn't fail when we open the PR. But when you run
"go test" as root, with all the capabilities, tests that exercise
permission errors will never work. As the capabilities makes them always
bypass the permission checks.

For some reason it seems that:
 * Not all our CI was run when the PR was open
 * The CI was changed to run as root now
 * _Some_ CI was added and it runs as root

If it wasn't one of that, or a combination, I don't see how this could
have happened. If any of that indeed happened, it can break more tests
outside the userns package too.

Signed-off-by: Rodrigo Campos <rodrigoca@microsoft.com>
2024-02-19 14:52:33 -03:00
Rodrigo Campos
cae710d9e9 kublet/userns: Test error messages on init failures
This adds a test for the just added wrapping error message, as well as
for the other already present error messages that initialization can
fail with.

Signed-off-by: Rodrigo Campos <rodrigoca@microsoft.com>
2024-02-05 19:03:50 +01:00
Rodrigo Campos
a56d483df0 kubelet/userns: Use t.TempDir()
These tests will create the userns record mapping file, so let's use a
temporal directory for that.

Without specifying one, by mistake we were using the
"/tmp/non-existant-dir.This-is-not-used-in-tests/" directory.

Signed-off-by: Rodrigo Campos <rodrigoca@microsoft.com>
2024-02-01 12:02:29 +01:00
Rodrigo Campos
2508f468a8 kubelet/userns: Add more unit tests
This covers all public methods and overall test coverage is above 80%
again.

Signed-off-by: Rodrigo Campos <rodrigoca@microsoft.com>
2023-10-18 11:59:54 +02:00
Giuseppe Scrivano
531d38e323 features: rename UserNamespacesStatelessPodsSupport
now it is called UserNamespacesSupport since all kind of volumes are
supported.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-06-22 15:19:50 +02:00
Rodrigo Campos
ec0410a266 kubelet: Move userns manager to its own package
To that end, we need to add one kubelet getter listPodsFromDisk(). Other
than that, it is a pretty trivial move.

Signed-off-by: Rodrigo Campos <rodrigoca@microsoft.com>
2023-03-13 22:28:04 +01:00