Proxy API#

Module: jupyterhub_traefik_proxy#

Traefik implementation of the JupyterHub proxy API

TraefikProxy#

class jupyterhub_traefik_proxy.proxy.TraefikProxy(**kwargs: Any)[source]#

JupyterHub Proxy implementation using traefik

async 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.

check_route_timeout c.TraefikProxy.check_route_timeout = Int(30)#

Timeout (in seconds) when waiting for traefik to register an updated route.

async check_routes(*args, **kwargs)[source]#

Check that all users are properly routed on the proxy.

concurrency c.TraefikProxy.concurrency = Int(10)#

The number of requests allowed to be concurrently outstanding to the proxy

Limiting this number avoids potential timeout errors by sending too many requests to update the proxy at once

async delete_route(routespec)[source]#

Delete a route with a given routespec if it exists.

enable_setup_dynamic_config c.TraefikProxy.enable_setup_dynamic_config = Bool(True)#

Whether to initialize the traefik dynamic configuration from JupyterHub configuration, when should_start is False (dynamic configuration is always applied when should_start is True).

Creates the traefik API router and TLS setup, if any. When True, only traefik static configuration must be managed by the external service (configuration of the endpoints and provider). The traefik api router should not already be configured via other dynamic configuration providers.

When False, initial dynamic configuration must be handled externally and match TraefikProxy configuration, such as traefik_api_url, traefik_api_username` and traefik_api_password. Choose this if the traefik api router is already configured via dynamic configuration elsewhere.

Added in version 1.1.

extra_dynamic_config c.TraefikProxy.extra_dynamic_config = Dict()#

Extra dynamic configuration for treafik.

Merged with the default dynamic config during startup.

Always takes effect unless should_start and enable_setup_dynamic_config are both False.

extra_routes c.TraefikProxy.extra_routes = Dict()#

Additional routes to be maintained in the proxy.

A dictionary with a route specification as key, and a URL as target. The hub will ensure this route is present in the proxy.

If the hub is running in host based mode (with JupyterHub.subdomain_host set), the routespec must have a domain component (example.com/my-url/). If the hub is not running in host based mode, the routespec must not have a domain component (/my-url/).

Helpful when the hub is running in API-only mode.

extra_static_config c.TraefikProxy.extra_static_config = Dict()#

Extra static configuration for treafik.

Merged with the default static config before writing to .static_config_file.

Has no effect if Proxy.should_start is False.

async 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)
}
is_https Bool(False)#

Whether public_url specifies an https entrypoint

provider_name Unicode('')#

The provider name that Traefik expects, e.g. file, consul, etcd

should_start 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.

async 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

static_config_file c.TraefikProxy.static_config_file = Unicode('traefik.toml')#

traefik’s static configuration file

async 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

toml_static_config_file c.TraefikProxy.toml_static_config_file = Unicode('')#

Deprecated. Use static_config_file

traefik_api_entrypoint c.TraefikProxy.traefik_api_entrypoint = Unicode('auth_api')#

The traefik entrypoint name to use for API access.

Separate from traefik_entrypoint, because this is usually only on localhost.

traefik_api_password c.TraefikProxy.traefik_api_password = Unicode('')#

The password for traefik api login

traefik_api_url c.TraefikProxy.traefik_api_url = Unicode('http://localhost:8099')#

traefik authenticated api endpoint url

traefik_api_username c.TraefikProxy.traefik_api_username = Unicode('')#

The username for traefik api login

traefik_api_validate_cert c.TraefikProxy.traefik_api_validate_cert = Bool(True)#

validate SSL certificate of traefik api endpoint

traefik_entrypoint c.TraefikProxy.traefik_entrypoint = Unicode('')#

The traefik entrypoint name to use.

By default, will be http if http or https if https.

If running traefik externally with your own specified entrypoint name, set this value.

traefik_env c.TraefikProxy.traefik_env = Dict()#

Environment variables to set for the traefik process.

Only has an effect when traefik is a subprocess (should_start=True).

traefik_log_level c.TraefikProxy.traefik_log_level = Unicode('')#

traefik’s log level

traefik_providers_throttle_duration c.TraefikProxy.traefik_providers_throttle_duration = Unicode('0s')#

throttle traefik reloads of configuration.

When traefik sees a change in configuration, it will wait this long before applying the next one. This affects how long adding a user to the proxy will take.

See https://doc.traefik.io/traefik/providers/overview/#providersprovidersthrottleduration

validate_routespec(routespec)[source]#

Override jupyterhub’s default Proxy.validate_routespec method, as traefik can set router rule’s on both Host and PathPrefix rules combined.

TraefikFileProviderProxy#

class jupyterhub_traefik_proxy.fileprovider.TraefikFileProviderProxy(**kwargs: Any)[source]#

JupyterHub Proxy implementation using traefik and toml or yaml config file

check_route_timeout c.TraefikFileProviderProxy.check_route_timeout = Int(30)#

Timeout (in seconds) when waiting for traefik to register an updated route.

concurrency c.TraefikFileProviderProxy.concurrency = Int(10)#

The number of requests allowed to be concurrently outstanding to the proxy

Limiting this number avoids potential timeout errors by sending too many requests to update the proxy at once

dynamic_config_file c.TraefikFileProviderProxy.dynamic_config_file = Unicode('rules.toml')#

traefik’s dynamic configuration file

enable_setup_dynamic_config c.TraefikFileProviderProxy.enable_setup_dynamic_config = Bool(True)#

Whether to initialize the traefik dynamic configuration from JupyterHub configuration, when should_start is False (dynamic configuration is always applied when should_start is True).

Creates the traefik API router and TLS setup, if any. When True, only traefik static configuration must be managed by the external service (configuration of the endpoints and provider). The traefik api router should not already be configured via other dynamic configuration providers.

When False, initial dynamic configuration must be handled externally and match TraefikProxy configuration, such as traefik_api_url, traefik_api_username` and traefik_api_password. Choose this if the traefik api router is already configured via dynamic configuration elsewhere.

Added in version 1.1.

extra_dynamic_config c.TraefikFileProviderProxy.extra_dynamic_config = Dict()#

Extra dynamic configuration for treafik.

Merged with the default dynamic config during startup.

Always takes effect unless should_start and enable_setup_dynamic_config are both False.

extra_routes c.TraefikFileProviderProxy.extra_routes = Dict()#

Additional routes to be maintained in the proxy.

A dictionary with a route specification as key, and a URL as target. The hub will ensure this route is present in the proxy.

If the hub is running in host based mode (with JupyterHub.subdomain_host set), the routespec must have a domain component (example.com/my-url/). If the hub is not running in host based mode, the routespec must not have a domain component (/my-url/).

Helpful when the hub is running in API-only mode.

extra_static_config c.TraefikFileProviderProxy.extra_static_config = Dict()#

Extra static configuration for treafik.

Merged with the default static config before writing to .static_config_file.

Has no effect if Proxy.should_start is False.

async 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)

should_start c.TraefikFileProviderProxy.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.

static_config_file c.TraefikFileProviderProxy.static_config_file = Unicode('traefik.toml')#

traefik’s static configuration file

toml_static_config_file c.TraefikFileProviderProxy.toml_static_config_file = Unicode('')#

Deprecated. Use static_config_file

traefik_api_entrypoint c.TraefikFileProviderProxy.traefik_api_entrypoint = Unicode('auth_api')#

The traefik entrypoint name to use for API access.

Separate from traefik_entrypoint, because this is usually only on localhost.

traefik_api_password c.TraefikFileProviderProxy.traefik_api_password = Unicode('')#

The password for traefik api login

traefik_api_url c.TraefikFileProviderProxy.traefik_api_url = Unicode('http://localhost:8099')#

traefik authenticated api endpoint url

traefik_api_username c.TraefikFileProviderProxy.traefik_api_username = Unicode('')#

The username for traefik api login

traefik_api_validate_cert c.TraefikFileProviderProxy.traefik_api_validate_cert = Bool(True)#

validate SSL certificate of traefik api endpoint

traefik_entrypoint c.TraefikFileProviderProxy.traefik_entrypoint = Unicode('')#

The traefik entrypoint name to use.

By default, will be http if http or https if https.

If running traefik externally with your own specified entrypoint name, set this value.

traefik_env c.TraefikFileProviderProxy.traefik_env = Dict()#

Environment variables to set for the traefik process.

Only has an effect when traefik is a subprocess (should_start=True).

traefik_log_level c.TraefikFileProviderProxy.traefik_log_level = Unicode('')#

traefik’s log level

traefik_providers_throttle_duration c.TraefikFileProviderProxy.traefik_providers_throttle_duration = Unicode('0s')#

throttle traefik reloads of configuration.

When traefik sees a change in configuration, it will wait this long before applying the next one. This affects how long adding a user to the proxy will take.

See https://doc.traefik.io/traefik/providers/overview/#providersprovidersthrottleduration

TKvProxy#

class jupyterhub_traefik_proxy.kv_proxy.TKvProxy(**kwargs: Any)[source]#

JupyterHub Proxy implementation using traefik and a key-value store.

Custom proxy implementations based on traefik and a key-value store can sublass TKvProxy.

check_route_timeout c.TKvProxy.check_route_timeout = Int(30)#

Timeout (in seconds) when waiting for traefik to register an updated route.

concurrency c.TKvProxy.concurrency = Int(10)#

The number of requests allowed to be concurrently outstanding to the proxy

Limiting this number avoids potential timeout errors by sending too many requests to update the proxy at once

enable_setup_dynamic_config c.TKvProxy.enable_setup_dynamic_config = Bool(True)#

Whether to initialize the traefik dynamic configuration from JupyterHub configuration, when should_start is False (dynamic configuration is always applied when should_start is True).

Creates the traefik API router and TLS setup, if any. When True, only traefik static configuration must be managed by the external service (configuration of the endpoints and provider). The traefik api router should not already be configured via other dynamic configuration providers.

When False, initial dynamic configuration must be handled externally and match TraefikProxy configuration, such as traefik_api_url, traefik_api_username` and traefik_api_password. Choose this if the traefik api router is already configured via dynamic configuration elsewhere.

Added in version 1.1.

extra_dynamic_config c.TKvProxy.extra_dynamic_config = Dict()#

Extra dynamic configuration for treafik.

Merged with the default dynamic config during startup.

Always takes effect unless should_start and enable_setup_dynamic_config are both False.

extra_routes c.TKvProxy.extra_routes = Dict()#

Additional routes to be maintained in the proxy.

A dictionary with a route specification as key, and a URL as target. The hub will ensure this route is present in the proxy.

If the hub is running in host based mode (with JupyterHub.subdomain_host set), the routespec must have a domain component (example.com/my-url/). If the hub is not running in host based mode, the routespec must not have a domain component (/my-url/).

Helpful when the hub is running in API-only mode.

extra_static_config c.TKvProxy.extra_static_config = Dict()#

Extra static configuration for treafik.

Merged with the default static config before writing to .static_config_file.

Has no effect if Proxy.should_start is False.

flatten_dict_for_kv(data, prefix='')[source]#

Flatten a dictionary of data for storage in the KV store, prefixing each key with prefix and joining each key with TKvProxy.kv_separator.

If the final value is a list, then the provided bottom-level key shall be appended with an incrementing numeric number, in the style that is used by traefik’s KV store, e.g.

flatten_dict_for_kv({
    'x' : {
        'y' : {
            'z': 'a'
        }
    }, {
        'foo': 'bar'
    },
    'baz': [ 'a', 'b', 'c' ]
})
Returns:

The flattened dictionary

Return type:

dict

e.g.

{
     'traefik/x/y/z' : 'a',
     'traefik/x/foo': 'bar',
     'traefik/baz/0': 'a',
     'traefik/baz/1': 'b',
     'traefik/baz/2': 'c',
}

Inspired by this answer on StackOverflow

async 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)

kv_jupyterhub_prefix c.TKvProxy.kv_jupyterhub_prefix = KVStorePrefix('jupyterhub')#

The key value store key prefix for traefik dynamic configuration

kv_separator c.TKvProxy.kv_separator = Unicode('/')#

The separator used for the path in the KV store

kv_traefik_prefix c.TKvProxy.kv_traefik_prefix = KVStorePrefix('traefik')#

The key value store key prefix for traefik static configuration

should_start 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.

static_config_file c.TKvProxy.static_config_file = Unicode('traefik.toml')#

traefik’s static configuration file

toml_static_config_file c.TKvProxy.toml_static_config_file = Unicode('')#

Deprecated. Use static_config_file

traefik_api_entrypoint c.TKvProxy.traefik_api_entrypoint = Unicode('auth_api')#

The traefik entrypoint name to use for API access.

Separate from traefik_entrypoint, because this is usually only on localhost.

traefik_api_password c.TKvProxy.traefik_api_password = Unicode('')#

The password for traefik api login

traefik_api_url c.TKvProxy.traefik_api_url = Unicode('http://localhost:8099')#

traefik authenticated api endpoint url

traefik_api_username c.TKvProxy.traefik_api_username = Unicode('')#

The username for traefik api login

traefik_api_validate_cert c.TKvProxy.traefik_api_validate_cert = Bool(True)#

validate SSL certificate of traefik api endpoint

traefik_entrypoint c.TKvProxy.traefik_entrypoint = Unicode('')#

The traefik entrypoint name to use.

By default, will be http if http or https if https.

If running traefik externally with your own specified entrypoint name, set this value.

traefik_env c.TKvProxy.traefik_env = Dict()#

Environment variables to set for the traefik process.

Only has an effect when traefik is a subprocess (should_start=True).

traefik_log_level c.TKvProxy.traefik_log_level = Unicode('')#

traefik’s log level

traefik_providers_throttle_duration c.TKvProxy.traefik_providers_throttle_duration = Unicode('0s')#

throttle traefik reloads of configuration.

When traefik sees a change in configuration, it will wait this long before applying the next one. This affects how long adding a user to the proxy will take.

See https://doc.traefik.io/traefik/providers/overview/#providersprovidersthrottleduration

unflatten_dict_from_kv(kv_list, root_key='')[source]#

Reconstruct tree dict from list of key/value pairs

This is the inverse of flatten_dict_for_kv, not including str coercion.

Args:

kv_list (list):

list of (key, value) pairs. keys and values should all be strings.

root_key (str, optional):

The key representing the root of the tree, if not the root of the key-value store.

Returns:

tree (dict):

The reconstructed dictionary. All values will still be strings, even those that originated as numbers or booleans.

TraefikRedisProxy#

class jupyterhub_traefik_proxy.redis.TraefikRedisProxy(**kwargs: Any)[source]#

JupyterHub Proxy implementation using traefik and redis

check_route_timeout c.TraefikRedisProxy.check_route_timeout = Int(30)#

Timeout (in seconds) when waiting for traefik to register an updated route.

concurrency c.TraefikRedisProxy.concurrency = Int(10)#

The number of requests allowed to be concurrently outstanding to the proxy

Limiting this number avoids potential timeout errors by sending too many requests to update the proxy at once

enable_setup_dynamic_config c.TraefikRedisProxy.enable_setup_dynamic_config = Bool(True)#

Whether to initialize the traefik dynamic configuration from JupyterHub configuration, when should_start is False (dynamic configuration is always applied when should_start is True).

Creates the traefik API router and TLS setup, if any. When True, only traefik static configuration must be managed by the external service (configuration of the endpoints and provider). The traefik api router should not already be configured via other dynamic configuration providers.

When False, initial dynamic configuration must be handled externally and match TraefikProxy configuration, such as traefik_api_url, traefik_api_username` and traefik_api_password. Choose this if the traefik api router is already configured via dynamic configuration elsewhere.

Added in version 1.1.

extra_dynamic_config c.TraefikRedisProxy.extra_dynamic_config = Dict()#

Extra dynamic configuration for treafik.

Merged with the default dynamic config during startup.

Always takes effect unless should_start and enable_setup_dynamic_config are both False.

extra_routes c.TraefikRedisProxy.extra_routes = Dict()#

Additional routes to be maintained in the proxy.

A dictionary with a route specification as key, and a URL as target. The hub will ensure this route is present in the proxy.

If the hub is running in host based mode (with JupyterHub.subdomain_host set), the routespec must have a domain component (example.com/my-url/). If the hub is not running in host based mode, the routespec must not have a domain component (/my-url/).

Helpful when the hub is running in API-only mode.

extra_static_config c.TraefikRedisProxy.extra_static_config = Dict()#

Extra static configuration for treafik.

Merged with the default static config before writing to .static_config_file.

Has no effect if Proxy.should_start is False.

kv_jupyterhub_prefix c.TraefikRedisProxy.kv_jupyterhub_prefix = KVStorePrefix('jupyterhub')#

The key value store key prefix for traefik dynamic configuration

kv_separator c.TraefikRedisProxy.kv_separator = Unicode('/')#

The separator used for the path in the KV store

kv_traefik_prefix c.TraefikRedisProxy.kv_traefik_prefix = KVStorePrefix('traefik')#

The key value store key prefix for traefik static configuration

redis_client_kwargs c.TraefikRedisProxy.redis_client_kwargs = Dict()#

Additional keyword arguments to pass through to the redis.asyncio.Redis constructor

redis_password c.TraefikRedisProxy.redis_password = Unicode('')#

The redis password

redis_url c.TraefikRedisProxy.redis_url = Unicode('redis://localhost:6379')#

The URL for the redis endpoint

redis_username c.TraefikRedisProxy.redis_username = Unicode('')#

The redis username

should_start c.TraefikRedisProxy.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.

static_config_file c.TraefikRedisProxy.static_config_file = Unicode('traefik.toml')#

traefik’s static configuration file

toml_static_config_file c.TraefikRedisProxy.toml_static_config_file = Unicode('')#

Deprecated. Use static_config_file

traefik_api_entrypoint c.TraefikRedisProxy.traefik_api_entrypoint = Unicode('auth_api')#

The traefik entrypoint name to use for API access.

Separate from traefik_entrypoint, because this is usually only on localhost.

traefik_api_password c.TraefikRedisProxy.traefik_api_password = Unicode('')#

The password for traefik api login

traefik_api_url c.TraefikRedisProxy.traefik_api_url = Unicode('http://localhost:8099')#

traefik authenticated api endpoint url

traefik_api_username c.TraefikRedisProxy.traefik_api_username = Unicode('')#

The username for traefik api login

traefik_api_validate_cert c.TraefikRedisProxy.traefik_api_validate_cert = Bool(True)#

validate SSL certificate of traefik api endpoint

traefik_entrypoint c.TraefikRedisProxy.traefik_entrypoint = Unicode('')#

The traefik entrypoint name to use.

By default, will be http if http or https if https.

If running traefik externally with your own specified entrypoint name, set this value.

traefik_env c.TraefikRedisProxy.traefik_env = Dict()#

Environment variables to set for the traefik process.

Only has an effect when traefik is a subprocess (should_start=True).

traefik_log_level c.TraefikRedisProxy.traefik_log_level = Unicode('')#

traefik’s log level

traefik_providers_throttle_duration c.TraefikRedisProxy.traefik_providers_throttle_duration = Unicode('0s')#

throttle traefik reloads of configuration.

When traefik sees a change in configuration, it will wait this long before applying the next one. This affects how long adding a user to the proxy will take.

See https://doc.traefik.io/traefik/providers/overview/#providersprovidersthrottleduration

TraefikEtcdProxy#

class jupyterhub_traefik_proxy.etcd.TraefikEtcdProxy(**kwargs: Any)[source]#

JupyterHub Proxy implementation using traefik and etcd

check_route_timeout c.TraefikEtcdProxy.check_route_timeout = Int(30)#

Timeout (in seconds) when waiting for traefik to register an updated route.

concurrency c.TraefikEtcdProxy.concurrency = Int(10)#

The number of requests allowed to be concurrently outstanding to the proxy

Limiting this number avoids potential timeout errors by sending too many requests to update the proxy at once

enable_setup_dynamic_config c.TraefikEtcdProxy.enable_setup_dynamic_config = Bool(True)#

Whether to initialize the traefik dynamic configuration from JupyterHub configuration, when should_start is False (dynamic configuration is always applied when should_start is True).

Creates the traefik API router and TLS setup, if any. When True, only traefik static configuration must be managed by the external service (configuration of the endpoints and provider). The traefik api router should not already be configured via other dynamic configuration providers.

When False, initial dynamic configuration must be handled externally and match TraefikProxy configuration, such as traefik_api_url, traefik_api_username` and traefik_api_password. Choose this if the traefik api router is already configured via dynamic configuration elsewhere.

Added in version 1.1.

etcd_client_kwargs c.TraefikEtcdProxy.etcd_client_kwargs = Dict()#

Extra keyword arguments to pass to the etcd Python client constructor

etcd_password c.TraefikEtcdProxy.etcd_password = Unicode('')#

Password for accessing etcd.

etcd_url c.TraefikEtcdProxy.etcd_url = Unicode('http://127.0.0.1:2379')#

URL for the etcd endpoint.

etcd_username c.TraefikEtcdProxy.etcd_username = Unicode('')#

Username for accessing etcd.

extra_dynamic_config c.TraefikEtcdProxy.extra_dynamic_config = Dict()#

Extra dynamic configuration for treafik.

Merged with the default dynamic config during startup.

Always takes effect unless should_start and enable_setup_dynamic_config are both False.

extra_routes c.TraefikEtcdProxy.extra_routes = Dict()#

Additional routes to be maintained in the proxy.

A dictionary with a route specification as key, and a URL as target. The hub will ensure this route is present in the proxy.

If the hub is running in host based mode (with JupyterHub.subdomain_host set), the routespec must have a domain component (example.com/my-url/). If the hub is not running in host based mode, the routespec must not have a domain component (/my-url/).

Helpful when the hub is running in API-only mode.

extra_static_config c.TraefikEtcdProxy.extra_static_config = Dict()#

Extra static configuration for treafik.

Merged with the default static config before writing to .static_config_file.

Has no effect if Proxy.should_start is False.

kv_jupyterhub_prefix c.TraefikEtcdProxy.kv_jupyterhub_prefix = KVStorePrefix('jupyterhub')#

The key value store key prefix for traefik dynamic configuration

kv_password c.TraefikEtcdProxy.kv_password = Unicode('DEPRECATED')#

No help string is provided.

kv_separator c.TraefikEtcdProxy.kv_separator = Unicode('/')#

The separator used for the path in the KV store

kv_traefik_prefix c.TraefikEtcdProxy.kv_traefik_prefix = KVStorePrefix('traefik')#

The key value store key prefix for traefik static configuration

kv_url c.TraefikEtcdProxy.kv_url = Unicode('DEPRECATED')#

No help string is provided.

kv_username c.TraefikEtcdProxy.kv_username = Unicode('DEPRECATED')#

No help string is provided.

should_start 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.

static_config_file c.TraefikEtcdProxy.static_config_file = Unicode('traefik.toml')#

traefik’s static configuration file

toml_static_config_file c.TraefikEtcdProxy.toml_static_config_file = Unicode('')#

Deprecated. Use static_config_file

traefik_api_entrypoint c.TraefikEtcdProxy.traefik_api_entrypoint = Unicode('auth_api')#

The traefik entrypoint name to use for API access.

Separate from traefik_entrypoint, because this is usually only on localhost.

traefik_api_password c.TraefikEtcdProxy.traefik_api_password = Unicode('')#

The password for traefik api login

traefik_api_url c.TraefikEtcdProxy.traefik_api_url = Unicode('http://localhost:8099')#

traefik authenticated api endpoint url

traefik_api_username c.TraefikEtcdProxy.traefik_api_username = Unicode('')#

The username for traefik api login

traefik_api_validate_cert c.TraefikEtcdProxy.traefik_api_validate_cert = Bool(True)#

validate SSL certificate of traefik api endpoint

traefik_entrypoint c.TraefikEtcdProxy.traefik_entrypoint = Unicode('')#

The traefik entrypoint name to use.

By default, will be http if http or https if https.

If running traefik externally with your own specified entrypoint name, set this value.

traefik_env c.TraefikEtcdProxy.traefik_env = Dict()#

Environment variables to set for the traefik process.

Only has an effect when traefik is a subprocess (should_start=True).

traefik_log_level c.TraefikEtcdProxy.traefik_log_level = Unicode('')#

traefik’s log level

traefik_providers_throttle_duration c.TraefikEtcdProxy.traefik_providers_throttle_duration = Unicode('0s')#

throttle traefik reloads of configuration.

When traefik sees a change in configuration, it will wait this long before applying the next one. This affects how long adding a user to the proxy will take.

See https://doc.traefik.io/traefik/providers/overview/#providersprovidersthrottleduration

TraefikConsulProxy#

class jupyterhub_traefik_proxy.consul.TraefikConsulProxy(**kwargs: Any)[source]#

JupyterHub Proxy implementation using traefik and Consul

check_route_timeout c.TraefikConsulProxy.check_route_timeout = Int(30)#

Timeout (in seconds) when waiting for traefik to register an updated route.

concurrency c.TraefikConsulProxy.concurrency = Int(10)#

The number of requests allowed to be concurrently outstanding to the proxy

Limiting this number avoids potential timeout errors by sending too many requests to update the proxy at once

consul_client_kwargs c.TraefikConsulProxy.consul_client_kwargs = Dict()#

Extra consul client constructor arguments

consul_password c.TraefikConsulProxy.consul_password = Unicode('')#

Password or token for accessing consul.

consul_url c.TraefikConsulProxy.consul_url = Unicode('http://127.0.0.1:8500')#

URL for the consul endpoint.

consul_username c.TraefikConsulProxy.consul_username = Unicode('')#

Usrname for accessing consul.

enable_setup_dynamic_config c.TraefikConsulProxy.enable_setup_dynamic_config = Bool(True)#

Whether to initialize the traefik dynamic configuration from JupyterHub configuration, when should_start is False (dynamic configuration is always applied when should_start is True).

Creates the traefik API router and TLS setup, if any. When True, only traefik static configuration must be managed by the external service (configuration of the endpoints and provider). The traefik api router should not already be configured via other dynamic configuration providers.

When False, initial dynamic configuration must be handled externally and match TraefikProxy configuration, such as traefik_api_url, traefik_api_username` and traefik_api_password. Choose this if the traefik api router is already configured via dynamic configuration elsewhere.

Added in version 1.1.

extra_dynamic_config c.TraefikConsulProxy.extra_dynamic_config = Dict()#

Extra dynamic configuration for treafik.

Merged with the default dynamic config during startup.

Always takes effect unless should_start and enable_setup_dynamic_config are both False.

extra_routes c.TraefikConsulProxy.extra_routes = Dict()#

Additional routes to be maintained in the proxy.

A dictionary with a route specification as key, and a URL as target. The hub will ensure this route is present in the proxy.

If the hub is running in host based mode (with JupyterHub.subdomain_host set), the routespec must have a domain component (example.com/my-url/). If the hub is not running in host based mode, the routespec must not have a domain component (/my-url/).

Helpful when the hub is running in API-only mode.

extra_static_config c.TraefikConsulProxy.extra_static_config = Dict()#

Extra static configuration for treafik.

Merged with the default static config before writing to .static_config_file.

Has no effect if Proxy.should_start is False.

kv_jupyterhub_prefix c.TraefikConsulProxy.kv_jupyterhub_prefix = KVStorePrefix('jupyterhub')#

The key value store key prefix for traefik dynamic configuration

kv_password c.TraefikConsulProxy.kv_password = Unicode('DEPRECATED')#

No help string is provided.

kv_separator c.TraefikConsulProxy.kv_separator = Unicode('/')#

The separator used for the path in the KV store

kv_traefik_prefix c.TraefikConsulProxy.kv_traefik_prefix = KVStorePrefix('traefik')#

The key value store key prefix for traefik static configuration

kv_url c.TraefikConsulProxy.kv_url = Unicode('DEPRECATED')#

No help string is provided.

kv_username c.TraefikConsulProxy.kv_username = Unicode('DEPRECATED')#

No help string is provided.

should_start 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.

static_config_file c.TraefikConsulProxy.static_config_file = Unicode('traefik.toml')#

traefik’s static configuration file

toml_static_config_file c.TraefikConsulProxy.toml_static_config_file = Unicode('')#

Deprecated. Use static_config_file

traefik_api_entrypoint c.TraefikConsulProxy.traefik_api_entrypoint = Unicode('auth_api')#

The traefik entrypoint name to use for API access.

Separate from traefik_entrypoint, because this is usually only on localhost.

traefik_api_password c.TraefikConsulProxy.traefik_api_password = Unicode('')#

The password for traefik api login

traefik_api_url c.TraefikConsulProxy.traefik_api_url = Unicode('http://localhost:8099')#

traefik authenticated api endpoint url

traefik_api_username c.TraefikConsulProxy.traefik_api_username = Unicode('')#

The username for traefik api login

traefik_api_validate_cert c.TraefikConsulProxy.traefik_api_validate_cert = Bool(True)#

validate SSL certificate of traefik api endpoint

traefik_entrypoint c.TraefikConsulProxy.traefik_entrypoint = Unicode('')#

The traefik entrypoint name to use.

By default, will be http if http or https if https.

If running traefik externally with your own specified entrypoint name, set this value.

traefik_env c.TraefikConsulProxy.traefik_env = Dict()#

Environment variables to set for the traefik process.

Only has an effect when traefik is a subprocess (should_start=True).

traefik_log_level c.TraefikConsulProxy.traefik_log_level = Unicode('')#

traefik’s log level

traefik_providers_throttle_duration c.TraefikConsulProxy.traefik_providers_throttle_duration = Unicode('0s')#

throttle traefik reloads of configuration.

When traefik sees a change in configuration, it will wait this long before applying the next one. This affects how long adding a user to the proxy will take.

See https://doc.traefik.io/traefik/providers/overview/#providersprovidersthrottleduration