Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Let singleuser server select a free random port to listen on #448

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

iwilltry42
Copy link

About

This PR adds the functionality to let the singleuser server/pod choose the port it's listening on itself.
For this, you need to have the jupyterhub-kubespawner package installed in both, the JupyterHub Server and the Singleuser Server image.

How it works

Currently, it works by setting the kubespawner/port: auto annotation on the profile list. I guess it would be way better to have it as a real config option for kubespawner or be assumed when setting port = 0.
It works almost exactly like the similar change in batchspawner (see jupyterhub/batchspawner#58 & jupyterhub/batchspawner#130).

Example Use Case

Our use case is to be able to connect to a remote Hadoop cluster, executing pySpark in client mode (so the Hadoop nodes can talk back to a real IP and not to the non-routeable Pod-IP). In this case, the singleuser pods run in hostNetwork: true mode.
Without this feature, the default ports would collide if more than one singleuser server is being scheduled to the same node.

We're using this in production for several months now, without any issues so far.

Related Issues

This could fix #299

@welcome
Copy link

welcome bot commented Oct 16, 2020

Thanks for submitting your first pull request! You are awesome! 🤗

If you haven't done so already, check out Jupyter's Code of Conduct. Also, please make sure you followed the pull request template, as this will help us review your contribution more quickly.
welcome
You can meet the other Jovyans by joining our Discourse forum. There is also a intro thread there where you can stop by and say Hi! 👋

Welcome to the Jupyter community! 🎉

@rkdarst
Copy link

rkdarst commented Oct 16, 2020

Before you spend too much time on this (I haven't read it yet), you might want to look at:

Perhaps you'd like to work on the jupyterhub improvement some, then hook into that?

@rkdarst
Copy link

rkdarst commented Oct 16, 2020

Note: I know some of batchspawner, less involved in both kubespawner and jupyterhub. I hope someone else more knowledgeable will comment on which options they recommend you to look into.

By all means, take over the pull request jupyterhub/jupyterhub#2727 that I started! It was designed in consultation with the JH team.

@iwilltry42
Copy link
Author

Hi @rkdarst , thanks for your feedback 👍
Actually jupyterhub/batchspawner#58 is what inspired me to do this like it is now.
I love the idea of having a generic callback endpoint for spawners to submit arbitrary data 🤔
Is it foreseeable to be merged soon-ish?

@rkdarst
Copy link

rkdarst commented Oct 20, 2020 via email

@consideRatio
Copy link
Member

I'm confused why there are so many commits unrelated to this PR. Can you rebase on master so I better understand whats really relevant to review @iwilltry42?

@iwilltry42 iwilltry42 force-pushed the autoport branch 2 times, most recently from d953aa3 to d39138e Compare October 26, 2020 11:17
@iwilltry42
Copy link
Author

Hi @consideRatio , sorry for the commit mess.. don't know what happened there when merging master. I now rebased onto master, but couldn't get rid of that one commit in travis (although I didn't change anything there).. However, right now that's only a newline 🤷‍♂️

@rkdarst , I'm trying to understand jupyterhub/jupyterhub#2727 now, however I feel like I'm lacking a clear specification there and am not sure if I can just pick it up on the fly.

... if the kubespawner/port: auto annotation is set

Signed-off-by: Thorsten Klein <iwilltry42@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

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