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

minikube preload tarballs need to preserve extended attributes such as capabilities #17804

Closed
afbjorklund opened this issue Dec 15, 2023 · 4 comments · Fixed by #17829
Closed
Assignees
Labels
priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release.

Comments

@afbjorklund
Copy link
Collaborator

afbjorklund commented Dec 15, 2023

The coredns version included with Kubernetes 1.29.0, that is coredns v1.11.1, now requires capabilities:

-ADD coredns /coredns
+COPY coredns /coredns
+RUN setcap cap_net_bind_service=+ep /coredns

So when you run coredns from that image (in the preload), it does not have the capability to listen below 1024:

Listen: listen tcp :53: bind: permission denied

coredns/coredns@d21537f


We need to make sure to include the extended attributes in the tarball, and to extract them again (requires root)

--xattrs --xattrs-include=security.capability

Then the capabilities gets included in the tarball, under a special header called "SCHILY.xattr.security.capability"

It requires a reasonable new tar version, like 1.27+

@afbjorklund
Copy link
Collaborator Author

The workaround to run --kubernetes-version=v1.29.0 before this fix, is to also include --preload=false

@afbjorklund afbjorklund added the priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. label Dec 15, 2023
@afbjorklund
Copy link
Collaborator Author

This issue only affects containerd and cri-o (and any other container runtime, except for docker), because of:

sysctl net.ipv4.ip_unprivileged_port_start=0 means that capability CAP_NET_BIND_SERVICEis not needed

@spowelljr spowelljr self-assigned this Dec 15, 2023
@afbjorklund
Copy link
Collaborator Author

afbjorklund commented Dec 16, 2023

Both containerd and cri-o have configuration to enable binding to ports below 1024, but it is off by default.

Docker has it on, since 20.10: moby/moby@dae652e adds sysctl net.ipv4.ip_unprivileged_port_start=0

containerd

    enable_unprivileged_ports = false

crio

# List of default sysctls. If it is empty or commented out, only the sysctls
# defined in the container json file by the user/kube will be added.
# default_sysctls = [
# ]

@gardo984
Copy link

gardo984 commented Jul 9, 2024

Both containerd and cri-o have configuration to enable binding to ports below 1024, but it is off by default.

Docker has it on, since 20.10: moby/moby@dae652e adds sysctl net.ipv4.ip_unprivileged_port_start=0

containerd

    enable_unprivileged_ports = false

crio

# List of default sysctls. If it is empty or commented out, only the sysctls
# defined in the container json file by the user/kube will be added.
# default_sysctls = [
# ]

Hey sir, thank you very much for sharing ur knowledge, this was very helpful and fixed the issue that I was having.

I made the change on the kernel settings and containerd settings and restart the services and it worked. 🥳

cat /etc/sysctl.conf |egrep -i net.ipv4.ip_unprivileged_port_start
-> net.ipv4.ip_unprivileged_port_start = 0
sysctl -f /etc/sysctl.conf

cat /etc/containerd/config.toml | egrep -i enable_unprivileged_ports
-> enable_unprivileged_ports = true
systemctl stop containerd && systemctl start containerd
systemctl stop kubelet && systemctl start kubelet
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants