forked from gatoniel/podmanspawner
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #162 from manics/dev
Add example jupyterhub_config.py
- Loading branch information
Showing
3 changed files
with
45 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -127,3 +127,7 @@ dmypy.json | |
|
||
# Pyre type checker | ||
.pyre/ | ||
|
||
# Other ignores | ||
jupyterhub.sqlite | ||
jupyterhub_cookie_secret |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from os import getenv | ||
import socket | ||
from traitlets.config import get_config | ||
|
||
|
||
def get_host_ip(): | ||
""" | ||
Get the IP to connect to the host | ||
If you're using Podman 5+ the default IP will not work, set HOST_IP | ||
a non-default IP: | ||
https://blog.podman.io/2024/03/podman-5-0-breaking-changes-in-detail/ | ||
""" | ||
host_ip = getenv("HOST_IP") | ||
if not host_ip: | ||
# IP associated with the default route https://stackoverflow.com/a/28950776 | ||
with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as s: | ||
# doesn't even have to be reachable | ||
s.connect(("10.255.255.255", 1)) | ||
host_ip = s.getsockname()[0] | ||
print(f"Host IP: {host_ip}") | ||
return host_ip | ||
|
||
|
||
c = get_config() | ||
|
||
c.JupyterHub.authenticator_class = "dummy" | ||
c.JupyterHub.hub_connect_ip = get_host_ip() | ||
c.JupyterHub.spawner_class = "podmancli" | ||
c.PodmanCLISpawner.remove = True |