为RStudio和Shiny设置具有HTTP负载平衡入口的Kuberentes集群会导致错误页面 [英] Setting up a Kuberentes cluster with HTTP Load balancing ingress for RStudio and Shiny results in error pages

查看:206
本文介绍了为RStudio和Shiny设置具有HTTP负载平衡入口的Kuberentes集群会导致错误页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正尝试在Google Kubernetes Engine上创建一个集群,该集群运行nginx,RStudio服务器和两个Shiny应用程序,并遵循并改编

I'm attempting to create a cluster on Google Kubernetes Engine that runs nginx, RStudio server and two Shiny apps, following and adapting this guide.

我有4种工作负载,它们在用户界面中都是绿色的,通过以下方式部署:

I have 4 workloads that are all green in the UI, 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

然后它们都通过以下方式暴露为节点端口:

They were then all exposed as node ports via:

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

..在用户界面中都是绿色的.

..that are all green in the UI.

然后我部署了此Ingress后端

I then deployed this Ingress backend

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

结果是nginx路由工作得很好,我可以在家中看到"Welcome to nginx"网页,但是我得到了另外三个路径:

The result is that the nginx routing works great, I can see "Welcome to nginx" webpage from home, but the three other paths I get:

  • /rstudio/-Input/output error
  • /shiny1/-找不到页面(闪亮的404页面)
  • /shiny5/-找不到页面(闪亮的404页面)

RStudio和Shiny工作负载在通过单个负载均衡器公开时都可以工作,分别映射到8787和3838.

The RStudio and Shiny workloads both work when exposing via the single load balancer, mapped to 8787 and 3838 respectively.

有人可以指出我要去哪里了吗?

Can anyone point to where I'm going wrong?

问:

  • 是否需要修改Dockerfile,以便在请求"/"时它们都在端口80上显示200状态?我需要更换健康检查器吗?我尝试更改RStudio登录页面(如果未登录,则将302更改为/auth-sign-in),但是没有运气
  • RStudio和Shiny都需要websocket-这会影响吗?
  • 是否需要启用会话亲和力?我尝试添加带有IP的文件,但存在相同的错误.

推荐答案

根据Radek的建议,需要ingress.kubernetes.io/rewrite-target: /来重写您的请求.但是,GKE入口控制器当前不支持此功能,这是您收到404响应的原因.

As Radek suggested, ingress.kubernetes.io/rewrite-target: / is required to re-write your requests. However, this is not currently supported by the GKE ingress controller and is the reason that you're receiving 404 responses.

相反,在GKE上,您必须使用 nginx入口控制器.

Instead, on GKE, you must use an nginx ingress controller.

然后,您将能够为您的rstudio和闪亮的图像配置符合重写规则的入口:

You will then be able to configure ingress for your rstudio and shiny images that obeys 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/*

这篇关于为RStudio和Shiny设置具有HTTP负载平衡入口的Kuberentes集群会导致错误页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆