我有一个 k8s 1.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
服务?
假设您使用的是Nginx入口控制器,则需要添加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