I'm losing my mind with shiny + Kubernetes

Hi,

I am going through a very weird situation and I feel desperate.

In short my issue is: My shiny app works perfectly locally and isolated on a docker image,
but for some odd reason it does not work properly on Google Kubernetes engine.

the exact same docker image just does not load the app properly at all.

And here is what inspect element says:

I'm not putting images of my app because I can only put one image, but as you can see from the inspect element, it doesn't load properly.

Here is my dockerfile:


FROM rocker/shiny-verse:3.6.0

RUN apt-get -y install default-jre

RUN apt-get -y install default-jdk

RUN sudo apt-get -y install libbz2-dev

RUN sudo apt-get install liblzma-dev

RUN install2.r --error \
    rJava \
    solitude \
    tidytext \
    shinythemes \
    future \
    promises \
    DT \
    plotly \
    RAdwords \
    devtools \
    remotes
    
RUN R -e "remotes::install_github('rstudio/httpuv')"
  
COPY /app /srv/shiny-server
COPY shiny-server.conf /etc/shiny-server/shiny-server.conf

CMD ["/usr/bin/shiny-server.sh"]

My folder structure:

- Docker-file
- shiny-server.conf
- app
    - server.R
    - ui.R
    - www
         - logo.png

My r-ingress-nginx.yaml


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

I have tried to install the latest httpuv version and install Shiny 1.2.0 to no success, same thing happens.

I stopped using nginx and now it suddenly works.

But I still want to use nginx, so if anyone has any ideas please help me.

I am encountering the exact same problems while deploying on k8s.
Changing path from /myapp/ to / gets the app served just fine by Nginx.

Reading around this might be related to proxying Shiny websockets, I haven't quite understood how to move forward on this one.

From a chat with Mark Edmonson it looks like Nginx recently changed their way of handling rewrite targets, which is now using captured groups.

My nginx-ingress now looks like the following:


apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: r-ingress-nginx
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/rewrite-target: /$2
    nginx.ingress.kubernetes.io/websocket-services: "shiny1" # this doesn't help
    nginx.ingress.kubernetes.io/ssl-redirect: "false"
  name: rewrite
  namespace: default

spec:
  rules:
  - http:
      paths:
      - backend:
            serviceName: shiny1
            servicePort: 80
        path: /wordcloud(/|$)(.*)
      - backend:
            serviceName: shiny2
            servicePort: 3838
        path: /lab/*

But I'm still having websocket-related problems (the app greyes out after page has finished loading):

Hope this helps

Just noticed this post talking about the websockets ordeal.

It isn't clear to me how to implement that conf snippet in my nginx-ingress.yaml but I believe it is the right direction.

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.