<p>I try to start RStudio in docker container via <code>kubernetes</code>. All objects are created, but when I try to open rstudio using such commands in Ubuntu 18: </p>

<pre><code>kubectl create -f rstudio-ing.yml    
IP=$(minikube ip)
xdg-open http://$IP/rstudio/
</code></pre>

<p>there is error: <code>#RStudio initialization error: unable connect to service</code>. </p>

<p>Usual docker command works fine:</p>

<pre><code>docker run -d -p 8787:8787 -e PASSWORD=123 -v /home/aabor/r-projects:/home/rstudio aabor/rstudio
</code></pre>

<p>The same intended operation in <code>kubernetes</code> fails. </p>

<p><code>rstudio-ing.yml</code> file creates all objects well. RStudio is accessible if I do not mount any folder. But if I add folder mounts it produces an error. Any suggestions?</p>

<p>The content of the <code>rstudio-ing.yml</code>:</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: r-ingress
  annotations:
    kubernetes.io/ingress.class: "nginx"
    ingress.kubernetes.io/ssl-redirect: "false"
    nginx.ingress.kubernetes.io/ssl-redirect: "false"
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  rules:
  - http:
      paths:
      - path: /rstudio/
        backend:
          serviceName: rstudio
          servicePort: 8787

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: rstudio
spec:
  replicas: 1
  selector:
    matchLabels:
      service: rstudio
  template:
    metadata:
      labels:
        service: rstudio
        language: R
    spec:
      containers:
      - name: rstudio
        image: aabor/rstudio
        env:
        - name: PASSWORD
          value: "123"
        volumeMounts:
        - name: home-dir
          mountPath: /home/rstudio/
      volumes: 
      - name: home-dir
        hostPath: 
        #RStudio initialization error: unable connect to service
          path: /home/aabor/r-projects 

---

apiVersion: v1
kind: Service
metadata:
  name: rstudio
spec:
  ports:
  - port: 8787
  selector:
    service: rstudio
</code></pre>

<p>This is pod description:</p>

<pre><code>    Name:           rstudio-689c4fd6c8-fgt7w
    Namespace:      default
    Node:           minikube/10.0.2.15
    Start Time:     Fri, 23 Nov 2018 21:42:35 +0300
    Labels:         language=R
                    pod-template-hash=2457098274
                    service=rstudio
    Annotations:    &lt;none&gt;
    Status:         Running
    IP:             172.17.0.9
    Controlled By:  ReplicaSet/rstudio-689c4fd6c8
    Containers:
    rstudio:
        Container ID:   docker://a6bdcbfdf8dc5489a4c1fa6f23fb782bc3d58dd75d50823cd370c43bd3bffa3c
        Image:          aabor/rstudio
        Image ID:       docker-pullable://aabor/rstudio@sha256:2326e5daa3c4293da2909f7e8fd15fdcab88b4eb54f891b4a3cb536395e5572f
        Port:           &lt;none&gt;
        Host Port:      &lt;none&gt;
        State:          Running
        Started:      Fri, 23 Nov 2018 21:42:39 +0300
        Ready:          True
        Restart Count:  0
        Environment:
        PASSWORD:  123
        Mounts:
        /home/rstudio/ from home-dir (rw)
        /var/run/secrets/kubernetes.io/serviceaccount from default-token-mrkd8 (ro)
    Conditions:
    Type           Status
    Initialized    True 
    Ready          True 
    PodScheduled   True 
    Volumes:
    home-dir:
        Type:          HostPath (bare host directory volume)
        Path:          /home/aabor/r-projects
        HostPathType:  
    default-token-mrkd8:
        Type:        Secret (a volume populated by a Secret)
        SecretName:  default-token-mrkd8
        Optional:    false
    QoS Class:       BestEffort
    Node-Selectors:  &lt;none&gt;
    Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300s
                    node.kubernetes.io/unreachable:NoExecute for 300s
    Events:
    Type    Reason                 Age   From               Message
    ----    ------                 ----  ----               -------
    Normal  Scheduled              10s   default-scheduler  Successfully assigned rstudio-689c4fd6c8-fgt7w to minikube
    Normal  SuccessfulMountVolume  10s   kubelet, minikube  MountVolume.SetUp succeeded for volume "home-dir"
    Normal  SuccessfulMountVolume  10s   kubelet, minikube  MountVolume.SetUp succeeded for volume "default-token-mrkd8"
    Normal  Pulling                9s    kubelet, minikube  pulling image "aabor/rstudio"
    Normal  Pulled                 7s    kubelet, minikube  Successfully pulled image "aabor/rstudio"
    Normal  Created                7s    kubelet, minikube  Created container
    Normal  Started                6s    kubelet, minikube  Started container
</code></pre>

<p>You have created a service of type <code>ClusterIP</code> that can only be possible to access in the cluster not the outside. So to make it available outside of the cluster, change the service type <code>LoadBalancer</code>.</p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: rstudio
spec:
  ports:
  - port: 8787
  selector:
    service: rstudio
  type: LoadBalancer
</code></pre>

<p>In that case, the loadbalancer type service don't need the ingress and use the url as:</p>

<pre><code>$ minikube service rstudio --url
</code></pre>
