11 Commits

Author SHA1 Message Date
Chris Evich
942d58d41c Setup for quadlet/systemd runtime management
Rather than setting up volumes and starting the pipglr container
manually, utilize quadlet + systemd.  Retain the old setup and execution
method, but move them into separate documentation.

Signed-off-by: Chris Evich <cevich@redhat.com>
2024-02-16 13:17:39 -05:00
Chris Evich
2161f09276 Merge branch 'del_dep_opt' into 'main'
Remove deprecated registration CLI option

Closes #12

See merge request qontainers/pipglr!32
2024-01-08 18:01:24 +00:00
Chris Evich
ded61bee62 Remove deprecated registration CLI option
Ref:
https://docs.gitlab.com/ee/update/deprecations.html#registration-tokens-and-server-side-runner-arguments-in-gitlab-runner-register-command

Thanks to @maxsatula for pointing this out.

Fixes #12

Signed-off-by: Chris Evich <cevich@redhat.com>
2024-01-08 12:57:37 -05:00
Chris Evich
1955b5d544 Merge branch 'docs_update' into 'main'
Document immediate namespace update effect

Closes #11

See merge request qontainers/pipglr!31
2024-01-08 17:51:45 +00:00
Chris Evich
a987bf649c Document immediate namespace update effect
Fixes #11

Signed-off-by: Chris Evich <cevich@redhat.com>
2024-01-08 12:47:01 -05:00
Chris Evich
f13f2a3ba2 Merge branch 'feature/gitlab-url' into 'main'
Remove extra } from GITLAB_URL

See merge request qontainers/pipglr!30
2024-01-08 15:28:11 +00:00
Andrey Radchishin
70b5176a33 Remove extra } 2023-12-21 09:09:45 -05:00
Chris Evich
8a21f07632 Merge branch 'feature/gitlab-url' into 'main'
Allow overriding Gitlab URL

See merge request qontainers/pipglr!29
2023-12-19 16:24:48 +00:00
Andrey Radchishin
6c752ebebf Allow overriding Gitlab URL 2023-12-18 12:28:30 -05:00
Chris Evich
2ef9e11aea Merge branch 'bump_workaround_timebomb' into 'main'
Draft: Remove workaround for #7 (closed)

Closes #9

See merge request qontainers/pipglr!28
2023-12-05 14:57:34 +00:00
Chris Evich
11e2200ff9 Remove workaround for #7
Fixes: #9

Signed-off-by: Chris Evich <cevich@redhat.com>
2023-11-21 10:22:29 -05:00
8 changed files with 128 additions and 31 deletions

View File

@@ -45,6 +45,8 @@ ENTRYPOINT /lib/systemd/systemd
# Gitlab-runner configuration options, may be freely overridden at
# container image build time.
ARG DEFAULT_JOB_IMAGE=registry.fedoraproject.org/fedora-minimal:latest
# Allow image-builders to override the Gitlab URL
ARG GITLAB_URL=https://gitlab.com/
# Run nested containers in --privileged mode - required to allow building
# container images using podman or buildah. Otherwise may be set 'false'.
ARG NESTED_PRIVILEGED=true
@@ -59,11 +61,10 @@ LABEL register="podman run -it --rm \
--secret=REGISTRATION_TOKEN,type=env \
-v ./config.toml:/etc/gitlab-runner/config.toml:Z \
-e REGISTER_NON_INTERACTIVE=true \
-e CI_SERVER_URL=https://gitlab.com/ \
-e CI_SERVER_URL=${GITLAB_URL} \
-e RUNNER_NAME=pipglr \
-e RUNNER_EXECUTOR=docker \
-e RUNNER_SHELL=bash \
-e REGISTER_MAINTENANCE_NOTE=Podman-In-Podman-GitLab-Runner \
-e DOCKER_HOST=unix:///home/runner/podman.sock \
-e DOCKER_IMAGE=${DEFAULT_JOB_IMAGE} \
-e DOCKER_CACHE_DIR=/cache \

View File

@@ -96,7 +96,12 @@ called `johndoe`, the contents of these files should be edited to allocate
`jogndoe:<some number>:65539`
Where `<some number>` was set by your OS when the `johndoe` user was created
(you can ignore this). Only the last number needs to be increased.
(you can ignore this). Only the last number needs to be increased. This
change will be effective on next login, or immediately by running:
`podman system migrate`
*Note:* This will stop any currently running containers.
#### Runner registration (step 3)
@@ -154,34 +159,30 @@ to reflect the number of registered runners. If you need to edit this file
after committing it as a secret, there's
[ a `dumpconfig` *runlabel* for that](README.md#configuration-editing).
#### Volume setup (step 5)
#### Quadlet setup and container start (step 5)
Since several users are utilized inside the container volumes must be
specifically configured to permit access. This is done using several
*runlabels* as follows:
**Note**: If your system is missing or does not support the use of quadlet
(`man 5 podman-systemd.unit`), you'll find [manual volume setup steps
here](manual_setup.md).
Create and copy the quadlet configuration files:
```bash
$ IMAGE="registry.gitlab.com/qontainers/pipglr:latest"
$ podman container runlabel setupstorage $IMAGE
$ podman container runlabel setupcache $IMAGE
$ mkdir -p ~/.config/containers/systemd
$ cp quadlet/* ~/.config/containers/systemd/
```
Note: These volumes generally do not contain any critical operational data,
they may be re-created anytime to quickly free up host disk-space if
it's running low. Simply remove them with the command
`podman volume rm pipglr-storage pipglr-cache`. Then reuse the `setupstorage`
and `setupcache` *runlabels* as in the above example.
#### Runner Startup (step 6)
With the runner configuration saved as a Podman secret, and the runner volumes
created, the GitLab runner container may be launched with the following commands:
Finally, reload the local systemd user-slice to generate the unit files,
and fire up pipglr!
```bash
$ IMAGE="registry.gitlab.com/qontainers/pipglr:latest"
$ podman container runlabel run $IMAGE
$ systemd --user daemon-reload
$ systemd start pipglr
```
If you want the service to start automatically on boot, you may run
`systemctl --user enable podman-restart.service`
### Configuration Editing
The gitlab-runner configuration contains some sensitive values which
@@ -242,6 +243,8 @@ Several build arguments are available to control the output image:
`--platform` build argument, it will be set automatically. Note:
as of this writing, only `amd64` and `arm64` builds of the gitlab-runner
are available.
* `GITLAB_URL` - Defaults to 'https://gitlab.com/' but can be set to point
to a self hosted instance of Gitlab.
* `NESTED_PRIVILEGED` - Defaults to 'true', may be set 'false' to prevent
nested containers running in `--privileged` mode. This will affect
the ability to build container images in CI jobs using tools like

32
manual_setup.md Normal file
View File

@@ -0,0 +1,32 @@
### Additional Manual steps
On systems without Quadlet, some additional steps are required
to get the pipglr container up and running.
### Manual Volume setup
Since several users are utilized inside the container volumes must be
specifically configured to permit access. This is done using several
*runlabels* as follows:
```bash
$ IMAGE="registry.gitlab.com/qontainers/pipglr:latest"
$ podman container runlabel setupstorage $IMAGE
$ podman container runlabel setupcache $IMAGE
```
Note: These volumes generally do not contain any critical operational data,
they may be re-created anytime to quickly free up host disk-space if
it's running low. Simply remove them with the command
`podman volume rm pipglr-storage pipglr-cache`. Then reuse the `setupstorage`
and `setupcache` *runlabels* as in the above example.
#### Manual Runner Startup
With the runner configuration saved as a Podman secret, and the runner volumes
created, the GitLab runner container may be launched with the following commands:
```bash
$ IMAGE="registry.gitlab.com/qontainers/pipglr:latest"
$ podman container runlabel run $IMAGE
```

View File

@@ -0,0 +1,13 @@
[Unit]
Description=Podman-in-podman GitLab Runner job cache storage volume
Documentation=https://gitlab.com/qontainers/pipglr/-/blob/main/README.md
After=local-fs.target
Requires=podman.socket
[Volume]
VolumeName=pipglr-cache
Copy=false
# The `podman` user inside the container should own everything
Options=o=uid=1000,gid=1000
# Support podman...prune --filters=persistent!=true
Label=persistent=true

View File

@@ -0,0 +1,13 @@
[Unit]
Description=Podman-in-podman GitLab Runner nested-container storage volume
Documentation=https://gitlab.com/qontainers/pipglr/-/blob/main/README.md
After=local-fs.target
Requires=podman.socket
[Volume]
VolumeName=pipglr-storage
Copy=false
# The `podman` user inside the container should own everything
Options=o=uid=1000,gid=1000
# Support podman...prune --filters=persistent!=true
Label=persistent=true

33
quadlet/pipglr.container Normal file
View File

@@ -0,0 +1,33 @@
[Unit]
Description=Podman-in-podman GitLab Runner
Documentation=https://gitlab.com/qontainers/pipglr/-/blob/main/README.md
After=pipglr-storage-volume.service pipglr-cache-volume.service
Requires=podman.socket pipglr-storage-volume.service pipglr-cache-volume.service
[Container]
ContainerName=pipglr
Image=registry.gitlab.com/qontainers/pipglr
# Required to run containers inside a container and ensure
# container can be managed with podman-restart.service
# Note: See https://github.com/containers/podman/issues/20418
PodmanArgs=--privileged --restart=always
# A nested systemd is used to manage nested podman & gitlab runner services
Systemd=true
# Allow jobs access to utilize fuse-overlayfs, for example to build container images.
Device=/dev/fuse
# Must be owned by the gitlab-runner user
Secret config.toml,uid=1001,gid=1001
# Add network isolation from other containers
Network=pipglr.network
# Storage for nested container images and job cache
Volume=pipglr-storage:/home/podman/.local/share/containers
Volume=pipglr-cache:/cache
# No need to preserve this between runs
VolatileTmp=true

11
quadlet/pipglr.network Normal file
View File

@@ -0,0 +1,11 @@
[Unit]
Description=Podman-in-podman GitLab Runner dedicated network
Documentation=https://gitlab.com/qontainers/pipglr/-/blob/main/README.md
After=network-online.target
Requires=podman.socket network.target
[Network]
Driver=bridge
# The pipglr container never accesses other containers on/or the host
Options=isolate
DisableDNS=true

View File

@@ -38,15 +38,6 @@ set -x # show what's happening to make debugging easier
# DNF itself or a dependence may need upgrading, take care of it first.
$DNF upgrade
# WORKAROUND: crun: write to `/proc/self/oom_score_adj`: Permission denied
# Ref: https://github.com/containers/podman/pull/19843
if [[ $(date +%Y%m%d) -gt 20231115 ]]; then
echo "FIXME: Please check if crun 1.9.3+ is available in CentOS Stream-9."
echo "If so, this crun-1.8.7 workaround may be removed."
exit 1
fi
dnf $x install -y crun-1.8.7
$DNF $x install \
podman \
systemd