2026-09-11 22:34:33 -04:00
|
|
|
apiVersion: v1
|
|
|
|
|
kind: PersistentVolumeClaim
|
|
|
|
|
metadata:
|
|
|
|
|
name: forgejo-runner-amd64
|
|
|
|
|
namespace: forgejo
|
|
|
|
|
spec:
|
|
|
|
|
accessModes:
|
|
|
|
|
- ReadWriteOnce
|
|
|
|
|
storageClassName: local-path
|
|
|
|
|
resources:
|
|
|
|
|
requests:
|
|
|
|
|
storage: 20Gi
|
|
|
|
|
---
|
|
|
|
|
apiVersion: apps/v1
|
|
|
|
|
kind: Deployment
|
|
|
|
|
metadata:
|
|
|
|
|
name: forgejo-runner-amd64
|
|
|
|
|
namespace: forgejo
|
|
|
|
|
labels:
|
|
|
|
|
app: forgejo-runner
|
|
|
|
|
arch: amd64
|
|
|
|
|
spec:
|
2026-09-18 23:36:52 -04:00
|
|
|
replicas: 1
|
2026-09-11 22:34:33 -04:00
|
|
|
selector:
|
|
|
|
|
matchLabels:
|
|
|
|
|
app: forgejo-runner
|
|
|
|
|
arch: amd64
|
|
|
|
|
strategy:
|
|
|
|
|
type: Recreate
|
|
|
|
|
template:
|
|
|
|
|
metadata:
|
|
|
|
|
labels:
|
|
|
|
|
app: forgejo-runner
|
|
|
|
|
arch: amd64
|
|
|
|
|
spec:
|
|
|
|
|
nodeSelector:
|
|
|
|
|
kubernetes.io/hostname: siriussec
|
|
|
|
|
securityContext:
|
2026-11-27 05:42:39 +00:00
|
|
|
# Group on the data volume; matches the runner's gid so the cache dir
|
|
|
|
|
# stays writable even before fix-data-perms re-owns it.
|
|
|
|
|
fsGroup: 1000
|
2026-09-11 22:34:33 -04:00
|
|
|
initContainers:
|
|
|
|
|
- name: register
|
2026-09-18 23:25:19 -04:00
|
|
|
image: alex3305/forgejo-runner-dind:13-dind-rootless-28
|
2026-09-11 22:34:33 -04:00
|
|
|
imagePullPolicy: IfNotPresent
|
|
|
|
|
command:
|
|
|
|
|
- sh
|
|
|
|
|
- -c
|
|
|
|
|
- |
|
|
|
|
|
set -e
|
|
|
|
|
if [ -s /data/runner.ini ]; then
|
|
|
|
|
echo already-registered
|
|
|
|
|
exit 0
|
|
|
|
|
fi
|
|
|
|
|
forgejo-runner register --no-interactive \
|
|
|
|
|
--instance https://forgejo.siriusdevops.com \
|
|
|
|
|
--token "$RUNNER_TOKEN" \
|
|
|
|
|
--name siriussec-amd64 \
|
|
|
|
|
--labels 'docker-amd64:docker://node:20-bullseye,amd64:docker://node:20-bullseye' \
|
|
|
|
|
--config /config/config.toml
|
|
|
|
|
env:
|
|
|
|
|
- name: RUNNER_TOKEN
|
|
|
|
|
valueFrom:
|
|
|
|
|
secretKeyRef:
|
|
|
|
|
name: forgejo-runner-amd64-token
|
|
|
|
|
key: token
|
|
|
|
|
volumeMounts:
|
|
|
|
|
- name: config-toml
|
|
|
|
|
mountPath: /config/config.toml
|
|
|
|
|
subPath: amd64.toml
|
|
|
|
|
- name: data
|
|
|
|
|
mountPath: /data
|
2026-11-27 05:42:39 +00:00
|
|
|
# The runner container runs as uid 1000 (the image's own user) and needs
|
|
|
|
|
# to read its registration and write the actions cache on this PVC.
|
|
|
|
|
# Both were created by root before this change, so re-own them once per
|
|
|
|
|
# start. Scoped on purpose: a recursive chown of the whole PVC would
|
|
|
|
|
# walk the dind data-root (tens of GB on the Pi).
|
|
|
|
|
- name: fix-data-perms
|
|
|
|
|
image: docker:27-dind
|
|
|
|
|
imagePullPolicy: IfNotPresent
|
|
|
|
|
securityContext:
|
2026-11-27 00:48:37 -05:00
|
|
|
# root is needed for exactly one thing: chown of the PVC.
|
|
|
|
|
runAsUser: 0
|
2026-11-27 05:42:39 +00:00
|
|
|
command:
|
|
|
|
|
- sh
|
|
|
|
|
- -c
|
|
|
|
|
- |
|
|
|
|
|
set -e
|
|
|
|
|
chown 1000:1000 /data
|
|
|
|
|
[ -f /data/runner.ini ] && chown 1000:1000 /data/runner.ini
|
|
|
|
|
[ -d /data/cache ] && chown -R 1000:1000 /data/cache
|
|
|
|
|
true
|
|
|
|
|
volumeMounts:
|
|
|
|
|
- name: data
|
|
|
|
|
mountPath: /data
|
2026-09-11 22:34:33 -04:00
|
|
|
containers:
|
|
|
|
|
- name: dind
|
|
|
|
|
image: docker:27-dind
|
|
|
|
|
imagePullPolicy: IfNotPresent
|
2026-09-11 22:37:09 -04:00
|
|
|
command:
|
|
|
|
|
- sh
|
|
|
|
|
- -c
|
|
|
|
|
- |
|
2026-11-16 20:41:20 -05:00
|
|
|
# A reboot restarts this container inside the same pod, so the
|
|
|
|
|
# dind-run emptyDir keeps the previous daemon's pid file. dockerd
|
|
|
|
|
# then refuses to start ("process with PID N is still running")
|
|
|
|
|
# and the runner crashloops until the pod is deleted by hand.
|
|
|
|
|
# Clear the stale runtime state first so a restart is
|
|
|
|
|
# self-healing.
|
|
|
|
|
rm -f /var/run/docker.pid /var/run/docker.sock
|
2026-11-17 15:04:00 -05:00
|
|
|
# Forgejo's container registry is reached in-cluster as a plain
|
|
|
|
|
# HTTP ClusterIP (forgejo.forgejo.svc.cluster.local:3000).
|
|
|
|
|
# Docker only treats 127.0.0.0/8 as insecure by default, so
|
|
|
|
|
# without this a workflow that logs in to or pushes to that host
|
|
|
|
|
# dies with "server gave HTTP response to HTTPS client".
|
|
|
|
|
# The public hostname stays HTTPS via Cloudflare, which 413s
|
|
|
|
|
# layer uploads >~100MB, so in-cluster pushes are the reliable
|
|
|
|
|
# path for large images.
|
|
|
|
|
dockerd --host=unix:///var/run/docker.sock --tls=false --mtu=1420 \
|
2026-11-27 05:42:39 +00:00
|
|
|
--group 1000 \
|
2026-11-17 15:04:00 -05:00
|
|
|
--insecure-registry=forgejo.forgejo.svc.cluster.local:3000 &
|
2026-09-11 22:37:09 -04:00
|
|
|
pid=$!
|
|
|
|
|
i=0
|
|
|
|
|
while [ "$i" -lt 30 ]; do
|
2026-11-27 05:42:39 +00:00
|
|
|
# Readiness only: ownership is set by `dockerd --group 1000`
|
|
|
|
|
# (socket 0660 root:1000) so the runner's uid 1000 can use it.
|
2026-09-11 22:37:09 -04:00
|
|
|
if [ -S /var/run/docker.sock ]; then
|
|
|
|
|
break
|
|
|
|
|
fi
|
|
|
|
|
i=$((i+1))
|
|
|
|
|
sleep 1
|
|
|
|
|
done
|
|
|
|
|
wait "$pid"
|
2026-09-11 22:34:33 -04:00
|
|
|
securityContext:
|
2026-11-27 05:42:39 +00:00
|
|
|
# Cannot be dropped on these nodes. Verified live 2026-11-27
|
|
|
|
|
# (card t_2bbe34a8): a pod with `privileged: false` cannot host a
|
|
|
|
|
# container runtime in this cluster, at three independent points:
|
|
|
|
|
# 1. dind's own containers need CAP_SYS_ADMIN: runc mounts a fresh
|
|
|
|
|
# procfs per container, and without the capability the daemon
|
|
|
|
|
# fails with `mount src=proc ... operation not permitted`.
|
|
|
|
|
# 2. kubelet mounts /sys/fs/cgroup read-only for non-privileged
|
|
|
|
|
# pods, so dockerd cannot create /sys/fs/cgroup/docker
|
|
|
|
|
# ("read-only file system") and no container can start.
|
|
|
|
|
# 3. rootless dind (docker:27-dind-rootless) dies earlier: a
|
|
|
|
|
# nested user namespace cannot mount procfs because the pod's
|
|
|
|
|
# /proc is masked (kernel mount_too_revealing), and
|
|
|
|
|
# procMount: Unmasked is only accepted with hostUsers: false —
|
|
|
|
|
# where newuidmap cannot map subuids and /dev/net/tun cannot be
|
|
|
|
|
# created (mknod is refused in a userns pod, and hostPath is
|
|
|
|
|
# forbidden under Pod Security baseline).
|
|
|
|
|
# What this file *does* remove: the runner's uid 0, the privileged
|
|
|
|
|
# flag on CI job containers (runner configmap), and the old
|
|
|
|
|
# chmod-666 socket race.
|
2026-09-11 22:34:33 -04:00
|
|
|
privileged: true
|
|
|
|
|
volumeMounts:
|
|
|
|
|
- name: dind-run
|
|
|
|
|
mountPath: /var/run
|
|
|
|
|
- name: data
|
|
|
|
|
mountPath: /var/lib/docker
|
|
|
|
|
subPath: docker
|
|
|
|
|
resources:
|
|
|
|
|
requests:
|
|
|
|
|
cpu: 200m
|
|
|
|
|
memory: 512Mi
|
|
|
|
|
limits:
|
2026-11-22 05:42:52 -05:00
|
|
|
# Hard ceiling on CI burst draw: siriussec is a laptop on a 15 W
|
|
|
|
|
# USB-C supply, and dind previously had no CPU limit, so one
|
|
|
|
|
# Android/x86_64 build could pin all 8 threads (~25 W package)
|
|
|
|
|
# and drain the battery faster than the adapter refills it.
|
|
|
|
|
cpu: 3
|
2026-09-11 22:34:33 -04:00
|
|
|
memory: 4Gi
|
|
|
|
|
- name: runner
|
|
|
|
|
image: code.forgejo.org/forgejo/runner:5.0.1
|
|
|
|
|
imagePullPolicy: IfNotPresent
|
2026-10-26 17:38:04 -04:00
|
|
|
securityContext:
|
2026-11-27 00:48:37 -05:00
|
|
|
# The image's own user. No root needed: the dind socket is 0660
|
|
|
|
|
# root:1000 (`dockerd --group 1000`) and fix-data-perms owns the PVC
|
|
|
|
|
# as 1000:1000, so the actions cache is writable.
|
|
|
|
|
runAsUser: 1000
|
|
|
|
|
runAsGroup: 1000
|
2026-09-11 22:34:33 -04:00
|
|
|
command:
|
|
|
|
|
- sh
|
|
|
|
|
- -c
|
|
|
|
|
- |
|
|
|
|
|
set -e
|
|
|
|
|
i=0
|
|
|
|
|
while [ "$i" -lt 60 ]; do
|
2026-09-11 22:37:09 -04:00
|
|
|
if [ -S /var/run/docker.sock ]; then
|
2026-09-11 22:34:33 -04:00
|
|
|
break
|
|
|
|
|
fi
|
|
|
|
|
i=$((i+1))
|
|
|
|
|
sleep 2
|
|
|
|
|
done
|
|
|
|
|
exec forgejo-runner --config /config/config.toml daemon
|
|
|
|
|
env:
|
|
|
|
|
- name: DOCKER_HOST
|
2026-09-11 22:37:09 -04:00
|
|
|
value: unix:///var/run/docker.sock
|
2026-09-11 22:34:33 -04:00
|
|
|
volumeMounts:
|
|
|
|
|
- name: config-toml
|
|
|
|
|
mountPath: /config/config.toml
|
|
|
|
|
subPath: amd64.toml
|
|
|
|
|
- name: data
|
|
|
|
|
mountPath: /data
|
2026-09-11 22:37:09 -04:00
|
|
|
- name: dind-run
|
|
|
|
|
mountPath: /var/run
|
2026-09-11 22:34:33 -04:00
|
|
|
resources:
|
|
|
|
|
requests:
|
|
|
|
|
cpu: 50m
|
|
|
|
|
memory: 128Mi
|
|
|
|
|
limits:
|
|
|
|
|
memory: 512Mi
|
|
|
|
|
volumes:
|
|
|
|
|
- name: config-toml
|
|
|
|
|
configMap:
|
|
|
|
|
name: forgejo-runner-config
|
|
|
|
|
- name: data
|
|
|
|
|
persistentVolumeClaim:
|
|
|
|
|
claimName: forgejo-runner-amd64
|
|
|
|
|
- name: dind-run
|
|
|
|
|
emptyDir: {}
|