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

Allow rootless containers to bind privileged ports and ping #2466

Closed
vflaux opened this issue Sep 29, 2022 · 6 comments · Fixed by #2494
Closed

Allow rootless containers to bind privileged ports and ping #2466

vflaux opened this issue Sep 29, 2022 · 6 comments · Fixed by #2494

Comments

@vflaux
Copy link

vflaux commented Sep 29, 2022

What I'd like:
Add config options to allow containers to bind privileged ports (<1024) and open icmp echo sockets without being root. (This the defaults with dockerd)
It can be enabled within containerd config (/etc/containerd/config.toml).
For kubernetes:

[plugins."io.containerd.grpc.v1.cri"]
enable_unprivileged_ports = true
enable_unprivileged_icmp = true

Any alternatives you've considered:

This can be worked around with kubernetes (>1.22) with a SecurityContext on pods:

securityContext:
  sysctls:
    - name: net.ipv4.ip_unprivileged_port_start
      value: "0"
    - name: net.ipv4.ping_group_range
      value: "0 2147483647"

It can also be configured within a bootstrap container but I'm not sure how to restart containerd from there.

@zmrow
Copy link
Contributor

zmrow commented Sep 29, 2022

Thanks for the issue @vflaux ! There are a few related requests in #1703 and #2404.

Does the SecurityContext workaround mentioned unblock this for you? Would the containerd settings mentioned be beneficial if so?

@vflaux
Copy link
Author

vflaux commented Sep 30, 2022

Hi,

The workaround works and we could also use a different port, but that means changing the manifests.

More context:
We are transitioning from dockerd to containerd with AL2 AMI and found some of our client apps that bind to the port 80. So we patched the containerd config with a bootstrap script which fix the issue.
We are also evaluating Bottelrocket AMI and noticed that we had the same problem.

We have to switch to containerd in the future and we can do this without breaking changes to our clients with AL2. But we cannot with Bottlerocket unless we can change the sysctl net.ipv4.ip_unprivileged_port_start of containers (via containerd or another component).

@zmrow
Copy link
Contributor

zmrow commented Sep 30, 2022

Thanks for the extra context! Another option here is to set these sysctls with settings.kernel.sysctl.

Based on your example above, it would look something like:

[settings.kernel.sysctl]
"net.ipv4.ip_unprivileged_port_start" = "0"
"net.ipv4.ping_group_range" = "0 2147483647"

@vflaux
Copy link
Author

vflaux commented Oct 3, 2022

settings.kernel.sysctl apply sysctls on the host but they are not propagated to the namespace of containers.

From the admin container:

$ sudo shelltie
# sysctl net.ipv4.ip_unprivileged_port_start
net.ipv4.ip_unprivileged_port_start = 0

From a pod:

$ sysctl net.ipv4.ip_unprivileged_port_start
net.ipv4.ip_unprivileged_port_start = 1024

@zmrow
Copy link
Contributor

zmrow commented Oct 3, 2022

Good point.

There is an issue in the containerd repo to enable these by default. It seem that the only caveat is that it can't be done with really old kernels (at least 3.10), which we don't use anyway.

Perhaps we can look into enabling these by default.

@zmrow
Copy link
Contributor

zmrow commented Oct 3, 2022

The comments on the related containerd issue suggests that enabling these "could break existing deployments", but the comment hasn't been expanded on.

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 a pull request may close this issue.

2 participants