RStudio on Kubernetes

About

A few years ago I had an external drive that got damaged. I was able to repair it and I found many materials I thought were lost forever.

Amongst nice Shiny apps, I found some codes to run RStudio on Kubernetes. After some minimal changes, I was able to transform that into a one click application you can deploy on Kubernetes clusters.

1-Click install

Go to marketplace.digitalocean.com and search for “RStudio Kubernetes” to then select “Install App”.

f0 f1

Change the cluster region (i.e. to AMS or FRA) or any option you find it’s convenient, then proceed to install RStudio on a new or existing cluster. I installed on a new cluster for testing.

f2 f4

For a new cluster, select the number of nodes and then put the cluster under any project.

f5 f6

Getting started

The total setup time takes around 4 minutes. I’ve decided to automatically install patches and not to add additional applications.

The setup can be done from DigitalOcean site except for one step that involves pasting into the command line.

f7 f8 f9 f10 f11 f12

Once the top of the dashboard doesn’t show a progress bar anymore, the installation is ready. It shows a “Kubernetes Dashboard” button when it’s ready.

f13

Specific instructions

The specific instructions for RStudio consist in three steps.

First: List the pods on Kubernetes

~ $ kubectl get pods -A
NAMESPACE     NAME                          READY   STATUS    RESTARTS   AGE
...
rstudio       rstudio-12345-67890           1/1     Running   0           9m

Second: Forward port 8787 to access RStudio

~ $ kubectl -n rstudio port-forward deploy/rstudio 8787
Forwarding from 127.0.0.1:8787 -> 8787
Forwarding from [::1]:8787 -> 8787

Third: Log in to RStudio by visiting localhost:8787 from the browser. This Kubernetes instance uses rstudio for both user and password, to change that type passwd rstudio in RStudio’s terminal.

f14 f16 f17

Start running scripts

The next script took around 10 seconds including installing RPostgres package.

f18

Get free DigitalOcean credits

If you register with this link, you’ll get free credits to try DigitalOcean and I also get credits for my FOSS projects:

My DigitalOcean Referral Link
https://m.do.co/c/6119f0430dad

Shameless self-promotion: If you liked this post, I am an Applied Statistician with years of experience in R, Shiny, APIs, SQL and finance. If you think I can be a valuable addition for your team, I’m happy to read from you and provide more details. My email is mavargas 11 [ at ] uc dot cl or send me a tweet to pachadotdev.