--- # Second Forgejo Actions runner instance on the Pi, declaring ONLY the # `deploy-arm64` label. # # Why: the Pi's original runner (forgejo-runner-arm64) serves every # `runs-on: docker` job in the instance, so a long onionwire `ci` build (Rust, # 20-40 min) holds the only `docker` slot and any site deploy queued behind it # waits indefinitely - that is exactly how siriusgrowthsolutions.com sat on a # stale page while deploy-site runs stayed in `waiting` (runs 1163/1164). # # Deploys are not CPU-bound the way CI is, so a separate runner instance is # cheap; the labels are disjoint in both directions, so neither class can # starve the other. Keep capacity 1: a deploy must not overlap itself (the Pi # registry tag :latest and the k8s restartedAt patch are last-writer-wins). # # Since the arm64 dind cutover this runner has its own in-pod daemon too, so a # deploy no longer shares the Pi's host Docker with anything. apiVersion: apps/v1 kind: Deployment metadata: name: forgejo-runner-deploy-arm64 namespace: ci-runners labels: app: forgejo-runner arch: arm64 role: deploy spec: replicas: 1 selector: matchLabels: app: forgejo-runner role: deploy # RWO PVC: never two pods on one data-root. Consequence to know before you # touch this template: a rollout SIGKILLs the job container of any run in # flight, and Forgejo then reports that run as a plain failure with the log # cut off mid-step (no `exitcode` line) — seen as a 14 min "failing" push on # sirius/sirius-growth, card t_29249bf0. Land template changes while the # runner is idle. strategy: type: Recreate template: metadata: labels: app: forgejo-runner arch: arm64 role: deploy spec: nodeSelector: kubernetes.io/hostname: rpi tolerations: - key: dedicated operator: Equal value: network effect: PreferNoSchedule # Group on the data volume, matching the runner gid (see fix-data-perms). securityContext: fsGroup: 1000 initContainers: # Registration guard, NOT a registration step. The runner's identity # (`runner.ini`, action_runner id 14 / uuid a41aad73-…) is copied onto # the PVC from the Pi host before the first start. The previous version # of this init container registered a *new* runner whenever the file was # missing, which burns a single-use token and leaves a second # action_runner row polling under a new uuid. Refuse instead: a missing # file is an operator error, not something to paper over. - name: require-registration image: code.forgejo.org/forgejo/runner:5.0.1 imagePullPolicy: IfNotPresent securityContext: runAsUser: 0 command: - sh - -c - | set -e if [ ! -s /data/runner.ini ]; then echo "runner.ini missing on the data PVC — refusing to register a second uuid" >&2 echo "restore it: ssh rpi sudo install -m600 -o root -g root /opt/siriusdevops/runner-deploy/data/runner.ini /opt/local-path-provisioner/forgejo-runner-deploy-arm64-dind/runner.ini" >&2 exit 1 fi echo "registration present: $(grep -o '\"uuid\": \"[^\"]*\"' /data/runner.ini)" volumeMounts: - name: data mountPath: /data # 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. - name: fix-data-perms image: docker:27-dind imagePullPolicy: IfNotPresent securityContext: runAsUser: 0 command: - sh - -c - | set -e chown 1000:1000 /data # Re-own the trees the runner itself writes: runner.ini, the act # cache (cache/) and the action-repo checkout cache (.cache/act/). # The re-own MUST be recursive. A top-level owner check is exactly # what let this through once: /data/.cache was already 1000 while # the git packs inside it were still root:root from the pre-uid-1000 # runner, so the guard skipped the one file that mattered and every # job died in actions/checkout before any step ran: # open /data/.cache/act/actions-checkout@v4/.git/objects/pack/ # pack-.pack: permission denied # (card t_29249bf0: 3 s red X, zero steps.) A few thousand small # files; the dind data-root (/data/docker, tens of GB) stays # root-owned and is deliberately not walked. for d in /data/cache /data/.cache /data/runner.ini; do if [ -e "$d" ]; then chown -R 1000:1000 "$d"; fi done true volumeMounts: - name: data mountPath: /data containers: - name: dind image: docker:27-dind imagePullPolicy: IfNotPresent command: - sh - -c - | # --insecure-registry: the Pi registry is plain HTTP on the WG # hub IP. Docker only treats 127.0.0.0/8 as insecure by default, # so without this `docker push 10.10.0.1:5000/...` from a job # fails with "server gave HTTP response to HTTPS client". dockerd --host=unix:///var/run/docker.sock --tls=false --mtu=1420 \ --group 1000 \ --insecure-registry=10.10.0.1:5000 & pid=$! i=0 while [ "$i" -lt 30 ]; do # Readiness only: ownership is set by `dockerd --group 1000`. if [ -S /var/run/docker.sock ]; then break fi i=$((i+1)) sleep 1 done wait "$pid" securityContext: # Cannot be dropped on these nodes: see the long note in # runner-amd64.yaml (procfs without CAP_SYS_ADMIN, /sys/fs/cgroup # mounted read-only by kubelet, rootless dind blocked by masked # /proc + missing /dev/net/tun). Verified live 2026-11-27. # Lives in namespace ci-runners (enforce: privileged), # not forgejo (enforce: baseline) — see runner-amd64.yaml. privileged: true volumeMounts: - name: dind-run mountPath: /var/run - name: data mountPath: /var/lib/docker subPath: docker resources: # Deliberately smaller than the shared runner's 4Gi. A deploy is two # nginx-based site images (112-143 MB each) plus buildx's # docker-container driver and one `--platform linux/amd64` cross # build under qemu; nothing like the Rust ci.yml job that peaked at # 3.10 GiB. The Pi has 7.0 GiB available and capacity 1 per runner # bounds each runner but nothing bounds both: 4Gi + 2Gi limits leave # ~1 GiB for kubelet/Cilium/cloudflared/host Docker even if a CI run # and a deploy overlap, and an OOM here fails one deploy visibly. # (A 4Gi deploy limit would let two runners claim every byte.) requests: cpu: 100m memory: 256Mi limits: memory: 2Gi - name: runner image: code.forgejo.org/forgejo/runner:5.0.1 imagePullPolicy: IfNotPresent securityContext: # Image default user. The dind socket is 0660 root:1000 # (`dockerd --group 1000`) and fix-data-perms owns the PVC as # 1000:1000, so no root is needed here. runAsUser: 1000 runAsGroup: 1000 command: - sh - -c - | set -e i=0 while [ "$i" -lt 60 ]; do if [ -S /var/run/docker.sock ]; then break fi i=$((i+1)) sleep 2 done exec forgejo-runner --config /config/config.toml daemon env: - name: DOCKER_HOST value: unix:///var/run/docker.sock volumeMounts: - name: config-toml mountPath: /config/config.toml subPath: deploy-arm64.toml - name: data mountPath: /data - name: dind-run mountPath: /var/run resources: requests: cpu: 50m memory: 128Mi limits: memory: 512Mi volumes: - name: config-toml configMap: name: forgejo-runner-config - name: data persistentVolumeClaim: claimName: forgejo-runner-deploy-arm64-dind - name: dind-run emptyDir: {}