Blog #aws #kubernetes #machine-learning
Install JupyterHub on AWS Elastic Kubernetes Service (EKS)
Field notes and step-by-step runbook for deploying multi-user, GPU-enabled JupyterHub on AWS EKS using custom Docker images and Zero to JupyterHub.
- Published
- Updated
- Reading
- 3 min
- Author
- Sudhanva Narayana
Adding a Custom User Environment
To add a new Python or ML environment to an existing JupyterHub deployment on EKS:
- Build a Dockerfile containing the libraries your team needs.
- Base your image on one of the official Jupyter Docker Stacks so the notebook server and hub hooks are already wired up.
- Push the custom image to Docker Hub (or ECR).
- Open
hub/config.yaml, which holds the Helm values for the Zero to JupyterHub deployment. - Register the new image under
singleuser.profileList; see the Zero to JupyterHub profile documentation for the exact schema. - Commit the change and run your Helm upgrade; JupyterHub will reload and surface the new profile in the server spawn menu.
- Restart your personal notebook server from the JupyterHub control panel to pick up the new image.
GPU-Enabled Docker Image
- To expose NVIDIA GPUs cleanly inside user notebooks, use
cschranz/gpu-jupyter. It is already preconfigured inconfig.yaml, so you can select it directly from the launcher. - Avoid stock
tensorflow/tensorflow:latest-gpuimages directly in JupyterHub, as mismatched CUDA/cuDNN paths and missing JupyterHub single-user entrypoints often prevent the notebook kernel from seeing the attached GPU.
Provisioning EKS from Scratch
Initial IAM Setup
Reference: AWS EKS Getting Started Guide
- Create an IAM group named
adminand attach theAdministratorAccesspolicy. - Create an IAM user with both programmatic (CLI) and AWS Management Console access, and add that user to
admin. - Enable virtual MFA (for example, Microsoft Authenticator or 1Password) on the AWS root account.
- Delete any root account access keys, sign out of root, and sign back in as your IAM user.
- Create an IAM role for CloudFormation with permissions to provision VPC and EKS resources.
Create the VPC
Reference: Creating a Public and Private VPC for EKS
- Attach the required EC2/VPC creation policies to your CloudFormation IAM role.
- Launch the official EKS CloudFormation VPC stack using the default Public and Private subnet topology.
Create the EKS Cluster
Reference: Modifying EKS Cluster Endpoint Access
- Create the cluster in the EKS console.
- Attach the subnets and security group created by your VPC CloudFormation stack (look for the security group with
ControlPlaneSecurityGroupin its name). - Configure cluster endpoint access (it defaults to Public).
Attach Worker Nodes (and Common Gotchas)
- GPU quota: New AWS accounts usually have a
0vCPU quota forGandPGPU instance families. Open a Service Quotas support ticket early if you need GPU node groups. - Nodes failing to join the cluster: If worker nodes spin up in EC2 but never register with
kubectl get nodes, check your public subnet settings. AWS occasionally defaultsMapPublicIpOnLaunchtofalse, so nodes come up without an outbound route to the EKS control plane. FlipMapPublicIpOnLaunchtotrueon the public subnets:- 5 Things You Need to Know to Add Worker Nodes in AWS EKS
- De-mystifying Cluster Networking for Amazon EKS Worker Nodes
- CloudFormation EC2 Subnet Reference
- EKS Worker Node Troubleshooting Gist (Liz Rice)
- Quick CLI check for
MapPublicIpOnLaunch:aws ec2 describe-subnets --filters "Name=vpc-id,Values=<your-vpc-id>" | grep 'MapPublicIpOnLaunch|SubnetId|VpcId|State'
JupyterHub Helm Configuration
- Follow the Zero to JupyterHub on Kubernetes guide for the base Helm chart install.
- AWS LoadBalancer port mismatch: By default, the Classic/NLB service annotation can route port 80/443 to the wrong backend port on the proxy pod. See zero-to-jupyterhub-k8s#1637 for the service annotations needed to expose the JupyterHub UI properly.
- Always pass
-n jhub(or switch your active context namespace tojhub) before runninghelm upgradeso you don’t accidentally deploy a second release intodefault.
Related work
Production ML context
See how this topic connects to production ML systems, infrastructure, and inference.