k8s ingress配置wss编排模板
作者:互联网
前段时间遇到了一个k8s配置websocket的问题,需要配置一下,由于wss比较安全,结合tls证书才能配置成功,如果是ws则无法在https的网站上面直接使用,wss才行。下面给出配置文件,希望帮助到需要的伙伴。
配置一个新的单独为所有websocket服务服务的ingress
参考文档:
https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/annotations/#configuration-snippet
新增一个配置如下的ingress 文件名为 websocket-ingress.yaml
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/configuration-snippet: |
proxy_set_header Upgrade "websocket";
proxy_set_header Connection "Upgrade";
name: demo-ingress
namespace: third
spec:
rules:
- host: 域名
http:
paths:
- backend:
serviceName: demo-svc
servicePort: 8893
path: /
tls:
- hosts:
- 域名
secretName: tls-https
status:
loadBalancer:
ingress:
- ip: 域名对应的dns ip
标签:tls,ingress,configuration,websocket,nginx,wss,k8s 来源: https://blog.csdn.net/sinat_27970175/article/details/120267767