Skip to content
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

feat: compatibility with docker userns-remap #1442

Merged
merged 1 commit into from
May 29, 2024
Merged

Conversation

proudier
Copy link
Contributor

What

This MR make k3d compatible with the userns-remap feature of Docker, like described in #547.

Why

As a developer, I run container applications from various sources and some run as root in the container.
To strengthen the isolation between the host and the containers, Im interested in leveraging Linux user namespaces.

Here's an example of a security exploit that would be blocked by using user namespaces, according to one of the maintainers of runc: CVE-2019-5736

Docker supports user namespaces when the daemon is configured to run with userns-remap.
With this setting enabled, privileged containers need to be created with userns=host explicitly.

Implications

This MR just set userns=host on all K3d privileged containers. As far as I understand, having a mechanism to detect if the daemon has userns-remap enabled is useless:

  • when userns-remap is disabled, the containers share the user namespace with the host, so setting userns=host has virtually no impact
  • when userns-remap is enabled, userns=host is required to start node containers

So it should be transparent for users who have userns-remap disabled. (Am I missing something?)

Tests

I've run this branch of k3d on my daily development laptop with no issue for a week now.
I have Localstack, Prometheus, Loki and Grafana deployed via Helm, with values suitable for single-node/development deployment.

@proudier proudier marked this pull request as ready for review May 29, 2024 00:24
@proudier
Copy link
Contributor Author

@all-contributors please add @proudier for code

Copy link
Contributor

@proudier

I've put up a pull request to add @proudier! 🎉

@iwilltry42
Copy link
Member

Thanks for this PR @proudier ! 🙏

So it should be transparent for users who have userns-remap disabled

AFAICT this is correct, so I'll merge this 👍

@iwilltry42 iwilltry42 merged commit 01d3876 into k3d-io:main May 29, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants