forgejo: let the deploy runner's init container write runner.ini; cap job memory; prune nightly
- init container runs as root: kubelet creates the hostPath /data as root:root and the runner image's default user cannot write runner.ini there. - container.options --memory 3g on both Pi runners: two concurrent jobs must not take the 8 GiB Pi (already using swap) to OOM. Caps the job container only. - forgejo-runner-prune CronJob: exited containers >48h, images >168h, builder cache >72h, so the single 917G / volume stops climbing.
This commit is contained in:
parent
1576240941
commit
741b9f13a7
4 changed files with 79 additions and 2 deletions
67
apps/base/forgejo/prune-cronjob.yaml
Normal file
67
apps/base/forgejo/prune-cronjob.yaml
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
---
|
||||
# Disk hygiene for the Pi's build host.
|
||||
#
|
||||
# Every push builds images on the Pi's own docker daemon (deploy-site's arm64
|
||||
# image, onionwire's ci build containers) and nothing ever removed them: the
|
||||
# single / volume sat at 76% (666G/917G) with weeks of exited job containers
|
||||
# and superseded image layers. On one volume that is a slow-motion outage.
|
||||
#
|
||||
# Prune keeps a week of images (a rollback window), 48h of exited containers,
|
||||
# and 72h of builder cache. It runs against the host socket, so it sees exactly
|
||||
# the containers the runners created.
|
||||
apiVersion: batch/v1
|
||||
kind: CronJob
|
||||
metadata:
|
||||
name: forgejo-runner-prune
|
||||
namespace: forgejo
|
||||
labels:
|
||||
app: forgejo-runner
|
||||
role: prune
|
||||
spec:
|
||||
schedule: "17 4 * * *"
|
||||
timeZone: "Etc/UTC"
|
||||
concurrencyPolicy: Forbid
|
||||
successfulJobsHistoryLimit: 3
|
||||
failedJobsHistoryLimit: 3
|
||||
jobTemplate:
|
||||
spec:
|
||||
backoffLimit: 1
|
||||
activeDeadlineSeconds: 1800
|
||||
template:
|
||||
spec:
|
||||
restartPolicy: Never
|
||||
nodeSelector:
|
||||
kubernetes.io/hostname: rpi
|
||||
tolerations:
|
||||
- key: dedicated
|
||||
operator: Equal
|
||||
value: network
|
||||
effect: PreferNoSchedule
|
||||
containers:
|
||||
- name: prune
|
||||
image: docker:27-cli
|
||||
imagePullPolicy: IfNotPresent
|
||||
command:
|
||||
- sh
|
||||
- -c
|
||||
- |
|
||||
set -e
|
||||
echo "== before"; docker system df
|
||||
docker container prune -f --filter until=48h || true
|
||||
docker image prune -af --filter until=168h || true
|
||||
docker builder prune -af --filter until=72h || true
|
||||
echo "== after"; docker system df
|
||||
volumeMounts:
|
||||
- name: docker-sock
|
||||
mountPath: /var/run/docker.sock
|
||||
resources:
|
||||
requests:
|
||||
cpu: 10m
|
||||
memory: 32Mi
|
||||
limits:
|
||||
memory: 128Mi
|
||||
volumes:
|
||||
- name: docker-sock
|
||||
hostPath:
|
||||
path: /var/run/docker.sock
|
||||
type: Socket
|
||||
Loading…
Reference in a new issue