Skip to content

Commit e519af9

Browse files
16020771602077
andauthored
feat: prefetching functionality via cronjob to keep client cache warm (#145)
Co-authored-by: 1602077 <jack.charlie.munday@cern.ch>
1 parent bbb6c68 commit e519af9

File tree

6 files changed

+81
-2
lines changed

6 files changed

+81
-2
lines changed

deployments/docker/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ RUN if [[ "${TARGETARCH}" == "amd64" ]]; then \
1515
https://ecsft.cern.ch/dist/cvmfs/cvmfs-${REL_VERSION}/cvmfs-libs-${PKG_VERSION}.el9.${FRIENDLY_ARCH_NAME}.rpm \
1616
https://ecsft.cern.ch/dist/cvmfs/cvmfs-${REL_VERSION}/cvmfs-fuse3-${PKG_VERSION}.el9.${FRIENDLY_ARCH_NAME}.rpm \
1717
https://ecsft.cern.ch/dist/cvmfs/cvmfs-config/cvmfs-config-default-latest.noarch.rpm \
18+
cronie \
1819
&& dnf --enablerepo=* clean all \
1920
&& rm -rf /var/cache/yum /var/cache/dnf
2021

deployments/helm/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@ Alternatively, a YAML file that specifies the values of the parameters can be pr
7878
| `nodeplugin.nodeSelector` | Pod node selector of the nodeplugin DaemonSet. |
7979
| `nodeplugin.tolerations` | Pod tolerations of the nodeplugin DaemonSet. |
8080
| `nodeplugin.affinity` | Pod node affinity of the nodeplugin DaemonSet. |
81+
| `nodeplugin.prefetcher.enabled` | Whether to enable CVMFS-CSI prefetching jobs. |
82+
| `nodeplugin.prefetcher.plugin.image.repository` | Default container image repository for CVMFS CSI prefetching jobs. |
83+
| `nodeplugin.prefetcher.plugin.image.tag` | Default container image tag for CVMFS CSI prefetching jobs. |
84+
| `nodeplugin.prefetcher.plugin.image.pullPolicy` | Pull policy for CVMFS CSI prefetching jobs. |
85+
| `nodeplugin.prefetcher.jobs` | Defintion of CVMFS-CSI prefetching tasks. |
8186
| `controllerplugin.name` | Component name for controller plugin component. Used as `component` label value and to generate Deployment name. |
8287
| `controllerplugin.podSecurityContext` | Pod-level security context for controllerplugin deployment. |
8388
| `controllerplugin.plugin.image.repository` | Container image repository for CVMFS CSI controller plugin. |

deployments/helm/cvmfs-csi/templates/_helpers.tpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this
1212
If release name contains chart name it will be used as a full name.
1313
*/}}
1414
{{- define "cvmfs-csi.fullname" -}}
15-
{{- if .Values.fullnameOverride -}}
16-
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
15+
{{- if .Values.fullNameOverride -}}
16+
{{- .Values.fullNameOverride | trunc 63 | trimSuffix "-" -}}
1717
{{- else -}}
1818
{{- $name := default .Chart.Name .Values.nameOverride -}}
1919
{{- if contains $name .Release.Name -}}

deployments/helm/cvmfs-csi/templates/nodeplugin-daemonset.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
{{- $defaultPrefetchImage := printf "%s:%s" $.Values.nodeplugin.prefetcher.image.repository ($.Values.nodeplugin.prefetcher.image.tag | default $.Chart.AppVersion) -}}
2+
---
13
kind: DaemonSet
24
apiVersion: apps/v1
35
metadata:
@@ -188,6 +190,28 @@ spec:
188190
{{- with .Values.nodeplugin.singlemount.resources }}
189191
resources: {{ toYaml . | nindent 12 }}
190192
{{- end }}
193+
{{- if .Values.nodeplugin.prefetcher.enabled }}
194+
{{- range .Values.nodeplugin.prefetcher.jobs }}
195+
- name: prefetcher-{{ .name }}
196+
image: {{ .image | default $defaultPrefetchImage }}
197+
# Launch crond with all debug flags (-x).
198+
command: ["/usr/sbin/crond", "-n", "-s", "-m", "off", "-x", "load,proc,sch"]
199+
securityContext:
200+
privileged: true
201+
volumeMounts:
202+
- name: autofs-root
203+
mountPath: /cvmfs
204+
mountPropagation: Bidirectional
205+
- name: prefetcher-{{ .name }}
206+
mountPath: "/etc/crontab"
207+
subPath: "cron.d"
208+
readOnly: true
209+
- name: prefetcher-{{ .name }}
210+
mountPath: "/etc/cvmfs-csi/prefetcher/entrypoint.sh"
211+
subPath: "entrypoint.sh"
212+
readOnly: true
213+
{{- end }}
214+
{{- end }}
191215
volumes:
192216
- name: socket-dir
193217
hostPath:
@@ -225,6 +249,13 @@ spec:
225249
- name: cvmfs-aliencache
226250
{{- toYaml .Values.cache.alien.volumeSpec | nindent 10 }}
227251
{{- end }}
252+
{{- if .Values.nodeplugin.prefetcher.enabled }}
253+
{{- range .Values.nodeplugin.prefetcher.jobs }}
254+
- name: prefetcher-{{ .name }}
255+
configMap:
256+
name: {{ include "cvmfs-csi.fullname" $ }}-prefetcher-{{ .name }}
257+
{{- end }}
258+
{{- end }}
228259
{{- with .Values.nodeplugin.extraVolumes }}
229260
{{- toYaml . | nindent 8 }}
230261
{{- end }}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{{ if .Values.nodeplugin.prefetcher.enabled }}
2+
{{- range .Values.nodeplugin.prefetcher.jobs }}
3+
---
4+
apiVersion: v1
5+
kind: ConfigMap
6+
metadata:
7+
name: {{ include "cvmfs-csi.fullname" $ }}-prefetcher-{{ .name }}
8+
labels:
9+
{{- include "cvmfs-csi.common.labels" $ | nindent 4 }}
10+
job: {{ .name }}
11+
data:
12+
# Entrypoint for cvmfs-csi prefetcher job mounted at
13+
# /etc/cvmfs-csi/prefetcher/entrypoint.sh.
14+
entrypoint.sh: {{ toYaml .script | nindent 4 }}
15+
16+
# Crontab configuration for entrypoint.sh.
17+
cron.d: |
18+
SHELL=/bin/bash
19+
PATH=/sbin:/bin:/usr/sbin:/usr/bin
20+
MAILTO=""
21+
{{ .schedule }} "bash /etc/cvmfs-csi/prefetcher/entrypoint.sh"
22+
{{- end }}
23+
{{- end }}

deployments/helm/cvmfs-csi/values.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,25 @@ nodeplugin:
105105
- name: etc-cvmfs-config-d
106106
mountPath: /etc/cvmfs/config.d
107107

108+
# Prefetch cvmfs repos on a schedule to keep client cache warm.
109+
prefetcher:
110+
enabled: false
111+
# Image defines the default image for prefetching jobs.
112+
# This can be optionally overridden per prefetch job.
113+
image:
114+
repository: registry.cern.ch/kubernetes/cvmfs-csi
115+
tag: "" # If no tag specified default to Chart AppVersion.
116+
pullPolicy: IfNotPresent
117+
# Jobs defines the pre-fetching tasks for keeping the client cache warm.
118+
jobs: {}
119+
# - name: example-job # Names should be unique and confirm to k8s resource naming specification.
120+
# # image: "" # Optional if not specified defaults to prefetcher.image. Image must include crond.
121+
# schedule: "* * * * *"
122+
# script: |-
123+
# #!/bin/bash
124+
# echo -e "prefetching atlas.cern.ch"
125+
# ls /cvmfs/atlas.cern.ch
126+
108127
# automount-runner image and container resources specs.
109128
singlemount:
110129
image:

0 commit comments

Comments
 (0)