-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Exposes the shared CEPH FS share to allow submission and retrieval of files
- Loading branch information
Showing
5 changed files
with
142 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
from kubernetes_asyncio.client.models import ( | ||
V1Volume, | ||
V1VolumeMount, | ||
V1PersistentVolumeClaimVolumeSource | ||
) | ||
|
||
|
||
class SwanHPCPodHookHandler(SwanSparkPodHookHandler): | ||
|
||
async def get_swan_user_pod(self): | ||
await super().get_swan_user_pod() | ||
|
||
if self._hpc_enabled(): | ||
self._init_hpc_volumes() | ||
|
||
return self.pod | ||
|
||
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' | ||
) | ||
) | ||
) | ||
|
||
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 | ||
) | ||
) | ||
|
||
def _hpc_enabled(self): | ||
""" | ||
Check if the HPC cluster access should be enabled for this user. | ||
This is True is they belong to a special egroup and the deployment | ||
is active | ||
""" | ||
|
||
user_roles = self.spawner.user_roles | ||
hpc_enabled = get_config('custom.hpc.enabled', False) | ||
hpc_role = get_config('custom.hpc.role', None) | ||
|
||
# TODO make this a form option? | ||
if hpc_enabled and hpc_role in user_roles: | ||
return True | ||
|
||
return False | ||
|
||
|
||
def spark_modify_pod_hook(spawner, pod): | ||
""" | ||
:param spawner: Swan Kubernetes Spawner | ||
:type spawner: swanspawner.SwanKubeSpawner | ||
:param pod: default pod definition set by jupyterhub | ||
:type pod: V1Pod | ||
:returns: dynamically customized pod specification for user session | ||
:rtype: V1Pod | ||
""" | ||
spark_pod_hook_handler = SwanHPCPodHookHandler(spawner, pod) | ||
return spark_pod_hook_handler.get_swan_user_pod() | ||
|
||
|
||
c.SwanKubeSpawner.modify_pod_hook = spark_modify_pod_hook |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{{ if .Values.hpc.enabled }} | ||
apiVersion: v1 | ||
kind: PersistentVolume | ||
metadata: | ||
name: hpc-volume | ||
namespace: {{ $.Release.Namespace }} | ||
spec: | ||
accessModes: | ||
- ReadWriteMany | ||
capacity: | ||
storage: 1Gi | ||
csi: | ||
driver: cephfs.csi.ceph.com | ||
volumeHandle: hpc-volume | ||
nodeStageSecretRef: | ||
name: hpc-volume-secret | ||
namespace: {{ $.Release.Namespace }} | ||
nodePublishSecretRef: | ||
name: hpc-volume-secret | ||
namespace: {{ $.Release.Namespace }} | ||
volumeAttributes: | ||
monitors: {{ $.Values.hpc.monitors }} | ||
rootPath: {{ $.Values.hpc.rootPath }} | ||
provisionVolume: "false" | ||
--- | ||
apiVersion: v1 | ||
kind: PersistentVolumeClaim | ||
metadata: | ||
name: hpc-volume-pvc | ||
namespace: {{ $.Release.Namespace }} | ||
spec: | ||
accessModes: | ||
- ReadWriteMany | ||
resources: | ||
requests: | ||
storage: 1Gi | ||
volumeName: hpc-volume | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters