-
Notifications
You must be signed in to change notification settings - Fork 797
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
Unprivileged Rootless Buildah on Kubernetes fails due to newgidmap/newuidmap: Operation not permitted error #4049
Comments
Hi @ckehoe , Thanks for creating the issue. Could you share how are you using buildah inside k8s ? Are you using buildah image from quay ? Could you share the image being used by pod to run buildah. ? I suspect something is wrong with the configured environment. Try using official buildah image from upstream i.e |
Also using buildah build --isolation=chroot ... Might be helpful. |
We are running into the same issue, tried both upstream and the latest tag. We are however running in openshift:
Any ideas? |
newuidmap and newgidmap are probably failing because you are running in a confined environment without SETUID and SETGID capabilities. Or newuidmap and newgidmap are not setfcap. |
The buildah pod is spun up as a Gitlab CI Runner to run our container build pipelines
Yes, the official buildah image from quay. Pulled down about 3 days before I posted the issue.
Anything specific to look for? Do you think it's the Centos 7.9 host or the container itself? |
No change when adding |
@ColonelBundy In your case I think as warning tells that there is no entry for your user in |
@ckehoe Could you share output of |
Solved it for now running as user 1000 and the nonroot scc in openshift. |
Thanks for confirming. |
Output of
Output of
|
@ckehoe Could you also please share |
@ckehoe Since you mentioned gitlab runner are you running in a double nested setup ? i.e kubernetes -> container (rootless) -> buildah ( that is inside first rootless container ) ? |
|
I don't believe so - it's a kubernetes runner so the buildah container runs on top of CRI-0 (built in to RKE2) |
@flouthoc Any thoughts on how to get this working? |
@ckehoe Upon checking this again with teammates. I think this is missing Could you try with additional caps on outer container i.e ( outermost buildah container ) securityContext:
capabilities:
add:
- CAP_SETGID
- CAP_SETUID cc @giuseppe do you think above is worth trying ? |
From my understanding CAP_SETUID is equivalent to running as root, as a process with CAP_SETUID can set their UID to anything including 0 i.e. root. Are there any ways to build containers inside of a container (such as in kubernetes) without this capability? |
no, you'd need to use user namespaces. CRI-O has support for them and support for user namespaces is being added to upstream Kubernetes as well |
CAP_SETUID is very powerful correct but the container is still prevented via SELinux, SECCOMP, Other missing CAPS, Namespaces ... CAP_SETUID is given to all containers by default in Podman, Docker, Containerd, if you trust the container then the processes running within the build will not be running with CAP_SETUID on the outer namespaces. |
I am closing the issue since this is not something that can be addressed in buildah |
Description
I have an unprivileged rootless Buildah container running on kubernetes/CRI-O on a Centos 7.9 host using VFS storage. When running any buildah command I receive the following output:
The
buildah bud
command eventually fails due to the following error:This issue is not present when running as user
build
withprivileged: true
enabled on the pod or when running as the root user without privileged mode enabled.Steps to reproduce the issue:
build
buildah bud
Describe the results you received:
Buildah is unable to create new gid or uid maps:
Describe the results you expected:
Expected buildah to be able to create mappings
Output of
rpm -q buildah
orapt list buildah
:Output of
buildah version
:Output of
cat /etc/*release
:Output of
uname -a
:Output of
cat /etc/containers/storage.conf
:Output of
buildah info
:Output of
capsh --print
:Output of
/etc/subgid
and/etc/subuid
:Output of
rpm -qa | grep shadow
:Output of
getcap /usr/bin/newuidmap /usr/bin/newgidmap
:Output of
cat /proc/sys/users/max_user_namespace
on Centos 7.9 host::The text was updated successfully, but these errors were encountered: