Problem is without ingress and setting my service as NodePort
I can access my node.js server outside of the Kubernetes Cluster via WebSocket connection in the client side which is running locally e.g., KX Platform using their q as programming language.
However, part of the architecture design we are required to use Ingress. But, using Ingress I cannot connect to the Pod with the server by WS connection.
Keep in mind, I'm running it locally not through minikube
but using Rancher Desktop
as context, as it was recommended by our SSE.
ingress-service.yaml
# Ingress
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: app-ingress
annotations:
# nginx.ingress.kubernetes.io/rewrite-target: /
# nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
# nginx.ingress.kubernetes.io/secure-backends: "true"
nginx.ingress.kubernetes.io/proxy-send-timeout: "3600"
nginx.ingress.kubernetes.io/proxy-read-timeout: "3600"
# nginx.ingress.kubernetes.io/configuration-snippet: |
# proxy_http_version 1.1;
# proxy_set_header Upgrade "websocket";
# proxy_set_header Connection "Upgrade";
nginx/websocket-services: "server-service"
spec:
ingressClassName: nginx
rules:
- host: example
http:
paths:
- path: /ws/
pathType: Prefix
backend:
service:
name: server-service
port:
number: 5005
server-service.yaml
# Service exposing pod internally to other pods
apiVersion: v1
kind: Service
metadata:
name: server-service
spec:
# type: NodePort
type: ClusterIP
selector:
nodejs-server: server
ports:
- protocol: TCP
port: 5005
targetPort: 5005
# nodePort: 30005
Terminal to check default hosts file content
# Kubernetes-managed hosts file.
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
fe00::0 ip6-mcastprefix
fe00::1 ip6-allnodes
fe00::2 ip6-allrouters
10.42.0.178 server-deployment-8b9cf4977-mc779
What's the problem here?
Problem is without ingress and setting my service as NodePort
I can access my node.js server outside of the Kubernetes Cluster via WebSocket connection in the client side which is running locally e.g., KX Platform using their q as programming language.
However, part of the architecture design we are required to use Ingress. But, using Ingress I cannot connect to the Pod with the server by WS connection.
Keep in mind, I'm running it locally not through minikube
but using Rancher Desktop
as context, as it was recommended by our SSE.
ingress-service.yaml
# Ingress
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: app-ingress
annotations:
# nginx.ingress.kubernetes.io/rewrite-target: /
# nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
# nginx.ingress.kubernetes.io/secure-backends: "true"
nginx.ingress.kubernetes.io/proxy-send-timeout: "3600"
nginx.ingress.kubernetes.io/proxy-read-timeout: "3600"
# nginx.ingress.kubernetes.io/configuration-snippet: |
# proxy_http_version 1.1;
# proxy_set_header Upgrade "websocket";
# proxy_set_header Connection "Upgrade";
nginx./websocket-services: "server-service"
spec:
ingressClassName: nginx
rules:
- host: example
http:
paths:
- path: /ws/
pathType: Prefix
backend:
service:
name: server-service
port:
number: 5005
server-service.yaml
# Service exposing pod internally to other pods
apiVersion: v1
kind: Service
metadata:
name: server-service
spec:
# type: NodePort
type: ClusterIP
selector:
nodejs-server: server
ports:
- protocol: TCP
port: 5005
targetPort: 5005
# nodePort: 30005
Terminal to check default hosts file content
# Kubernetes-managed hosts file.
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
fe00::0 ip6-mcastprefix
fe00::1 ip6-allnodes
fe00::2 ip6-allrouters
10.42.0.178 server-deployment-8b9cf4977-mc779
What's the problem here?
Share asked Mar 7 at 10:50 kannickannic 156 bronze badges 2- Please provide details of the problem. – Thomas Commented Mar 7 at 12:22
- @Thomas sorted now. thanks. problem was with the ingress controller in the end. doesn't help that i'm using rancher desktop as context and not minikube. – kannic Commented Mar 7 at 14:46
1 Answer
Reset to default 0Problem relied in not properly installed and configured nginx
ingress controller. By installing it through Helm and deleting all references to traefik
to avoid LoadBalancer
collision and setting nginx./websocket-services: server-service
and/or nginx.ingress.kubernetes.io/websocket-services: server-service
, we successfully established 101 Switching Protocols with the client.
As the ingress did not have an address, therefore it was never being routed.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744935329a4601986.html
评论列表(0条)