-
Notifications
You must be signed in to change notification settings - Fork 35
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
tasks: Bind the host's podman API socket #583
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
013f9a2
to
57e1ee8
Compare
Ugh, running the test on GitHub is difficult. First of all, the
containers/podman#17362 doesn't make me very hopeful, but there is somebody who backported the Debian bookworm packages to Ubuntu 22.04: https://launchpad.net/~quarckster/+archive/ubuntu/containers . This works very well indeed! I don't want to waste too much time on the EPERM on github, so I just hacked it. |
36ebb34
to
e6091cd
Compare
Rebased after #585 |
e6091cd
to
caba867
Compare
@@ -61,8 +65,11 @@ ExecStart=/usr/bin/podman run --name=cockpit-tasks-%i --hostname=${CONTAINER_HOS | |||
--volume=\${TEST_SECRETS}/webhook:/run/secrets/webhook:ro \ | |||
--volume=${IMAGE_STORES}:/work/.config/cockpit-dev/image-stores:ro \ | |||
--volume=/etc/npmrc:/etc/npmrc:ro \ | |||
--volume=%t/podman/podman.sock:/podman.sock:rw \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use the "normal" location on the inside, and save ourselves the envvar?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Heh, I spent about two hours on that. There's no $XDG_RUNTIME_DIR
in the tasks container, so podman defaults to some /tmp/podman-1111/whatever
path which doesn't feel very predictable. Plus, if you actually bind-mount it there, it then wants a /work/rundir/podman/... directory. This is by far the easiest and most robust version that I found.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean /run/podman/podman.sock
. I guess that's only the default when you're root, though?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But we aren't, we are uid 1111 😁
This paves the way for spawning per-job tasks containers from the container (via `job-runner`). Getting the permissions right is unfortunately annoyingly complicated, as the host's socket has 660 permissions, but the tasks container runs as uid 1111. Ideally we could use something like -v "${XDG_RUNTIME_DIR:-/run}/podman/podman.sock:/podman.sock:idmap=gids=$(id -g)-1111-1" but that fails with "invalid mappings", and is generally not well documented. `--mount=type=bind,[...],idmap --uidmap [...]` does not work either. So resort to file permissions for the host's `podman.sock`: - For local developers in `run-local.sh`, make the socket world writable. This does not actually hurt for a human developer: Its directory (/run/user/uid) is not accessible for any other user. - For production, set the socket group to `1111`. That doesn't matter much, the secrets are all already chmod'ed to the container user, and these machines don't do anything else. `setfacl` would be more targeted, but it isn't installed in Fedora IoT/CoreOS.
caba867
to
7f6f269
Compare
@allisonkarlitskaya Simplified as discussed, fixed the rebase error, and I redeployed it on rhos-01-1. I re-validated that I can access podman there. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better, thanks!
tasks: Bind the host's podman API socket
This paves the way for spawning per-job tasks containers from the
container (via
job-runner
).Getting the permissions right is unfortunately annoyingly complicated, as the
host's socket has 660 permissions, but the tasks container runs as uid 1111.
Ideally we could use something like
but that fails with "invalid mappings", and is generally not well documented.
--mount=type=bind,[...],idmap --uidmap [...]
does not work either.So resort to file permissions for the host's
podman.sock
:For local developers in
run-local.sh
, make the socket worldwritable. This does not actually hurt for a human developer: Its
directory (/run/user/uid) is not accessible for any other user.
For production, set the socket group to
1111
. That doesn't mattermuch, the secrets are all already chmod'ed to the container user, and
these machines don't do anything else.
setfacl
would be moretargeted, but it isn't installed in Fedora IoT/CoreOS.
I rolled this out to one production machine:
Et voilà:
Once this lands, I'll apply it to all our production machines.