Search code examples
kubernetesjupytergoogle-kubernetes-engine

Setting up JupyterHub on K8s: Can I forward the user to different node pool (cpu vs. gpu)


I am currently investigating whether it's worth to setup Jupyter on K8s. I came across this website: https://z2jh.jupyter.org/en/latest/index.html. One of the questions I have is forwarding a user to appropriate node pool. I will have 2. One is with CPU running and one with GPU active. I don't want all of the users to be automatically using GPU but rather reserve GPU for couple of data scientists that actually need it. Everyone else should be using CPU node-pool.

I am trying to figure out if there is a way to either forward the user to appropriate nodepool based on his credentials, or any other way.


Solution

  • Side note: I definitely think it is worth setting up Jupyterhub on Kubernetes if you plan to have multiple users and want to dynamically scale your resources rather than manual or pre-provisioning environments for each user.

    To answer your question, it is possible to set things up in a way which meets your requirements.

    You'll need to:

    1. Set up at least two different profiles (one for CPU only and one for GPUs). In the profile for GPUs, you'd use the extra_resource_guarantee property of the kubespawner_override to set the GPU guarantee. Alternatively, you can use the node_affinity_required property to only choose nodes with GPUs (assuming nodes are labeled) or you can use the node_selector property (for example, with GKE you could set this to select nodes with specific types of GPUs using the key cloud.google.com/gke-accelerator)

    2. Enable user-dependent profiles such that only select users will see the GPU profile option.