Kubernetes Jupyter Server with Example Notebook and Persistent Storage

6/1/2020

I am trying to run a jupyter lab server Kubernetes deployment with a docker container that is set up to be a Jupiter server and that contains an example notebook (and Jupyter config) in the jupyter working directory. I would like to link this working directory to persistent storage, but when mounting the (Azure fileshare) volume to the container (as specified in the deployement.yaml file), the example notebook gets deleted (due to the empty storage being mounted). Is there any way to mount the container and keep the notebook and config?

The deployment file looks more or less (with some unimportant sections replaced by '...')as follows:

apiVersion: apps/v1beta2 kind: Deployment metadata: name: {{ include "api-chart.fullname" . }} labels: ... spec: replicas: 1 selector: matchLabels: app.kubernetes.io/name: {{ include "api-chart.name" . }} app.kubernetes.io/instance: {{ .Release.Name }} template: metadata: labels: ... volumes: - name: personal-volume azureFile: secretName: {{ .Values.sharedVolumes.personalSecretName }} shareName: personal readOnly: false containers: - name: {{ .Chart.Name }} image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" imagePullPolicy: {{ .Values.image.pullPolicy }} ports: - name: http containerPort: {{ .Values.service.targetPort }} protocol: TCP volumeMounts: - name: personal-volume mountPath: "/workspace" subPath: {{ .Values.username }} resources: ...

-- ejlouw
azure
jupyter-lab
kubernetes
kubernetes-helm

1 Answer

6/1/2020

You did not provide much information on how you're mounting the storage service. The first thing I would look is to make sure to use a StorageClass with the reclaim policy set to Retain.

kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: azurefile
provisioner: kubernetes.io/azure-file
mountOptions:
  - dir_mode=0777
  - file_mode=0777
  - uid=0
  - gid=0
  - mfsymlinks
  - cache=strict
parameters:
  skuName: Standard_LRS
reclaimPolicy: Retain
-- CSharpRocks
Source: StackOverflow