在这里报告一个解决方案以供将来参考,因为我在实现时找不到任何单一的资源
使用nginxinc/kubernetesingress控制器而不是使用kubernetesingress nginx。
问题始于portaliner v2.1.1,但如果您需要创建一个入口规则并传递标头,或者应用任何特定的规则。
问题代码:
Unable to upgrade the connection (err=websocket: the client is not using the websocket protocol: 'upgrade' token not found in 'Connection' header) (code=500)
WebSocket connection to 'ws://portainer.example.com/.....// failed
遵循Nginx websocket代理指南使用Nginx片段的最小解决方案:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: portainer-ingress
namespace: portainer
annotations:
nginx.org/location-snippets: |
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
spec:
ingressClassName: nginx
rules:
- host: portainer.example.com
http:
paths:
- path: /
backend:
service:
name: portainer
port:
number: 9000
pathType: Prefix
运行使用清单安装的Nginx入口控制器v1.10.1版本
helm.sh/chart: ingress-nginx-3.23.0
app.kubernetes.io/name: ingress-nginx
app.kubernetes.io/instance: ingress-nginx
app.kubernetes.io/version: 0.44.0
我希望这能帮助到作为参考的人