Skip to content

Commit

Permalink
Merge pull request #3226 from yuvipanda/scheduledjob
Browse files Browse the repository at this point in the history
Run a cronJob every 30m to cleanup docker buildkit cache
  • Loading branch information
yuvipanda authored Feb 17, 2025
2 parents 22b05b5 + 014e118 commit 32f5667
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
34 changes: 34 additions & 0 deletions mybinder/templates/buildkit-pruner.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{{ if .Values.buildkitPruner.enabled }}
apiVersion: batch/v1
kind: CronJob
metadata:
name: build-cache-prune
spec:
schedule: {{ .Values.buildkitPruner.schedule | quote }}
# If the previous run is still going, replace it with our new one
concurrencyPolicy: Replace
jobTemplate:
spec:
template:
spec:
restartPolicy: OnFailure
volumes:
- name: dind-socket
hostPath:
path: /var/run/dind/docker.sock
containers:
- name: pruner
image: {{ .Values.buildkitPruner.image }}
env:
- name: DOCKER_HOST
value: "unix:///var/run/dind/docker.sock"
command:
- /bin/sh
- -c
- |
docker builder prune --force --all --keep-storage={{ .Values.buildkitPruner.buildkitCacheSize }} && \
docker system df
volumeMounts:
- name: dind-socket
mountPath: /var/run/dind/docker.sock
{{- end }}
9 changes: 8 additions & 1 deletion mybinder/values.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# values ref: https://github.com/yuvipanda/cryptnono/blob/main/cryptnono/values.yaml
cryptnono:
enabled: true
detectors:
Expand All @@ -10,6 +9,14 @@ cryptnono:
containerdHostPath: /run/containerd/containerd.sock
dockerHostPath: /run/dind/docker.sock

buildkitPruner:
enabled: true
# Use the same image as we use for dind
image: docker:27.5.1-dind
buildkitCacheSize: 300GB
# Run this every 30min
schedule: "*/30 * * * *"

registry:
enabled: false
replicas: 2
Expand Down

0 comments on commit 32f5667

Please sign in to comment.