bitnami / charts

Bitnami Helm Charts
https://bitnami.com
Other
9.07k stars 9.25k forks source link

[bitnami/jupyterhub] extraEnvVars - KubeSpawner instance expected a dict #11806

Closed chrispward closed 2 years ago

chrispward commented 2 years ago

Name and Version

bitnami/jupyterhub:lastest

What steps will reproduce the bug?

Installing jupyerhub charts. Trying to set some custom singleuser.extraEnvVars which the docs say is default is [] No matter how I define it in my config.yaml, when I launch my lab, there is an error

traitlets.traitlets.TraitError: The 'environment' trait of a KubeSpawner instance expected a dict, not the list [{'accept_license': 'Y'}]

It might be just how I'm defining it as this is 1st time I've used the bitnami charts. Note: I can't find any examples of using an override chart... Would be useful to see some examples of different data types (dict list etc)

I've attached the current config file. Trying to set the environment variable accept_license = "Y"

Are you using any custom parameters or values?

Can't seem to upload/attach my yaml file so... helm install bjhub bitnami/jupyterhub -n bjhub -f bitnamiConfig.yaml

bitnamiConfig.yaml contents..

global:
  storageClass: pmax-storage-policy

hub:
  adminUser: admin
  password: admin

singleuser:
  image:
    repository: teradata/jupyterlab-extensions
    tag: latest
  extraEnvVars: 
    accept_license : "Y"

What is the expected behavior?

Lab to be spawned with the environment variable 'accept_license=Y'

What do you see instead?

Error in the log stating

traitlets.traitlets.TraitError: The 'environment' trait of a KubeSpawner instance expected a dict, not the list [{'accept_license': 'Y'}]

Additional information

I can't find a good example of setting the yaml files for each property 'type'. ie [] int, {} etc. Be good to have as it might just be how I'm doing it rather than a bug.

fmulero commented 2 years ago

Hi @chrispward

extraEnvVars have been desgined to allow users set additional environment variables to the containers. Here you can find an example about how to use it.

In your case you have to set something like this:

global:
  storageClass: pmax-storage-policy

hub:
  adminUser: admin
  password: admin

singleuser:
  image:
    repository: teradata/jupyterlab-extensions
    tag: latest
  extraEnvVars: 
    - name: accept_license
      value: "Y"

I hope it helps

chrispward commented 2 years ago

so thats the issue then.

When I set it as you suggest ie

`global: storageClass: pmax-storage-policy

hub: adminUser: admin password: admin

singleuser: image: repository: teradata/jupyterlab-extensions tag: latest extraEnvVars:

when the you try to start the pod (ie log in and it spawns the image) it fails with

traitlets.traitlets.TraitError: The 'environment' trait of a KubeSpawner instance expected a dict, not the list [{'name': 'accept_license', 'value': 'Y'}].

fmulero commented 2 years ago

Sorry @chrispward I don't fully understand. The yaml here solved the problem? If not, could you format properly your previous comment(Here you can find information about how to do it.)? I'd like to do some tests

chrispward commented 2 years ago

setting the yaml as you suggested is not fixing the issue. The Kubespawner still generates the error so whatever is been passed in, is not been correct.

I am able to do set these parameters just fine in a native jupyterhub install.

ie in a native install, setting these in the config file like so works. extraEnv: accept_license: "Y" TD_CONFIG: /home/jovyan/tdconfig/tdconfig.yaml

Whatever your doing with you your environment properties is not setting it how jupyterhub kubespawner is expecting.

fmulero commented 2 years ago

Sorry @chrispward I didn't see the singleUser.extraEnvVars is not use as a regular extraEnvVars for our deployments. In this case, this is directly used in the jupyterhub config.yaml file.

With the following configuration seems fixed in my side. Could you try this? :

hub:
  adminUser: admin
  password: admin

singleuser:
  image:
    repository: teradata/jupyterlab-extensions
    tag: latest
  extraEnvVars:
    accept_license: "Y"
chrispward commented 2 years ago

sorry. now I'm confused.

if I try to set up the extraEnvVars in the bitnami config file like you suggest it errors with [root]/data/gitlab/jhubinstall/helm> helm install bjhub bitnami/jupyterhub -n bjhub -f bitnamiConfig.yaml --create-namespace

coalesce.go:223: warning: destination for jupyterhub.singleuser.extraEnvVars is a table. Ignoring non-table value ([])
coalesce.go:223: warning: destination for jupyterhub.singleuser.extraEnvVars is a table. Ignoring non-table value ([])

I know that in a native jhub install works setting the extraEnvVars like.

  extraEnvVars:
    accept_license: "Y"

I need the bitnami charts to work with it (or some equivalent format)

If your saying there is a way to 'override' the bitnami charts with a 'standard' config file with singleuser properties.. How?

Content of bitnamiConfig.yaml

global:
  storageClass: pmax-storage-policy

hub:
  adminUser: admin
  password: admin

singleuser:
  image:
    repository: teradata/jupyterlab-extensions
    tag: latest
  extraEnvVars:
    accept_license: "Y"
fmulero commented 2 years ago

I know, a lot of misunderstood here. I'll try to explain.

We usually have an extraEnvVars array to add additional environment variables to the containers but in this case we use singleuser.extraEnvVars to set the Jupyter singleuser.extraEnv, so our extraEnvVars shouldn't be a list. Anyway, you can use it as it is, ignoring the warning messages, the generated secret should have accept_license: "Y". For instance:

$ kubectl get secrets bjhub-jupyterhub-hub -n bjhub -o "jsonpath={.data['values\.yaml']}" | base64 -d
Chart:
  Name: jupyterhub
  Version: 1.4.1
Release:
  Name: bjhub
  Namespace: bjhub
  Service: Helm
hub:
  config:
    JupyterHub:
      admin_access: true
      authenticator_class: dummy
      cookie_secret_file: /tmp/jupyterhub_cookie_secret
      DummyAuthenticator:
        password: "admin"
      Authenticator:
        admin_users:
          - admin
  cookieSecret:
  concurrentSpawnLimit: 64
  consecutiveFailureLimit: 5
  activeServerLimit:
  db:
    type: postgres
    url: postgresql://bn_jupyterhub@bjhub-postgresql:5432/bitnami_jupyterhub
  services: {}
  allowNamedServers: false
  namedServerLimitPerUser:
  redirectToServer:
  shutdownOnLogout:
singleuser:
  podNameTemplate: bjhub-jupyterhub-jupyter-{username}
  networkTools:
    image:
      name: docker.io/bitnami/bitnami-shell
      tag: 11-debian-11-r23
      digest: 
      pullPolicy: IfNotPresent
      pullSecrets:

  cloudMetadata:
    blockWithIptables: false
  events: true
  extraAnnotations:
  extraLabels:
    hub.jupyter.org/network-access-hub: "true"
    app.kubernetes.io/component: singleuser
    app.kubernetes.io/name: jupyterhub
    helm.sh/chart: jupyterhub-1.4.1
    app.kubernetes.io/instance: bjhub
    app.kubernetes.io/managed-by: Helm
  extraEnv:
    accept_license: "Y"
  uid: 1001
  fsGid: 1001
  serviceAccountName: bjhub-jupyterhub-singleuser
  storage:
    type: dynamic
    extraLabels:
      app.kubernetes.io/component: singleuser
      app.kubernetes.io/name: jupyterhub
      helm.sh/chart: jupyterhub-1.4.1
      app.kubernetes.io/instance: bjhub
      app.kubernetes.io/managed-by: Helm
    capacity: 10Gi
    homeMountPath: /opt/bitnami/jupyterhub-singleuser
    dynamic:

      pvcNameTemplate: bjhub-jupyterhub-claim-{username}{servername}
      volumeNameTemplate: bjhub-jupyterhub-volume-{username}{servername}
      storageAccessModes:
        - ReadWriteOnce
  image:
    name: docker.io/teradata/jupyterlab-extensions
    tag: latest
    digest: 
    pullPolicy: IfNotPresent
    pullSecrets:

  startTimeout: 300
  cpu:
    limit: 
    guarantee: 
  memory:
    limit: 
    guarantee: 
  cmd: jupyterhub-singleuser
  defaultUrl:
cull:
  enabled: true
  users: false
  removeNamedServers: false
  timeout: 3600
  every: 600
  concurrency: 10
  maxAge: 0
chrispward commented 2 years ago

yeah. That worked. its defiantly confusing to see the warning/error especially when trying to debug several issues at once. I would suggest putting the command somewhere in the documentation as a debugging tip.

kubectl get secrets bjhub-jupyterhub-hub -n bjhub -o "jsonpath={.data['values.yaml']}" | base64 -d

bcm0 commented 1 year ago

Hi @chrispward

extraEnvVars have been desgined to allow users set additional environment variables to the containers. Here you can find an example about how to use it.

In your case you have to set something like this:

global:
  storageClass: pmax-storage-policy

hub:
  adminUser: admin
  password: admin

singleuser:
  image:
    repository: teradata/jupyterlab-extensions
    tag: latest
  extraEnvVars: 
    - name: accept_license
      value: "Y"

I hope it helps

This does not work for me, only accept_license: "Y" works

AntonOfTheWoods commented 8 months ago

@fmulero

extraEnvVars have been desgined to allow users set additional environment variables to the containers. Here you can find an example about how to use it.

That here now simply returns a 404.

carrodher commented 8 months ago

Documentation of the Helm chart is now placed in the READMEs instead of Bitnami doc site, see https://github.com/bitnami/charts/tree/main/bitnami/etcd#using-custom-configuration