Configuring a Kuberentes Cluster with HTTP Access for Load Balancing for RStudio and Shiny Fails

I am trying to create a cluster in the Google Kubernetes Engine that runs nginx, an RStudio server and two Shiny applications, following and adapting this guide .

I have 4 workloads, all green in the user interface, deployed via:

kubectl run nginx --image=nginx --port=80 kubectl run rstudio --image gcr.io/gcer-public/persistent-rstudio:latest --port 8787 kubectl run shiny1 --image gcr.io/gcer-public/shiny-googleauthrdemo:latest --port 3838 kubectl run shiny5 --image=flaviobarros/shiny-wordcloud --port=80 

Then they were opened as node ports through:

 kubectl expose deployment nginx --target-port=80 --type=NodePort kubectl expose deployment rstudio --target-port=8787 --type=NodePort kubectl expose deployment shiny1 --target-port=3838 --type=NodePort kubectl expose deployment shiny5 --target-port=80 --type=NodePort 

.. are all green in the user interface.

Then I deployed this inner part of Ingress

 apiVersion: extensions/v1beta1 kind: Ingress metadata: name: r-ingress spec: rules: - http: paths: - path: / backend: serviceName: nginx servicePort: 80 - path: /rstudio/ backend: serviceName: rstudio servicePort: 8787 - path: /shiny1/ backend: serviceName: shiny1 servicePort: 3838 - path: /shiny5/ backend: serviceName: shiny5 servicePort: 80 

As a result, the nginx router works fine, I see the Welcome to nginx homepage, but three other paths that I get:

  • / rstudio / - Input/output error
  • / shiny1 / - Page not found (page Shiny 404)
  • / shiny5 / - Page not found (Page Brilliant 404)

RStudio and Shiny workloads work when exposed through a single load balancer, displayed 8787 and 3838, respectively.

Can someone please indicate where I am going wrong?

Qs:

  • Do I need to adapt Dockerfiles so that all of them set the status to 200 on port 80 when requesting "/"? Do I need to change the health check? I tried changing the login page to RStudio (this is 302 to / auth-sign-in if you are not logged in), but no luck
  • Both RStudio and Shiny need websockets - does this affect this?
  • Should there be attachment to the session? I tried to add this with IP, but with the same errors.
+5
source share
2 answers

As Radek suggested, re-writing your queries requires ingress.kubernetes.io/rewrite-target: / . However, this is not currently supported by the GKE login controller and is causing you to receive 404 responses.

Instead, on GKE, you should use the nginx input controller .

Then you can configure the input for your rstudio and brilliant images that obey the rewrite rule:

 apiVersion: extensions/v1beta1 kind: Ingress metadata: name: r-ingress annotations: kubernetes.io/ingress.class: "nginx" nginx.ingress.kubernetes.io/rewrite-target: / spec: rules: - http: paths: - backend: serviceName: rstudio servicePort: 8787 path: /rstudio/* - backend: serviceName: shiny1 servicePort: 3838 path: /shiny1/* - backend: serviceName: shiny5 servicePort: 80 path: /shiny5/* 
+2
source

the most likely problem is that when you go with this access, you attached your URI and then directly accesc (/ shiny1 / vs /), so your application is lost and has no content for this uri.

Using the Nginx Ingress Controller, you can use the annotation ingress.kubernetes.io/rewrite-target: / to reduce this and make sure that / has access even if there is a subfolder in the input path.

+4
source

Source: https://habr.com/ru/post/1274958/


All Articles