Installing packages in jupyterhub kubespawner nodes

3/13/2017

I have a jupyterhub running over a kubernetes cluster with kubespawner. As I understand it, kubespawner is, via kubernetes, spinning up dockers on my cluster that have their own python environment and storage area.

For some user, I am attempting to import rpy2 (or whatever, it's not important), and the package is not installed.

My questions:

Where do these dockers get their python environment (e.g. Is there a dockerfile I can edit somewhere)?

How to I get rpy2 installed for just that one docker session?

How do I get rpy2 installed for that user (if possible)?

How do I get rpy2 installed for everyone on the hub?

-- Scott
jupyter
jupyterhub
kubernetes

1 Answer

3/15/2017

Assuming you're using the official images (jupyterhub/jupyterhub) you'll find all installation steps in the related Dockerfile on hub.docker.com or on Github.

To install a package for just one (already running) container. You can use kubectl exec your-pod -- pip install xxx

To install it for every deployment you'd have to provide your own container and include that in your Deployment. I assume this would result in merging with the rpy2 image, which could be done with a Dockerfile like:

FROM jupyterhub/singleuser
RUN pip3 --no-cache-dir install \
   https://bitbucket.org/rpy2/rpy2/get/default.tar.gz && \
   rm -rf /root/.cache
-- pagid
Source: StackOverflow