Skip to main content

Spawns JupyterHub single user servers in Docker containers running in AWS Fargate

Project description

fargatespawner

Spawns JupyterHub single user notebook servers in Docker containers running in AWS Fargate

Installation

pip install fargatespawner

Configuration

To configure JupyterHub to use FargateSpawner, you can add the following to your jupyterhub_config.py.

from fargatespawner import FargateSpawner
c.JupyterHub.spawner_class = FargateSpawner

You must also set the following settings on c.FargateSpawner in your jupyterhub_config.py. None of them are optional.

Setting Description Example
aws_region The AWS region in which the tasks are launched. 'eu-west-1'
aws_host The hostname of the AWS ECS API. Typically, this is of the form ecs.<aws-region>.amazonaws.com. 'ecs.eu-west-1.amazonaws.com'
aws_access_key_id The ID of the AWS access key used to sign the requests to the AWS ECS API. ommitted
aws_secret_access_key The secret part of the AWS access key used to sign the requests to the AWS ECS API . ommitted
task_role_arn The role the notebook tasks can assume. For example, in order for them to make requests to AWS, such as to use Jupyter S3 with role-based authentication. 'arn:aws:iam::123456789012:role/notebook-task'
task_cluster_name The name of the ECS cluster in which the tasks are launched. 'jupyerhub-notebooks'
task_container_name The name of the container in the task definition. 'jupyerhub-notebook'
task_definition_arn The family and revision (family:revision) or full ARN of the task definition that runs the notebooks. Typically, this task definition would specify a docker image that builds on one of those from https://github.com/jupyter/docker-stacks. 'jupyterhub-notebook:7'
task_security_groups The security group(s) associated with the Fargate tasks. These must allow communication to and from the hub/proxy. More information, such as the ports used, is at https://jupyterhub.readthedocs.io/en/stable/getting-started/networking-basics.html. ['sg-00026fc201a4e374b']
task_subnets The subnets associated with the Fargate tasks. ['subnet-01fc5f15ac710c012'] }
notebook_port The port the notebook servers listen on. 8888
notebook_scheme The scheme used by the hub and proxy to connect to the notebook servers. At the time of writing 'https' will not work out of the box. However, users do not connect to the the notebook server directly, and does not, typically, allow incoming connections from the public internet. Instead, users connect to the proxy, which can be configured to listen on HTTPS independently of this setting. There is more information on setting up HTTPS for connections to the proxy at https://jupyterhub.readthedocs.io/en/stable/getting-started/security-basics.html. 'http'
notebook_args Additional arguments to be passed to jupyterhub-singleuser that starts each notebook server. This can be the empty list. ['--config=notebook_config.py']

Run-time dependencies

The spawner is deliberately written to not have any additional dependencies, beyond those that are required for JupyterHub.

Approximate minimum permissions

In order for the user to be able to start, monitor, and stop the tasks, they should have the below permissions.

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "",
      "Effect": "Allow",
      "Action": "ecs:RunTask",
      "Resource": "arn:aws:ecs:<aws_region>:<aws_account_id>:task-definition/<task_family>:*",
      "Condition": {
        "ArnEquals": {
          "ecs:cluster": "arn:aws:ecs:<aws_region>:<aws_account_id>:cluster/<cluster_name>"
        }
      }
    },
    {
      "Sid": "",
      "Effect": "Allow",
      "Action": "ecs:StopTask",
      "Resource": "arn:aws:ecs:<aws_region>:<aws_account_id>:task/*",
      "Condition": {
        "ArnEquals": {
          "ecs:cluster": "arn:aws:ecs:<aws_region>:<aws_account_id>:cluster/<cluster_name>"
        }
      }
    },
    {
      "Sid": "",
      "Effect": "Allow",
      "Action": "ecs:DescribeTasks",
      "Resource": "arn:aws:ecs:<aws_region>:<aws_account_id>:task/*",
      "Condition": {
        "ArnEquals": {
          "ecs:cluster": "arn:aws:ecs:<aws_region>:<aws_account_id>:cluster/<cluster_name>"
        }
      }
    },
    {
      "Sid": "",
      "Effect": "Allow",
      "Action": "iam:PassRole",
      "Resource": [
        "arn:aws:iam::<aws_account_id>:role/<task-execution-role>",
        "arn:aws:iam::<aws_account_id>:role/<task-role>"
      ]
    }
  ]
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fargatespawner-0.0.18.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fargatespawner-0.0.18-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file fargatespawner-0.0.18.tar.gz.

File metadata

  • Download URL: fargatespawner-0.0.18.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.5

File hashes

Hashes for fargatespawner-0.0.18.tar.gz
Algorithm Hash digest
SHA256 2a29ad6f0813b40c533c332f9cbcb39a2274f1df2791932cf6c6a57c2400d55e
MD5 01d31ea840eb32e9e6acdfb601bf470e
BLAKE2b-256 a64a452b63a9f2e90dd3952611cf4f041bc59b63140933ff3f23dd98d8c5a797

See more details on using hashes here.

File details

Details for the file fargatespawner-0.0.18-py3-none-any.whl.

File metadata

  • Download URL: fargatespawner-0.0.18-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.5

File hashes

Hashes for fargatespawner-0.0.18-py3-none-any.whl
Algorithm Hash digest
SHA256 37f3afc4eca54b50fcef3b615461a600c9d32162e6fad1d0505906a68956228e
MD5 0e01bc55229cd10b7164d030b209dea4
BLAKE2b-256 c87e049de40708e917fc21634373a49b0447b4748f77e6d6b78c726ba736a5d1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page