Start again from agentos: a read-only, verity-checked /usr with A/B updates, and a TPM-encrypted btrfs root made at first boot that holds /etc and /var. On top of that the runner: gitea-runner from gitea.com, a path unit that starts it once registered, and a drain before update reboots. Jobs run in plain Fedora on root's podman. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0569bce676
commit
0733ff55f3
49 files changed
+492
-509
No files matched your search
@@ -1,12 +1,8 @@
|
||||
# DHCP on the real network cards. Kind=!* skips virtual links like the veths of podman's bridges,
|
||||
# which netavark manages.
|
||||
# 80-dhcp.network turns on DHCP on the real network cards. Kind=!* skips
|
||||
# virtual links such as those of containers.
|
||||
[Match]
|
||||
Type=ether
|
||||
Kind=!*
|
||||
|
||||
[Network]
|
||||
DHCP=yes
|
||||
|
||||
[DHCPv4]
|
||||
# The hostname is the runner's name (gitea-runner.service), not the DHCP server's.
|
||||
UseHostname=no
|
||||
@@ -1,12 +0,0 @@
|
||||
# Services enabled in the image (mkosi runs systemctl preset-all). Fedora disables getty@.service, the
|
||||
# login on the screen (tty1, and tty2-6 through its autovt@ alias); this file sorts first, so it wins.
|
||||
enable systemd-networkd.service
|
||||
enable systemd-resolved.service
|
||||
enable nftables.service
|
||||
enable podman.socket
|
||||
enable getty@.service
|
||||
enable gitea-runner-setup@.service tty1 ttyS0
|
||||
enable etc-shadow.mount
|
||||
enable gitea-runner.service
|
||||
enable systemd-sysupdate-update.timer
|
||||
enable systemd-sysupdate-reboot.timer
|
||||
@@ -0,0 +1,24 @@
|
||||
# 50-runneros.preset enables the services of the image. PID 1 applies it at
|
||||
# first boot, so a change reaches existing machines only after a factory reset.
|
||||
# It sorts before Fedora's presets, so it wins where they disagree.
|
||||
|
||||
# systemd-networkd is disabled by Fedora, which uses NetworkManager.
|
||||
enable systemd-networkd.service
|
||||
|
||||
# gitea-runner.path starts the runner once it is registered.
|
||||
enable gitea-runner.path
|
||||
disable gitea-runner.service
|
||||
|
||||
# getty@.service is the login on the screen, which Fedora disables.
|
||||
enable getty@.service
|
||||
enable systemd-sysupdate-update.timer
|
||||
enable systemd-sysupdate-reboot.timer
|
||||
|
||||
# authselect-apply-changes fails, because /etc/authselect is on read-only /usr.
|
||||
disable authselect-apply-changes.service
|
||||
|
||||
# systemd-homed, systemd-userdbd and systemd-nsresourced are unused here.
|
||||
disable systemd-homed.service
|
||||
disable systemd-homed-activate.service
|
||||
disable systemd-userdbd.socket
|
||||
disable systemd-nsresourced.socket
|
||||
@@ -1,14 +0,0 @@
|
||||
# The root password. /etc is read-only, so gitea-runner-setup writes the shadow file to /var and
|
||||
# this mounts it over /etc/shadow.
|
||||
[Unit]
|
||||
Description=Root password from /var
|
||||
ConditionPathExists=/var/lib/shadow/etc/shadow
|
||||
RequiresMountsFor=/var
|
||||
|
||||
[Mount]
|
||||
What=/var/lib/shadow/etc/shadow
|
||||
Where=/etc/shadow
|
||||
Options=bind
|
||||
|
||||
[Install]
|
||||
WantedBy=local-fs.target
|
||||
@@ -1,18 +0,0 @@
|
||||
# Before the runner starts: loads our job image from /usr into podman's storage (wiped at every
|
||||
# boot), and pulls the base images that jobs share read-only (see /usr/lib/gitea-runner/config.yaml),
|
||||
# so no job uses them while they change. Hosts reboot to update, so this runs about as often as
|
||||
# there are updates.
|
||||
[Unit]
|
||||
Description=Images for Gitea Actions jobs
|
||||
Wants=network-online.target
|
||||
After=network-online.target
|
||||
Before=gitea-runner.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
Environment=IMAGES=/var/lib/containers/base-images
|
||||
ExecStart=/bin/sh -c 'podman tag "$(podman pull -q oci:/usr/lib/gitea-runner/job-image)" localhost/git-runner-job:latest'
|
||||
# Without network the runner still starts, with the images it has.
|
||||
ExecStart=-/usr/bin/podman --root ${IMAGES} --runroot /run/containers/base-images pull -q --policy newer quay.io/fedora/fedora:45
|
||||
ExecStart=/usr/bin/podman --root ${IMAGES} --runroot /run/containers/base-images image prune -f
|
||||
TimeoutStartSec=30min
|
||||
@@ -1,20 +0,0 @@
|
||||
# First boot: asks for the root password and the runner's registration, on the screen (tty1) and
|
||||
# the serial console (ttyS0) at once; whichever is answered first stops the other.
|
||||
[Unit]
|
||||
Description=Gitea runner first-boot setup on %I
|
||||
ConditionPathExists=!/var/lib/gitea-runner/runner.env
|
||||
Before=getty@%i.service serial-getty@%i.service kmsconvt@%i.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/libexec/gitea-runner-setup
|
||||
StandardInput=tty
|
||||
StandardOutput=tty
|
||||
TTYPath=/dev/%I
|
||||
TTYReset=yes
|
||||
TTYVHangup=yes
|
||||
# Answering on one console stops the setup on the other (SIGTERM), which is no failure.
|
||||
SuccessExitStatus=SIGTERM
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -0,0 +1,10 @@
|
||||
# gitea-runner.path starts the runner once it is registered, so a new machine
|
||||
# waits for `gitea-runner -c /etc/gitea-runner/config.yaml register`.
|
||||
[Unit]
|
||||
Description=Start the Gitea runner once registered
|
||||
|
||||
[Path]
|
||||
PathExists=/var/lib/gitea-runner/.runner
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -1,28 +1,20 @@
|
||||
# The Gitea Actions runner. Registers itself on its first start.
|
||||
# gitea-runner.service runs the Gitea Actions runner, which runs each job in a
|
||||
# container on root's podman. gitea-runner.path starts it once it is
|
||||
# registered. It runs as root: whoever has podman's socket is root anyway.
|
||||
#
|
||||
# TimeoutStopSec is a bit longer than runner.shutdown_timeout in
|
||||
# /etc/gitea-runner/config.yaml, so running jobs can finish on stop.
|
||||
[Unit]
|
||||
Description=Gitea Actions runner
|
||||
Wants=network-online.target gitea-runner-images.service
|
||||
# gitea-runner-setup writes runner.env on first boot.
|
||||
After=network-online.target podman.socket gitea-runner-images.service
|
||||
After=gitea-runner-setup@tty1.service gitea-runner-setup@ttyS0.service
|
||||
Wants=network-online.target
|
||||
After=network-online.target podman.socket
|
||||
Requires=podman.socket
|
||||
|
||||
[Service]
|
||||
# Runs as root: it drives root's podman, which is root access anyway. The jobs it starts never
|
||||
# get the socket (see config.yaml).
|
||||
WorkingDirectory=/var/lib/gitea-runner
|
||||
EnvironmentFile=/var/lib/gitea-runner/runner.env
|
||||
# HOME holds the cache of actions/cache, next to the registration.
|
||||
Environment=HOME=/var/lib/gitea-runner
|
||||
Environment=DOCKER_HOST=unix:///run/podman/podman.sock
|
||||
# The hostname is the runner's name. /etc is read-only, so it is set on every start.
|
||||
ExecStartPre=/usr/bin/hostnamectl hostname --transient ${GITEA_RUNNER_NAME}
|
||||
# Register once; the result is kept in .runner.
|
||||
ExecStartPre=/bin/sh -c '[ -f .runner ] || exec gitea-runner register --no-interactive --config /usr/lib/gitea-runner/config.yaml --instance "$GITEA_INSTANCE_URL"'
|
||||
ExecStart=/usr/bin/gitea-runner daemon --config /usr/lib/gitea-runner/config.yaml
|
||||
ExecStart=/usr/bin/gitea-runner -c /etc/gitea-runner/config.yaml daemon
|
||||
Restart=on-failure
|
||||
# A bit longer than runner.shutdown_timeout, so running jobs can finish on stop.
|
||||
TimeoutStopSec=35min
|
||||
RestartSec=10s
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
TimeoutStopSec=65min
|
||||
@@ -1,8 +0,0 @@
|
||||
# systemd-oomd for job containers, which podman runs in this slice: when jobs run the VM out of
|
||||
# memory, kill the job container responsible, before the VM thrashes on zram swap or the kernel's
|
||||
# OOM killer picks the runner or podman.
|
||||
[Slice]
|
||||
# Memory pressure above 60% for 30s: kill the container reclaiming the most memory.
|
||||
ManagedOOMMemoryPressure=kill
|
||||
# Swap over 90% full: kill the container using the most swap.
|
||||
ManagedOOMSwap=kill
|
||||
@@ -1,6 +0,0 @@
|
||||
# Load our firewall (/usr/lib/gitea-runner/firewall.nft) instead of /etc/sysconfig/nftables.conf.
|
||||
[Service]
|
||||
ExecStart=
|
||||
ExecStart=/usr/sbin/nft -f /usr/lib/gitea-runner/firewall.nft
|
||||
ExecReload=
|
||||
ExecReload=/usr/sbin/nft -f /usr/lib/gitea-runner/firewall.nft
|
||||
@@ -1,5 +1,6 @@
|
||||
# Daily at about 04:10, reboot into a downloaded update. Stop the runner first: it takes no new
|
||||
# jobs and lets running ones finish (runner.shutdown_timeout).
|
||||
# drain.conf stops the runner before an update reboots the machine, so running
|
||||
# jobs can finish first (TimeoutStopSec= of gitea-runner.service). A plain
|
||||
# reboot would stop the job containers at the same time as the runner.
|
||||
[Service]
|
||||
ExecStartPre=/bin/sh -c '/usr/lib/systemd/systemd-sysupdate pending || exit 0; systemctl stop gitea-runner'
|
||||
TimeoutStartSec=40min
|
||||
ExecStartPre=/bin/sh -c '/usr/lib/systemd/systemd-sysupdate pending || exit 0; systemctl stop gitea-runner.service'
|
||||
TimeoutStartSec=70min
|
||||
Reference in new issue
Block a user