From 641ee72b8350df138389cdd3c4fee6537d849ea8 Mon Sep 17 00:00:00 2001 From: John McCann Cunniff Jr Date: Thu, 9 Jul 2020 22:54:09 -0400 Subject: [PATCH 1/4] Add persistent volume configuration to jupyter --- dask/templates/dask-jupyter-deployment.yaml | 26 +++++++++++++++++++++ dask/values.yaml | 5 ++++ 2 files changed, 31 insertions(+) diff --git a/dask/templates/dask-jupyter-deployment.yaml b/dask/templates/dask-jupyter-deployment.yaml index 38b30ba..20eeb4d 100644 --- a/dask/templates/dask-jupyter-deployment.yaml +++ b/dask/templates/dask-jupyter-deployment.yaml @@ -43,6 +43,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 }} @@ -53,6 +57,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 }} @@ -72,4 +81,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 }} diff --git a/dask/values.yaml b/dask/values.yaml index 0be80b1..fb7af95 100644 --- a/dask/values.yaml +++ b/dask/values.yaml @@ -97,6 +97,11 @@ jupyter: servicePort: 80 # This hash corresponds to the password 'dask' password: 'sha1:aae8550c0a44:9507d45e087d5ee481a5ce9f4f16f37a0867318c' + persistent: + enable: false + storageClass: "default" + size: 1Gi + path: /home/jovyan/persistent env: # - name: EXTRA_CONDA_PACKAGES # value: "numba xarray -c conda-forge" From a9bc79401fe8a810e1d6305ea218a4c0eb653694 Mon Sep 17 00:00:00 2001 From: John McCann Cunniff Jr Date: Sat, 11 Jul 2020 17:59:40 -0400 Subject: [PATCH 2/4] FIX persistent directory permissions with initContainer --- dask/templates/dask-jupyter-deployment.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/dask/templates/dask-jupyter-deployment.yaml b/dask/templates/dask-jupyter-deployment.yaml index 20eeb4d..ba07c24 100644 --- a/dask/templates/dask-jupyter-deployment.yaml +++ b/dask/templates/dask-jupyter-deployment.yaml @@ -28,6 +28,15 @@ spec: spec: imagePullSecrets: {{- toYaml .Values.jupyter.image.pullSecrets | nindent 8 }} + {{- if .Values.jupyter.persistent.enable }} + initContainers: + - name: {{ .Release.Name }}-jupyter-volume-permissions + image: busybox:1.31.1 + command: ["sh", "-c", "chmod -Rv 777 /data/ && chown 0: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 }}" From e256a14dc7b10695b7c6267e06d5d9f3f84e70b2 Mon Sep 17 00:00:00 2001 From: John McCann Cunniff Jr Date: Mon, 13 Jul 2020 15:45:33 -0400 Subject: [PATCH 3/4] ADD optional initContainer, 755 permissions and default pv path to jovyan home --- dask/templates/dask-jupyter-deployment.yaml | 4 ++-- dask/values.yaml | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/dask/templates/dask-jupyter-deployment.yaml b/dask/templates/dask-jupyter-deployment.yaml index ba07c24..b7d9ed2 100644 --- a/dask/templates/dask-jupyter-deployment.yaml +++ b/dask/templates/dask-jupyter-deployment.yaml @@ -28,11 +28,11 @@ spec: spec: imagePullSecrets: {{- toYaml .Values.jupyter.image.pullSecrets | nindent 8 }} - {{- if .Values.jupyter.persistent.enable }} + {{- 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 777 /data/ && chown 0:100 -R /data/"] + command: ["sh", "-c", "chmod -Rv 755 /data/ && chown 1000:100 -R /data/"] volumeMounts: - name: jupyter-persistent mountPath: /data diff --git a/dask/values.yaml b/dask/values.yaml index fb7af95..354fed6 100644 --- a/dask/values.yaml +++ b/dask/values.yaml @@ -101,7 +101,9 @@ jupyter: enable: false storageClass: "default" size: 1Gi - path: /home/jovyan/persistent + 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" From 17c9aad86bc361cd94c07b847916a3d90197c52e Mon Sep 17 00:00:00 2001 From: John McCann Cunniff Jr Date: Mon, 13 Jul 2020 16:01:40 -0400 Subject: [PATCH 4/4] ADD persistent volume options to README --- dask/README.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/dask/README.md b/dask/README.md index 11ca206..dfd891d 100644 --- a/dask/README.md +++ b/dask/README.md @@ -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