kubespawner form example

59 views
Skip to first unread message

daniel davis

unread,
Sep 19, 2018, 10:58:55 AM9/19/18
to Project Jupyter
Hello all,

I followed the jupyterhub-quickstart examples on GitHub and have a working jupyterhub instance in OpenShift that spawns instances of a custom notebook.  Works great!

Now I am trying to add an input form to the jupyterhub spawner to capture an API token for use in the notebook instances.  I have seen examples of using forms, but they all involve defining a new spawner class rather than passing parameters to the kubespawner instance.  Attempts to create a custom spawner by overriding jupyterhub_spawner.py succeed in displaying a form, but break the rest of the deployment.  So I am looking for advice on how to approach this problem.  I was hoping to pass a form variable or html to the c.KubeSpawner object, but all the examples I have seen require creating a new spawner class and defining functions to handle the form data.

Is there a way to use an input form with the existing KubeSpawner class?  I'm a Jupyter novice, so it is possible I am missing something obvious.  Appreciate any advice.

George Miller

unread,
Dec 21, 2018, 11:19:58 AM12/21/18
to Project Jupyter
If you are using the jupyterhub helm chart https://github.com/jupyterhub/zero-to-jupyterhub-k8s , you can specify it in the helm values yml like so:

hub:
  extraConfig: |
    c.KubeSpawner.options_form = """
      <label for='image'>Image</label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      <input name='image' placeholder='repo/image:tag'></input>
      <br/><br/>
      <label for='cpu_guarantee'>CPU</label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      <input name='cpu_guarantee' placeholder='200m, 1.0, 2.5, etc'></input>
      <br/><br/>
      <label for='mem_guarantee'>Memory</label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      <input name='mem_guarantee' placeholder='100Mi, 1.5Gi'></input>
      <br/><br/>
      <label for='extra_resource_limits'>Extra Resource Limits</label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      <input name='extra_resource_limits' placeholder='{'nvidia.com/gpu': '3'}'></input>
      <br/><br/>
Reply all
Reply to author
Forward
0 new messages