我正在尝试公开托管在Kubernetes(Azure)窗格中的SignalR集线器。基本上,身份验证和握手步骤可以正常工作,但是当我触发某些操作时,通过k8s Ingress连接的所有客户端都不会收到该消息。是否有人遇到过此问题,或者是否刚刚通过Kubernetes-Ingress共享了SignalR集线器?
ingress.yml
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: endpoints
annotations:
kubernetes.io/ingress.class: addon-http-application-routing
ingress.kubernetes.io/ssl-redirect: "false"
nginx.ingress.kubernetes.io/ssl-redirect: "false"
nginx.org/websocket-services: "myservice"
spec:
rules:
- host: api.[MY-DOMAIN].com
http:
paths:
- backend:
serviceName: myservice
servicePort: 80
path: /myservice
答案 0 :(得分:2)
尝试:
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/ssl-redirect: "false"
nginx.ingress.kubernetes.io/affinity: cookie
nginx.ingress.kubernetes.io/session-cookie-hash: sha1
nginx.ingress.kubernetes.io/session-cookie-name: REALTIMESERVERID
如果您想要一个可行的示例,我不久前写了一个示例项目:DenisBiondic/RealTimeMicroservices
作为旁注,考虑使用Azure SignalR服务,它应该可以消除很多麻烦(同样在上面的示例中)。
答案 1 :(得分:0)
不熟悉SignalR,但可能有两件事。
经过身份验证后,SignalR集线器是否有可能尝试使用TLS?我看到您在不使用TLS的端口80上运行它。您将必须配置以下内容:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: endpoints
annotations:
kubernetes.io/ingress.class: addon-http-application-routing
ingress.kubernetes.io/ssl-redirect: "false" <== you may need to remove
nginx.ingress.kubernetes.io/ssl-redirect: "false" <== you may need to remove
nginx.org/websocket-services: "myservice"
spec:
rules:
- host: api.[MY-DOMAIN].com
http:
paths:
- backend:
serviceName: myservice
servicePort: 80
path: /myservice
tls:
- secretName: <your-tls-certs>
希望有帮助!