jupyterhub / jupyter-rsession-proxy

Jupyter extensions for running an RStudio rsession proxy
BSD 3-Clause "New" or "Revised" License
120 stars 87 forks source link

Rstudio integration to Jupyterhub (z2jh) #73

Open navneetkrverma opened 5 years ago

navneetkrverma commented 5 years ago

I have installed jupyterhub on linux box using z2jh guide. i have configured multiple profile lists and i am able to work with the profiles given on z2jh document. (https://zero-to-jupyterhub.readthedocs.io/en/latest/user-environment.html#using-multiple-profiles-to-let-users-select-their-environment). I have followed #990 and #69 to set it up. However, when i tried the issue threads to add one more image for Rstudio in jupyter hub; it did not work for me and i keep getting 404 as follows:

404_rstudio

Steps which i followed: 1.) install and run z2jh

sudo install minikube /usr/local/bin
minikube start
sudo install ~/Downloads/VirtualBox-6.0-6.0.10_132072_el7-1.x86_64.rpm 
sudo rpm -i ~/Downloads/VirtualBox-6.0-6.0.10_132072_el7-1.x86_64.rpm 
curl https://raw.githubusercontent.com/kubernetes/helm/master/scripts/get | bash
kubectl --namespace kube-system create serviceaccount tiller
kubectl create clusterrolebinding tiller --clusterrole cluster-admin --serviceaccount=kube-system:tiller
helm init --service-account tiller --wait
kubectl patch deployment tiller-deploy --namespace=kube-system --type=json --patch='[{"op": "add", "path": "/spec/template/spec/containers/0/command", "value": ["/tiller", "--listen=localhost:44134"]}]'
kubectl config  get-context
helm version
#helm init --service-account tiller --wait
openssl rand -hex 32
mkdir z2jh
cd z2jh/
sl config.yaml
helm repo add jupyterhub https://jupyterhub.github.io/helm-chart/
helm repo update
helm repo list
RELEASE=jhub
NAMESPACE=jhub
helm upgrade --install $RELEASE jupyterhub/jupyterhub   --namespace $NAMESPACE    --version=0.8.2   --values config.yaml
kubectl config set-context $(kubectl config current-context) --namespace ${NAMESPACE:-jhub}
kubectl --namespace=jhub get pod
kubectl --namespace=jhub get svc proxy-public 
kubectl config current-config # cross check kube config
kubectl describe service proxy-public --namespace jhub
kubectl config cluster-info # to know cluster public ip
#couple of above kubectl commands i used to know ip and port where the jupyterhub is running.

2.) sl config.yaml in step 1

singleuser:
  defaultUrl: "/rstudio"
  memory:
    limit: 100M
    guarantee: 100M
  cpu:
    limit: .2
    guarantee: .1
    # Defines the default image
  image:
    name: jupyter/minimal-notebook
    tag: 2343e33dec46
  profileList:
    - display_name: "Minimal environment"
      description: "To avoid too much bells and whistles: Python."
      default: true
    - display_name: "Datascience environment"
      description: "If you want the additional bells and whistles: Python, R, and Julia."
      kubespawner_override:
        image: jupyter/datascience-notebook:2343e33dec46
    - display_name: "Spark environment"
      description: "The Jupyter Stacks spark image!"
      kubespawner_override:
        image: jupyter/all-spark-notebook:2343e33dec46
    - display_name: "Rstudio environment"
      description: "The rstudio Stacks image!"
      kubespawner_override:
        image: my_docker_artifactory/rstudio:v0.0.1
proxy:
  secretToken: "2b31007cb9bdc1111ec4d470543eea3411221150f2d04e9b4661d77cf8c"

3.) login to jh, and i see the options from profile list

Screen Shot 2019-08-28 at 8 54 14 PM

4.) choosing rstudio and click on spawn

404_rstudio

5.) rstudio dockerfile content

FROM jupyter/r-notebook

RUN python3 -m pip install jupyter-rsession-proxy
RUN cd /tmp/ && \
    git clone --depth 1 https://github.com/jupyterhub/jupyter-server-proxy && \
    cd jupyter-server-proxy/jupyterlab-server-proxy && \
    npm install && npm run build && jupyter labextension link . && \
    npm run build && jupyter lab build
# install rstudio-server
USER root
RUN apt-get update && \
    curl --silent -L --fail https://download2.rstudio.org/rstudio-server-1.1.419-amd64.deb > /tmp/rstudio.deb && \
    echo '24cd11f0405d8372b4168fc9956e0386 /tmp/rstudio.deb' | md5sum -c - && \
    apt-get install -y /tmp/rstudio.deb && \
    rm /tmp/rstudio.deb && \
    apt-get clean && rm -rf /var/lib/apt/lists/*
ENV PATH=$PATH:/usr/lib/rstudio-server/bin
USER $NB_USER

@mathematicalmichael @trallard @ablekh can you please help me out here?

Thanks

ablekh commented 5 years ago

@navneetkrverma You seem to be mixing up two different methods. For the jupyter-rsession-proxy method, you are not supposed to use RStudio profile entry - you will get an Rsession entry in the kernels menu. After installing and configuring jupyter-rsession-proxy and standard Z2JH setup (as described in https://github.com/jupyterhub/zero-to-jupyterhub-k8s/issues/990), you should be able to see and use RStudio menu entry (or set it up as default, if your cluster is dedicated to RStudio). On the other hand, if you want to use an alternative method (which I have used), you need to build relevant Docker image (using jupyter-repo2docker), push it to a public or private Docker registry and then reference it in your config.yaml (or values.yaml) file. After that, perform helm upgrade and it should work. I hope that this helps. Additional suggestion: edit code blocks and use triple backticks to make them readable.

navneetkrverma commented 5 years ago

Thanks for information @ablekh. I am not looking for launching rstudio from kernel. I want to launch it as part of profile list served to jupterhub spawner. S yes, i got clarity, i should not be installing jupyter-rsession-proxy. As I want profilelist solution for my use case, i am wondering how have you generated rstudio docker image using repo2docker? I would be using this image in profilelist as one more entry in jupyterhub config.yaml.

Thanks for suggestion to use triple backticks, updated that.

ablekh commented 5 years ago

@navneetkrverma You're welcome. I think that you still need jupyter-rsession-proxy (I used it, but I implemented RStudio solution as a separate cluster, not as profile list-based solution). If you want to use the latter, then you would need to somehow use Rocker Docker or similar images (that was my original idea - see discussion in https://github.com/jupyterhub/zero-to-jupyterhub-k8s/issues/990, but I have abandoned that idea due to lack of knowledge on how to actually use Rocker images with JupyterHub). Perhaps, somebody else could advise you on this, but, if you need the solution soon, I would use working approaches (RStudio as menu item or RStudio as a separate cluster).

Re: how to build your custom Docker image - see documentation: https://repo2docker.readthedocs.io (including this section: https://repo2docker.readthedocs.io/en/latest/howto/user_interface.html#rstudio).

riazarbi commented 5 years ago

I've built an RStudio image that presents as an option in a z2jh spawner options page and launches successfully.

The docker image is here.

This is a sample bash script that deploys the helm script and then updates the values.yaml.

It's suited to my purposes, but maybe it will help you?

navneetkrverma commented 5 years ago

Thank you @riazarbi for sharing your knowledge and insight. I will try these options and update them here by this weekend. Thanks

riazarbi commented 4 years ago

Hi @navneetkrverma did it work?