feat: compatibility with docker userns-remap #1442
Merged
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.
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:userns=host
has virtually no impactuserns=host
is required to start node containersSo 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.