0

我有一个 k8s1.9.0集群,以下是我的入口规则。

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
 name: my-ingress
 labels:
  app: report
annotations:
  ingress.kubernetes.io/rewrite-target: /
spec:
 rules:
  - host: "gayan.test.com"
    http:
     paths:
      - path: /report
        backend:
         serviceName: qc-report-svc
         servicePort: 80
     - path: /report/*
        backend:
         serviceName: qc-report-svc
         servicePort: 80

所以我有两个要求。

请求一-https://gayan.test.com/report/ping此请求命中 pod 并返回响应。( GET /ping 200 302.079 ms - 63)

请求二- wss://gayan.test.com/report/socket.io/?EIO=3&transport=websocket。这个请求甚至没有到达服务器。我认为这与入口规则有关。

我的问题是如何将所有/report流量发送到qc-report-svc服务?

4

1 回答 1

1

假设您使用的是 Nginx Ingress Controller,您需要添加nginx.org/websocket-services注释以启用 WebSocket 支持。

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
 name: my-ingress
 labels:
   app: report
annotations:
  ingress.kubernetes.io/rewrite-target: /
  nginx.org/websocket-services: "qc-report-svc"
spec:
 rules:
  - host: "gayan.test.com"
    http:
     paths:
      - path: /report
        backend:
         serviceName: qc-report-svc
         servicePort: 80
于 2018-01-08T18:13:55.073 回答