stack.basicstack.de/apps/forgejo-runner/forgejo-runner-deployment.yaml
CTO 8dffba2c52 fix(forgejo-runner): pin to nodes with docker installed (DEV-498)
Rolling OS updates removed docker.io from all workers, breaking the
runner's hostPath mount of /var/run/docker.sock (type=Socket check).

- Install docker.io on all 5 worker nodes and enable the systemd unit.
- Label the nodes basicstack.de/docker=true so the dependency is explicit.
- Add nodeSelector to the Deployment so scheduling fails fast on
  non-labeled nodes instead of hanging in ContainerCreating.
- Document the node prerequisite in the README.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-08-16 20:15:16 +00:00

85 lines
2.4 KiB
YAML

apiVersion: apps/v1
kind: Deployment
metadata:
name: forgejo-runner
namespace: forgejo
spec:
replicas: 1
selector:
matchLabels:
app: forgejo-runner
template:
metadata:
labels:
app: forgejo-runner
spec:
serviceAccountName: forgejo-runner
nodeSelector:
basicstack.de/docker: "true"
containers:
- name: runner
image: code.forgejo.org/forgejo/runner:4.0.1
imagePullPolicy: IfNotPresent
securityContext:
runAsUser: 0
runAsGroup: 0
command:
- sh
- -c
- |
# Wait for Forgejo to be ready (external URL)
while ! wget -q -O- https://forgejo.basicstack.de/api/healthz > /dev/null 2>&1; do
echo "Waiting for Forgejo to be ready..."
sleep 5
done
# Re-register if the stored address is the internal cluster URL
if [ -f /data/.runner ] && grep -q "svc.cluster.local" /data/.runner; then
echo "Detected internal cluster URL in .runner — forcing re-registration with external URL"
rm /data/.runner
fi
# Register runner if not already registered
if [ ! -f /data/.runner ]; then
forgejo-runner register \
--no-interactive \
--instance https://forgejo.basicstack.de \
--token "$RUNNER_TOKEN" \
--name k3s-runner-1 \
--labels ubuntu-latest:docker://node:24-bookworm,ubuntu-22.04:docker://node:24-bookworm
fi
# Start runner
forgejo-runner daemon --config /etc/forgejo-runner/config.yaml
env:
- name: RUNNER_TOKEN
valueFrom:
secretKeyRef:
name: forgejo-runner-token
key: token
- name: DOCKER_HOST
value: unix:///var/run/docker.sock
volumeMounts:
- name: docker-sock
mountPath: /var/run/docker.sock
- name: runner-data
mountPath: /data
- name: config
mountPath: /etc/forgejo-runner
resources:
requests:
cpu: 100m
memory: 256Mi
limits:
cpu: "2"
memory: 2Gi
volumes:
- name: docker-sock
hostPath:
path: /var/run/docker.sock
type: Socket
- name: runner-data
emptyDir: {}
- name: config
configMap:
name: forgejo-runner-config