Kubernetes入口Websockets连接问题

编程入门 行业动态 更新时间:2024-10-14 06:25:58
本文介绍了Kubernetes入口Websockets连接问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在带有KOPS的AWS上部署了k8. 我已经创建了nginx入口 github/kubernetes/ingress-nginx nginx入口控制器图像:quay.io/kubernetes入口控制器/nginx入口控制器:0.18.0

Deployed k8s on AWS with KOPS. I have created nginx ingress github/kubernetes/ingress-nginx nginx-ingress-controller image: quay.io/kubernetes-ingress-controller/nginx-ingress-controller:0.18.0

一切正常,我可以使用由nginx服务创建的aws classic负载均衡器从外部访问应用程序.

Everything is up and running and I could able to access applications externally using aws classic load balancer which is created by nginx service.

最近,我们开始研究websocket.我在k8s中部署了服务,并尝试从外部进行访问.

Recently we started working on websockets. I deployed my services in k8s and trying to access externally.

我为我的应用程序创建了服务和入口.现在,Ingress指向的是loadbalancer(位于json文件下方).

I created service and ingress for my application. Ingress is now pointing to loadbalancer(below json file).

我在aws中创建了route53条目并尝试连接到该条目,但是当我尝试通过chrome浏览器从客户端应用程序进行连接时,却出现错误提示

I created route53 entry in aws and trying to connect to that but I am getting below error when I am trying to connect from my client application through chrome browser

与'wss://blockchain.aro/socket.io/?EIO = 3& transport = websocket'的WebSocket连接失败:WebSocket握手期间出错:意外的响应代码:400

WebSocket connection to 'wss://blockchain.aro/socket.io/?EIO=3&transport=websocket' failed: Error during WebSocket handshake: Unexpected response code: 400

我尝试创建应用程序负载平衡器,但无法连接到wss://<host>

I tried creating Application load balancer but I could not able to connect to wss://<host>

错误:

WebSocket连接到 'wss://blockchain.aro/socket.io/?EIO = 3& transport = websocket'失败: WebSocket握手期间出错:意外的响应代码:400

WebSocket connection to 'wss://blockchain.aro/socket.io/?EIO=3&transport=websocket' failed: Error during WebSocket handshake: Unexpected response code: 400

const config: SocketIoConfig = { url: 'wss://blockchain.aro', options: { autoConnect: false, transports: ['websocket']} }; Ingress: "annotations": { "kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"extensions/v1beta1\",\"kind\":\"Ingress\",\"metadata\":{\"annotations\":{},\"name\":\"blockchain\",\"namespace\":\"adapt\"},\"spec\":{\"rules\":[{\"host\":\"blockchain.aro\",\"http\":{\"paths\":[{\"backend\":{\"serviceName\":\"blockchain\",\"servicePort\":8097},\"path\":\"/\"},{\"backend\":{\"serviceName\":\"blockchain\",\"servicePort\":8097},\"path\":\"/socket.io\"},{\"backend\":{\"serviceName\":\"blockchain\",\"servicePort\":8097},\"path\":\"/ws/\"}]}}],\"tls\":[{\"hosts\":[\"blockchain.aro\"],\"secretName\":\"blockchain-tls-secret\"}]}}\n", "nginx.ingress.kubernetes.io/proxy-read-timeout": "3600", "nginx.ingress.kubernetes.io/proxy-send-timeout": "3600" }

包含在入口文件中的tls和secretname和rules.我尝试创建ApplicationLoadbalancer,但也无法与此连接.

included tls and secretname and rules in ingress file. I tried creating ApplicationLoadbalancer but I could not able to connect with that too.

推荐答案

apiVersion: extensions/v1beta1 kind: Ingress metadata: annotations: certmanager.k8s.io/cluster-issuer: core-prod kubernetes.io/ingress.class: nginx nginx.ingress.kubernetes.io/proxy-read-timeout: "1800" nginx.ingress.kubernetes.io/proxy-send-timeout: "1800" nginx.ingress.kubernetes.io/rewrite-target: / nginx.ingress.kubernetes.io/secure-backends: "true" nginx.ingress.kubernetes.io/ssl-redirect: "true" nginx.ingress.kubernetes.io/websocket-services: core-service nginx/websocket-services: core-service name: core-ingress spec: rules: - host: test.io http: paths: - backend: serviceName: core-service servicePort: 80 tls: - hosts: - test.io secretName: core-prod

更多推荐

Kubernetes入口Websockets连接问题

本文发布于:2023-11-25 20:39:34,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1631270.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:入口   Kubernetes   Websockets

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!