jupyterhub / zero-to-jupyterhub-k8s

Helm Chart & Documentation for deploying JupyterHub on Kubernetes
https://zero-to-jupyterhub.readthedocs.io
Other
1.56k stars 799 forks source link

ExtraVolumes and ExtraVolumeMounts for Configmap not working with singleuser #3579

Open duc-dn opened 1 day ago

duc-dn commented 1 day ago

Hi, I want to mount a configmap sparkmagic config to singleuser pod but it doesn't work for me. I created a configmap file, tried to mount it into a hub pod, and found the config file of spark magic. However, in singleuser pod, I realized that it doesn't be mounted singleuser in values.yaml:

singleuser:
  storage:
    extraVolumes:
      - name: spark-magic-config
        configMap:
          name: spark-magic-config
    extraVolumeMounts:
      - name: spark-magic-config
        mountPath: /home/config.json
        subPath: config.json

hub in values.yaml:

hub:
  extraVolumes:
    - name: spark-magic-config
      configMap:
        name: spark-magic-config
  extraVolumeMounts:
    - name: spark-magic-config
      mountPath: /home/config.json
      subPath: config.json

image And I described notebook pod, it's none image

Can you share with me some recommendations for this problem?

consideRatio commented 1 day ago

Didnt you get a schema validation error from this? Are you using a packaged chart (recommended) or one from this git repository directly (not with a schema without manual action).

It seems singleuser.extraVolumes wasn't defined as i though, but you can do hub.config.KubeSpawner.extra_volumes and .extra_volume_mounts i think. This is a kubespawner config, and singleuser. typically is just configuring kubespawner as well as you can do directly via hub.config.KubeSpawner.

duc-dn commented 1 day ago

Thanks @consideRatio

Didnt you get a schema validation error from this? Are you using a packaged chart (recommended) or one from this git repository directly (not with a schema without manual action). I used chart in this repo, and added sparkmagicConfig in singleuser in values.yaml. After I added define for this config in values.schema.json

"sparkmagicConfig": {
"type": "object",
"description": "Configuration for Sparkmagic integration",
"additionalProperties": true
}

Moreover, I also added configmap.yaml in singleuser folder

apiVersion: v1
kind: ConfigMap
metadata:
name: spark-magic-config
data:
config.json: |
{{ .Values.singleuser.sparkmagicConfig | toJson | nindent 4 }}

When installing chart, configmap was created and mounted to hub pod. But with singleuser pod, it wasn't be mounted


It seems singleuser.extraVolumes wasn't defined as i though, but you can do hub.config.KubeSpawner.extra_volumes and .extra_volume_mounts i think. This is a kubespawner config, and singleuser. typically is just configuring kubespawner as well as you can do directly via hub.config.KubeSpawner.

I tried this way. However, when single pod started, spark-magic-config in configmap wasn't be mounted

hub: 
  revisionHistoryLimit:
  config:
    KubeSpawner:
      extraVolumes:
        - name: spark-magic-config
          configMap:
            name: spark-magic-config
      extraVolumeMounts:
        - name: spark-magic-config
          mountPath: /home/config.json
          subPath: config.json
consideRatio commented 19 hours ago

It ahould be extra_volumes when you put something under hub.config.KubeSpawner, and you can use KubeSpanwer documentation of what you configure etc.