Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add persistent volume configuration to jupyter #78

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions dask/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,15 @@ their default values.
| `jupyter.tolerations` | Tolerations | `[]` |
| `jupyter.nodeSelector` | nodeSelector | `{}` |
| `jupyter.affinity` | Container affinity | `{}` |
| `jupyter.ingress.enabled` | Enable ingress controller resource | false |
| `jupyter.ingress.enabled` | Enable ingress controller resource | `false` |
| `jupyter.ingress.hostname` | Ingress resource hostnames | dask-ui.example.com |
| `jupyter.ingress.tls` | Ingress TLS configuration | false |
| `jupyter.ingress.tls` | Ingress TLS configuration | `false` |
| `jupyter.ingress.secretName` | Ingress TLS secret name | `dask-jupyter-tls` |
| `jupyter.ingress.annotations` | Ingress annotations configuration | null |
| `jupyter.persistent.enable` | Enable persistent storage | `false` |
| `jupyter.persistent.size` | Size of persistent storage | `1Gi` |
| `jupyter.persistent.path` | Path of Persistent Volume mount | `/home/jovyan` |


#### Jupyter Password

Expand Down
35 changes: 35 additions & 0 deletions dask/templates/dask-jupyter-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ spec:
spec:
imagePullSecrets:
{{- toYaml .Values.jupyter.image.pullSecrets | nindent 8 }}
{{- if (and .Values.jupyter.persistent.enable .Values.jupyter.persistent.setPermissions) }}
initContainers:
- name: {{ .Release.Name }}-jupyter-volume-permissions
image: busybox:1.31.1
command: ["sh", "-c", "chmod -Rv 755 /data/ && chown 1000:100 -R /data/"]
volumeMounts:
- name: jupyter-persistent
mountPath: /data
{{- end }}
containers:
- name: {{ template "dask.fullname" . }}-jupyter
image: "{{ .Values.jupyter.image.repository }}:{{ .Values.jupyter.image.tag }}"
Expand All @@ -43,6 +52,10 @@ spec:
volumeMounts:
- name: config-volume
mountPath: /usr/local/etc/jupyter
{{- if .Values.jupyter.persistent.enable }}
- name: jupyter-persistent
mountPath: {{ .Values.jupyter.persistent.path }}
{{- end }}
env:
- name: DASK_SCHEDULER_ADDRESS
value: {{ template "dask.fullname" . }}-scheduler:{{ .Values.scheduler.servicePort }}
Expand All @@ -53,6 +66,11 @@ spec:
- name: config-volume
configMap:
name: {{ template "dask.fullname" . }}-jupyter-config
{{- if .Values.jupyter.persistent.enable }}
- name: jupyter-persistent
persistentVolumeClaim:
claimName: {{ .Release.Name }}-jupyter-persistent
{{- end }}
{{- with .Values.jupyter.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
Expand All @@ -72,4 +90,21 @@ spec:
{{- if .Values.jupyter.serviceAccountName }}
serviceAccountName: {{ .Values.jupyter.serviceAccountName | quote }}
{{- end }}
{{- if .Values.jupyter.persistent.enable }}
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ .Release.Name }}-jupyter-persistent
spec:
{{- if (not (eq .Values.jupyter.persistent.storageClass "default")) }}
storageClassName: {{ .Values.jupyter.persistent.storageClass }}
{{- end }}
accessModes:
- ReadWriteOnce
resources:
requests:
storage: {{ .Values.jupyter.persistent.size }}
{{- end }}

{{- end }}
7 changes: 7 additions & 0 deletions dask/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,13 @@ jupyter:
servicePort: 80
# This hash corresponds to the password 'dask'
password: 'sha1:aae8550c0a44:9507d45e087d5ee481a5ce9f4f16f37a0867318c'
persistent:
enable: false
storageClass: "default"
size: 1Gi
path: /home/jovyan/
# run init container that will set the volume directory ownership to jovyan
setPermissions: true
env:
# - name: EXTRA_CONDA_PACKAGES
# value: "numba xarray -c conda-forge"
Expand Down