213 lines
8.3 KiB
YAML
213 lines
8.3 KiB
YAML
---
|
|
# 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: forgejo
|
|
labels:
|
|
app: forgejo-runner
|
|
arch: arm64
|
|
role: deploy
|
|
spec:
|
|
replicas: 1
|
|
selector:
|
|
matchLabels:
|
|
app: forgejo-runner
|
|
role: deploy
|
|
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 every entry the runner writes as uid 1000 — runner.ini,
|
|
# cache/ and the actions cache .cache/act/ where it clones the
|
|
# action repos (a stale root-owned pack file there fails the job
|
|
# with "permission denied"). Skip `docker`, the dind data-root,
|
|
# which stays root-owned: a recursive chown of that tree is tens
|
|
# of GB on the Pi. The owner check makes repeat starts cheap.
|
|
for d in /data/* /data/.[!.]*; do
|
|
if [ ! -e "$d" ]; then continue; fi
|
|
if [ "$d" = /data/docker ]; then continue; fi
|
|
if [ "$(stat -c %u "$d")" != 1000 ]; 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.
|
|
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: {}
|