kubernetes - Istio Ingress 路由失败,对 Kubernetes 中的 Shiny 服务器出现 400 Bad request

标签 kubernetes shinydashboard kubernetes-ingress shiny-server istio

我正在 Kubernetes 中部署一个 Shiny 的服务器,它有 istio 入口。 我们还安装了一个正常运行的入口网关。

但是当我尝试通过网关访问我的 Shiny 服务器时,它失败并显示 400 Bad Request。 网关已启用 https。 我尝试对shiny-server.conf文件和shiny服务器的virtualservice.yml进行多次修改,但没有成功。我什至不知道如何进行进一步的故障排除。

请帮忙。

用于 Shiny 服务器应用程序的 Dockerfile

FROM rocker/shiny:3.6.3

# Install Ubuntu packages
RUN apt-get update && apt-get install sudo gdebi-core pandoc pandoc-citeproc libcurl4-gnutls-dev libxt-dev libssl-dev libxml2-dev libjpeg-dev -y


# Install R packages that are required

RUN R -e "install.packages(c('shiny', 'shinydashboardPlus', 'shinydashboard', 'jsonlite', 'dplyr', 'DT', 'config', 'shinyalert', 'curl', 'scales', 'plotly', 'shinyjs', 'data.table', 'shinythemes', 'gridExtra', 'ggplot2', 'httr', 'bsplus', 'shinyWidgets', 'ggiraph', 'ggiraphExtra', 'xml2', 'ggmap', 'leaflet', 'maps', 'viridis', 'htmlwidgets', 'zoo', 'reshape2', 'httpuv'), repos='http://cran.rstudio.com/')"

COPY /app /srv/shiny-server/executive/

EXPOSE 80

COPY shiny-server.conf  /etc/shiny-server/shiny-server.conf

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

Shiny-server.conf 文件:

# Define the user we should use when spawning R Shiny processes
run_as shiny;

# Define a top-level server which will listen on a port
server {
  # Instruct this server to listen on port 80. The app at dokku-alt need expose PORT 80, or 500 e etc. See the docs
  listen 80;

  # Define the location available at the base URL
  location / {

    # Run this location in 'site_dir' mode, which hosts the entire directory
    # tree at '/srv/shiny-server'
    app_dir /srv/shiny-server/executive;

    # Define where we should put the log files for this location
    log_dir /var/log/shiny-server;

    # Should we list the contents of a (non-Shiny-App) directory when the user
    # visits the corresponding URL?
    directory_index off;
  }
}

K8s部署:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: "executive"
  namespace: default
  labels:
    app: "executive"
spec:
  replicas: 1
  selector:
    matchLabels:
      app: "executive"
  template:
    metadata:
      labels:
        app: "executive"
    spec:
      containers:
        - name: "executive"
          image: appexecutive1
          imagePullPolicy: Always
          ports:
            - name: http
              containerPort: 80
              protocol: TCP
---
apiVersion: v1
kind: Service
metadata:
  name: "executive"
  namespace: default
spec:
  ports:
    - port: 80
      targetPort: 80
      protocol: TCP
  type: ClusterIP
  selector:
    app: "executive"
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: executive-ingress
  namespace: ingress-system
spec:
  hosts:
  - "*"
  gateways:
  - apollox-istio-gateway
  http:
  - match:
    - uri:
        prefix: /executive/
    rewrite:
        uri: /
    route:
    - destination:
        host: executive.default.svc.cluster.local
        port:
          number: 80

现在,当我尝试从系统中以下 URL 的网关访问它时,它会失败并显示 400 错误请求。 https://10.20.33.134:32000/executive/

需要一些帮助来确定原因或我应该采取什么方向。

感谢和问候。

最佳答案

现在似乎可以正常工作了。我忘记在最新的 Dockerfile 中添加 httpuv 包。 添加此包后,它开始工作。

谢谢。

关于kubernetes - Istio Ingress 路由失败,对 Kubernetes 中的 Shiny 服务器出现 400 Bad request,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63117317/

相关文章:

kubernetes - 如何列出一个kubernetes对象的所有resourceVersion?

kubernetes - 为什么 Fluent-bit 使用 varlibdockercontainers 卷?

javascript - 单击 Shiny 的操作按钮后,将光标聚焦在 textArea 中

r - 使用 includeHTML 时 sidebarMenu 无法正常工作

kubernetes - 网络负载均衡器如何与 Kubernetes (AWS/EKS) 中的入口 Controller 配合使用?

Python Kubernetes 客户端 : equivalent of kubectl get [custom-resource]

elasticsearch - 如何诊断 k8s pod 不断重启的原因?

r - shinydashboard:通过textInput过滤DT

Kubernetes 入口 Controller 返回 503 服务不可用

kubernetes-ingress - 使用 Kubernetes NGINX 入口 Controller 后面的相对 URL 托管 web 应用程序