question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support random port assignment when c.KubeSpawner.port = 0

See original GitHub issue

According to the document, KubeSpawner will use randomly allocated port. I deployed zero-to-jupyterhub-k8s (hostNetwork:true set for spark) and got error when login some users: [Warning] 0/3 nodes are available: 1 node(s) had taints that the pod didn't tolerate, 2 Insufficient memory, 2 node(s) didn't have free ports for the requested pod ports.

That’s because KubeSpawner always use port 8888 instead of random port. https://github.com/jupyterhub/kubespawner/blob/master/kubespawner/spawner.py#L145

https://jupyterhub-kubespawner.readthedocs.io/en/latest/spawner.html

config c.KubeSpawner.port = Int(0) The port for single-user servers to listen on.

Defaults to 0, which uses a randomly allocated port number each time.

If set to a non-zero value, all Spawners will use the same port, which only makes sense if each server is on a different address, e.g. in containers.

New in version 0.7.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:1
  • Comments:16

github_iconTop GitHub Comments

1reaction
frouzbehcommented, Jul 30, 2019

@ramkrishnan8994 My Kubernetes and Hadoop cluster are physically on the same computer cluster. I thought to connect to spark from client side I needed hostNetwork but I don’t. I just needed to set the spark.driver.host of SparkConf to the ip address of the container.

1reaction
cmd-ntrfcommented, Apr 10, 2019

As @rkdarst mentionned, we encountered a similar issue with batchspawner.

The solution we opted for was to write a API Handler that is installed on the Hub side. The handler waits to receive the port number from the singleuser and modify the spawner port value. The spawner is identified based on the user auth, but I have recently submitted a patch to use the API token instead to support named servers.

To send the port, I have written a small wrapper script that selects a port, configures the singleuser to use it, send it through http to the Hub at the API handler address, then starts the notebook just like singleuser would.

There is a problem though. JupyterHub does not provide mechanism to automatically registers API handlers from third-parties. Currently, the API handler is registered when the batchspawner module is imported, but for some cases like when using wrapspawner, the module is imported after JupyterHub is initialized and the batchspawner API handler is not registered properly. As a solution to that problem, we currently instructing user to import batchspawner in jupyterhub_config.py, which is not ideal, but it works.

Ideally, the API handler I have written for batchspawner would be integrated directly in JupyterHub to configure the port number. Another option would be to implement a mechanism similar to the one in Jupyter that allow the installation and activation of server side plugin / handlers. I am willing to help with either solution or anything related.

Read more comments on GitHub >

github_iconTop Results From Across the Web

jupyterhub_config.py - Kubespawner - Read the Docs
c.JupyterHub.spawner_class = 'kubespawner.KubeSpawner' ... Defaults to 0 , which uses a randomly allocated port number each time. If set to a non-zero value ......
Read more >
Kubespawner Documentation - Read the Docs
Spawn multiple hubs in the same kubernetes cluster, with support ... Defaults to 0, which uses a randomly allocated port number each time....
Read more >
Is it possible to stop random port assignment? : r/asustor - Reddit
Did you manually assign the ports, or did you hit the assign random ports button? I manually assigned ports for all my containers...
Read more >
Configuration Reference - Zero to JupyterHub with Kubernetes
c.JupyterHub.admin_access = true c.JupyterHub.admin_users = ["jovyan1", "jovyan2"] ... Object to configure the ports the hub service will be deployed on.
Read more >
Manual deployment of JupyterHub on Kubernetes for a single ...
c.JupyterHub.port = int(os.environ['PROXY_PUBLIC_SERVICE_PORT'])# the hub should ... later on, I will create a Service named proxy-api and K8S will assign ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found