diff --git a/mybinder/templates/buildkit-pruner.yaml b/mybinder/templates/buildkit-pruner.yaml new file mode 100644 index 000000000..de016a6f8 --- /dev/null +++ b/mybinder/templates/buildkit-pruner.yaml @@ -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 }} diff --git a/mybinder/values.yaml b/mybinder/values.yaml index 06128fb5b..387db72ac 100644 --- a/mybinder/values.yaml +++ b/mybinder/values.yaml @@ -1,4 +1,3 @@ -# values ref: https://github.com/yuvipanda/cryptnono/blob/main/cryptnono/values.yaml cryptnono: enabled: true detectors: @@ -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