Skip to content

Commit

Permalink
swan-cern: adapt to allow multiple ceph mounts for HPC integration
Browse files Browse the repository at this point in the history
  • Loading branch information
diocas committed Mar 28, 2024
1 parent eebe3d2 commit 8d4b43d
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 32 deletions.
27 changes: 14 additions & 13 deletions swan-cern/files/swan_computing_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,23 +386,24 @@ def _init_hpc_volumes(self):
"""
Mount the CEPHFS share of HPC in the user container
"""
self.pod.spec.volumes.append(
V1Volume(
name='hpc-volume',
persistent_volume_claim=V1PersistentVolumeClaimVolumeSource(
claim_name='hpc-volume-pvc'
for i, volume in enumerate(get_config('custom.hpc.cephVolumes', [])):
self.pod.spec.volumes.append(
V1Volume(
name=f'hpc-volume-{i}',
persistent_volume_claim=V1PersistentVolumeClaimVolumeSource(
claim_name=f'hpc-volume-{i}-pvc'
)
)
)
)

notebook_container = self._get_pod_container('notebook')
mount_path = get_config('custom.hpc.mountPath', '/hpc')
notebook_container.volume_mounts.append(
V1VolumeMount(
name='hpc-volume',
mount_path=mount_path
notebook_container = self._get_pod_container('notebook')
mount_path = volume['mountPath'] if 'mountPath' in volume else f'/hpc-{i}'
notebook_container.volume_mounts.append(
V1VolumeMount(
name=f'hpc-volume-{i}',
mount_path=mount_path
)
)
)

def _hpc_enabled(self):
"""
Expand Down
10 changes: 6 additions & 4 deletions swan-cern/templates/secrets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ data:
sparkk8s.cred: {{ (required "helm --set swanCern.secrets.sparkk8s.cred=$(base64 -w0 <path>)" .Values.swanCern.secrets.sparkk8s.cred) }}
---
{{ if .Values.hpc.enabled }}
{{- range $i, $volume := .Values.hpc.cephVolumes }}
apiVersion: v1
kind: Secret
metadata:
name: hpc-volume-secret
namespace: {{ .Release.Namespace }}
name: hpc-volume-{{ $i }}-secret
namespace: {{ $.Release.Namespace }}
data:
userKey: {{ $.Values.hpc.user.key }}
userID: {{ $.Values.hpc.user.id }}
userKey: {{ $volume.user.key }}
userID: {{ $volume.user.id }}
{{ end }}
{{ end }}
18 changes: 10 additions & 8 deletions swan-cern/templates/storageclasses.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{{ if .Values.hpc.enabled }}
{{- range $i, $volume := .Values.hpc.cephVolumes }}
apiVersion: v1
kind: PersistentVolume
metadata:
name: hpc-volume
name: hpc-volume-{{ $i }}
namespace: {{ $.Release.Namespace }}
spec:
accessModes:
Expand All @@ -11,28 +12,29 @@ spec:
storage: 1Gi
csi:
driver: cephfs.csi.ceph.com
volumeHandle: hpc-volume
volumeHandle: hpc-volume-{{ $i }}
nodeStageSecretRef:
name: hpc-volume-secret
name: hpc-volume-{{ $i }}-secret
namespace: {{ $.Release.Namespace }}
nodePublishSecretRef:
name: hpc-volume-secret
name: hpc-volume-{{ $i }}-secret
namespace: {{ $.Release.Namespace }}
volumeAttributes:
monitors: {{ $.Values.hpc.monitors }}
rootPath: {{ $.Values.hpc.rootPath }}
monitors: {{ $volume.monitors }}
rootPath: {{ $volume.rootPath }}
provisionVolume: "false"
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: hpc-volume-pvc
name: hpc-volume-{{ $i }}-pvc
namespace: {{ $.Release.Namespace }}
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 1Gi
volumeName: hpc-volume
volumeName: hpc-volume-{{ $i }}
{{- end }}
{{- end }}
15 changes: 8 additions & 7 deletions swan-cern/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ hpc: &hpc
# jupyterhub.custom.hpc references that config
# like below
enabled: false
# monitors:
# rootPath:
# mountPath:
# role:
# user:
# id:
# key:
# required_role:
# cephVolumes:
# - monitors:
# rootPath:
# mountPath:
# user:
# id:
# key:

swan:
cvmfs:
Expand Down

0 comments on commit 8d4b43d

Please sign in to comment.