Proxy API¶
Module: jupyterhub_traefik_proxy
¶
Traefik implementation of the JupyterHub proxy API
TraefikProxy
¶
-
class
jupyterhub_traefik_proxy.
TraefikProxy
(**kwargs)[source]¶ JupyterHub Proxy implementation using traefik
-
config c.TraefikProxy.check_route_timeout = Int(30)
Timeout (in seconds) when waiting for traefik to register an updated route.
-
config c.TraefikProxy.should_start = Bool(True)
Should the Hub start the proxy
If True, the Hub will start the proxy and stop it. Set to False if the proxy is managed externally, such as by systemd, docker, or another service manager.
-
config c.TraefikProxy.toml_static_config_file = Unicode('traefik.toml')
traefik’s static configuration file
-
config c.TraefikProxy.traefik_api_password = Unicode('')
The password for traefik api login
-
config c.TraefikProxy.traefik_api_url = Unicode('http://127.0.0.1:8099')
traefik authenticated api endpoint url
-
config c.TraefikProxy.traefik_api_username = Unicode('')
The username for traefik api login
-
config c.TraefikProxy.traefik_log_level = Unicode('ERROR')
traefik’s log level
-
add_route
(routespec, target, data)[source]¶ Add a route to the proxy.
Subclasses must define this method
Parameters: - routespec (str) – A URL prefix ([host]/path/) for which this route will be matched, e.g. host.name/path/
- target (str) – A full URL that will be the target of this route.
- data (dict) – A JSONable dict that will be associated with this route, and will be returned when retrieving information about this route.
Will raise an appropriate Exception (FIXME: find what?) if the route could not be added.
The proxy implementation should also have a way to associate the fact that a route came from JupyterHub.
-
config c.TraefikProxy.check_route_timeout = Int(30)
Timeout (in seconds) when waiting for traefik to register an updated route.
-
delete_route
(routespec)[source]¶ Delete a route with a given routespec if it exists.
Subclasses must define this method
-
get_all_routes
()[source]¶ Fetch and return all the routes associated by JupyterHub from the proxy.
Subclasses must define this method
Should return a dictionary of routes, where the keys are routespecs and each value is a dict of the form:
{ 'routespec': the route specification ([host]/path/) 'target': the target host URL (proto://host) for this route 'data': the attached data dict for this route (as specified in add_route) }
-
get_route
(routespec)[source]¶ Return the route info for a given routespec.
Parameters: routespec (str) – A URI that was used to add this route, e.g. host.tld/path/ Returns: dict with the following keys: 'routespec': The normalized route specification passed in to add_route ([host]/path/) 'target': The target host for this route (proto://host) 'data': The arbitrary data dict that was passed in by JupyterHub when adding this route.
None: if there are no routes matching the given routespec
Return type: result (dict)
-
start
()[source]¶ Start the proxy.
Will be called during startup if should_start is True.
Subclasses must define this method if the proxy is to be started by the Hub
-
stop
()[source]¶ Stop the proxy.
Will be called during teardown if should_start is True.
Subclasses must define this method if the proxy is to be started by the Hub
-
config c.TraefikProxy.toml_static_config_file = Unicode('traefik.toml')
traefik’s static configuration file
-
config c.TraefikProxy.traefik_api_password = Unicode('')
The password for traefik api login
-
config c.TraefikProxy.traefik_api_url = Unicode('http://127.0.0.1:8099')
traefik authenticated api endpoint url
-
config c.TraefikProxy.traefik_api_username = Unicode('')
The username for traefik api login
-
config c.TraefikProxy.traefik_log_level = Unicode('ERROR')
traefik’s log level
-
TraefikTomlProxy
¶
-
class
jupyterhub_traefik_proxy.
TraefikTomlProxy
(**kwargs)[source]¶ JupyterHub Proxy implementation using traefik and toml config file
-
config c.TraefikTomlProxy.check_route_timeout = Int(30)
Timeout (in seconds) when waiting for traefik to register an updated route.
-
config c.TraefikTomlProxy.should_start = Bool(True)
Should the Hub start the proxy
If True, the Hub will start the proxy and stop it. Set to False if the proxy is managed externally, such as by systemd, docker, or another service manager.
-
config c.TraefikTomlProxy.toml_dynamic_config_file = Unicode('rules.toml')
traefik’s dynamic configuration file
-
config c.TraefikTomlProxy.toml_static_config_file = Unicode('traefik.toml')
traefik’s static configuration file
-
config c.TraefikTomlProxy.traefik_api_password = Unicode('')
The password for traefik api login
-
config c.TraefikTomlProxy.traefik_api_url = Unicode('http://127.0.0.1:8099')
traefik authenticated api endpoint url
-
config c.TraefikTomlProxy.traefik_api_username = Unicode('')
The username for traefik api login
-
config c.TraefikTomlProxy.traefik_log_level = Unicode('ERROR')
traefik’s log level
-
add_route
(routespec, target, data)[source]¶ Add a route to the proxy.
Subclasses must define this method
Parameters: - routespec (str) – A URL prefix ([host]/path/) for which this route will be matched, e.g. host.name/path/
- target (str) – A full URL that will be the target of this route.
- data (dict) – A JSONable dict that will be associated with this route, and will be returned when retrieving information about this route.
Will raise an appropriate Exception (FIXME: find what?) if the route could not be added.
The proxy implementation should also have a way to associate the fact that a route came from JupyterHub.
-
delete_route
(routespec)[source]¶ Delete a route with a given routespec if it exists.
Subclasses must define this method
-
get_all_routes
()[source]¶ Fetch and return all the routes associated by JupyterHub from the proxy.
Subclasses must define this method
Should return a dictionary of routes, where the keys are routespecs and each value is a dict of the form:
{ 'routespec': the route specification ([host]/path/) 'target': the target host URL (proto://host) for this route 'data': the attached data dict for this route (as specified in add_route) }
-
get_route
(routespec)[source]¶ Return the route info for a given routespec.
Parameters: routespec (str) – A URI that was used to add this route, e.g. host.tld/path/ Returns: dict with the following keys: 'routespec': The normalized route specification passed in to add_route ([host]/path/) 'target': The target host for this route (proto://host) 'data': The arbitrary data dict that was passed in by JupyterHub when adding this route.
None: if there are no routes matching the given routespec
Return type: result (dict)
-
start
()[source]¶ Start the proxy.
Will be called during startup if should_start is True.
Subclasses must define this method if the proxy is to be started by the Hub
-
stop
()[source]¶ Stop the proxy.
Will be called during teardown if should_start is True.
Subclasses must define this method if the proxy is to be started by the Hub
-
config c.TraefikTomlProxy.toml_dynamic_config_file = Unicode('rules.toml')
traefik’s dynamic configuration file
-
TKvProxy
¶
-
class
jupyterhub_traefik_proxy.
TKvProxy
(**kwargs)[source]¶ JupyterHub Proxy implementation using traefik and a key-value store. Custom proxy implementations based on trafik and a key-value store can sublass
TKvProxy
.-
config c.TKvProxy.check_route_timeout = Int(30)
Timeout (in seconds) when waiting for traefik to register an updated route.
-
config c.TKvProxy.kv_jupyterhub_prefix = Unicode('')
The key value store key prefix for traefik dynamic configuration
-
config c.TKvProxy.kv_password = Unicode('')
The password for key value store login
-
config c.TKvProxy.kv_traefik_prefix = KVStorePrefix('')
The key value store key prefix for traefik static configuration
-
config c.TKvProxy.kv_url = Unicode('')
The URL of the key value store server
-
config c.TKvProxy.kv_username = Unicode('')
The username for key value store login
-
config c.TKvProxy.should_start = Bool(True)
Should the Hub start the proxy
If True, the Hub will start the proxy and stop it. Set to False if the proxy is managed externally, such as by systemd, docker, or another service manager.
-
config c.TKvProxy.toml_static_config_file = Unicode('traefik.toml')
traefik’s static configuration file
-
config c.TKvProxy.traefik_api_password = Unicode('')
The password for traefik api login
-
config c.TKvProxy.traefik_api_url = Unicode('http://127.0.0.1:8099')
traefik authenticated api endpoint url
-
config c.TKvProxy.traefik_api_username = Unicode('')
The username for traefik api login
-
config c.TKvProxy.traefik_log_level = Unicode('ERROR')
traefik’s log level
-
add_route
(routespec, target, data)[source]¶ Add a route to the proxy.
Parameters: - routespec (str) – A URL prefix ([host]/path/) for which this route will be matched, e.g. host.name/path/
- target (str) – A full URL that will be the target of this route.
- data (dict) – A JSONable dict that will be associated with this route, and will be returned when retrieving information about this route.
Will raise an appropriate Exception (FIXME: find what?) if the route could not be added.
This proxy implementation prefixes the routespec with proxy.jupyterhub_prefix when adding it to the kv store in orde to associate the fact that the route came from JupyterHub. Everything traefik related is prefixed with proxy.traefik_prefix.
-
delete_route
(routespec)[source]¶ Delete a route and all the traefik related info associated given a routespec, (if it exists).
-
get_all_routes
()[source]¶ Fetch and return all the routes associated by JupyterHub from the proxy.
Returns a dictionary of routes, where the keys are routespecs and each value is a dict of the form:
{ 'routespec': the route specification ([host]/path/) 'target': the target host URL (proto://host) for this route 'data': the attached data dict for this route (as specified in add_route) }
-
get_route
(routespec)[source]¶ Return the route info for a given routespec.
Parameters: routespec (str) – A URI that was used to add this route, e.g. host.tld/path/ Returns: dict with the following keys: 'routespec': The normalized route specification passed in to add_route ([host]/path/) 'target': The target host for this route (proto://host) 'data': The arbitrary data dict that was passed in by JupyterHub when adding this route.
None: if there are no routes matching the given routespec
Return type: result (dict)
-
config c.TKvProxy.kv_jupyterhub_prefix = Unicode('')
The key value store key prefix for traefik dynamic configuration
-
config c.TKvProxy.kv_password = Unicode('')
The password for key value store login
-
config c.TKvProxy.kv_traefik_prefix = KVStorePrefix('')
The key value store key prefix for traefik static configuration
-
config c.TKvProxy.kv_url = Unicode('')
The URL of the key value store server
-
config c.TKvProxy.kv_username = Unicode('')
The username for key value store login
-
TraefikEtcdProxy
¶
-
class
jupyterhub_traefik_proxy.
TraefikEtcdProxy
(**kwargs)[source]¶ JupyterHub Proxy implementation using traefik and etcd
-
config c.TraefikEtcdProxy.check_route_timeout = Int(30)
Timeout (in seconds) when waiting for traefik to register an updated route.
-
config c.TraefikEtcdProxy.etcd_client_ca_cert = Unicode(None)
Etcd client root certificates
-
config c.TraefikEtcdProxy.etcd_client_cert_crt = Unicode(None)
Etcd client certificate chain (etcd_client_cert_key must also be specified)
-
config c.TraefikEtcdProxy.etcd_client_cert_key = Unicode(None)
Etcd client private key (etcd_client_cert_crt must also be specified)
-
config c.TraefikEtcdProxy.kv_jupyterhub_prefix = Unicode('')
The key value store key prefix for traefik dynamic configuration
-
config c.TraefikEtcdProxy.kv_password = Unicode('')
The password for key value store login
-
config c.TraefikEtcdProxy.kv_traefik_prefix = KVStorePrefix('')
The key value store key prefix for traefik static configuration
-
config c.TraefikEtcdProxy.kv_url = Unicode('')
The URL of the key value store server
-
config c.TraefikEtcdProxy.kv_username = Unicode('')
The username for key value store login
-
config c.TraefikEtcdProxy.should_start = Bool(True)
Should the Hub start the proxy
If True, the Hub will start the proxy and stop it. Set to False if the proxy is managed externally, such as by systemd, docker, or another service manager.
-
config c.TraefikEtcdProxy.toml_static_config_file = Unicode('traefik.toml')
traefik’s static configuration file
-
config c.TraefikEtcdProxy.traefik_api_password = Unicode('')
The password for traefik api login
-
config c.TraefikEtcdProxy.traefik_api_url = Unicode('http://127.0.0.1:8099')
traefik authenticated api endpoint url
-
config c.TraefikEtcdProxy.traefik_api_username = Unicode('')
The username for traefik api login
-
config c.TraefikEtcdProxy.traefik_log_level = Unicode('ERROR')
traefik’s log level
-
config c.TraefikEtcdProxy.etcd_client_ca_cert = Unicode(None)
Etcd client root certificates
-
config c.TraefikEtcdProxy.etcd_client_cert_crt = Unicode(None)
Etcd client certificate chain (etcd_client_cert_key must also be specified)
-
config c.TraefikEtcdProxy.etcd_client_cert_key = Unicode(None)
Etcd client private key (etcd_client_cert_crt must also be specified)
-
TraefikConsulProxy
¶
-
class
jupyterhub_traefik_proxy.
TraefikConsulProxy
(**kwargs)[source]¶ JupyterHub Proxy implementation using traefik and Consul
-
config c.TraefikConsulProxy.check_route_timeout = Int(30)
Timeout (in seconds) when waiting for traefik to register an updated route.
-
config c.TraefikConsulProxy.consul_client_ca_cert = Unicode(None)
Consul client root certificates
-
config c.TraefikConsulProxy.kv_jupyterhub_prefix = Unicode('')
The key value store key prefix for traefik dynamic configuration
-
config c.TraefikConsulProxy.kv_password = Unicode('')
The password for key value store login
-
config c.TraefikConsulProxy.kv_traefik_prefix = KVStorePrefix('')
The key value store key prefix for traefik static configuration
-
config c.TraefikConsulProxy.kv_url = Unicode('')
The URL of the key value store server
-
config c.TraefikConsulProxy.kv_username = Unicode('')
The username for key value store login
-
config c.TraefikConsulProxy.should_start = Bool(True)
Should the Hub start the proxy
If True, the Hub will start the proxy and stop it. Set to False if the proxy is managed externally, such as by systemd, docker, or another service manager.
-
config c.TraefikConsulProxy.toml_static_config_file = Unicode('traefik.toml')
traefik’s static configuration file
-
config c.TraefikConsulProxy.traefik_api_password = Unicode('')
The password for traefik api login
-
config c.TraefikConsulProxy.traefik_api_url = Unicode('http://127.0.0.1:8099')
traefik authenticated api endpoint url
-
config c.TraefikConsulProxy.traefik_api_username = Unicode('')
The username for traefik api login
-
config c.TraefikConsulProxy.traefik_log_level = Unicode('ERROR')
traefik’s log level
-
config c.TraefikConsulProxy.consul_client_ca_cert = Unicode(None)
Consul client root certificates
-