Kubernetes ingress rule

822 Views Asked by At

I have a k8s 1.9.0 cluster and following is my ingress rule.

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
 name: my-ingress
 labels:
  app: report
annotations:
  ingress.kubernetes.io/rewrite-target: /
spec:
 rules:
  - host: "gayan.test.com"
    http:
     paths:
      - path: /report
        backend:
         serviceName: qc-report-svc
         servicePort: 80
     - path: /report/*
        backend:
         serviceName: qc-report-svc
         servicePort: 80

So I have two requests.

Request one - https://gayan.test.com/report/ping This request hit the pod and return the response. (GET /ping 200 302.079 ms - 63)

Request two - wss://gayan.test.com/report/socket.io/?EIO=3&transport=websocket. This request doesn't even hit the server. I think this is related to ingress rule.

My question is how can I send all the /report traffic to qc-report-svc service?

1

There are 1 best solutions below

2
On BEST ANSWER

Assuming you are using the Nginx Ingress Controller you need to add the nginx.org/websocket-services annotation to enable WebSocket support.

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
 name: my-ingress
 labels:
   app: report
annotations:
  ingress.kubernetes.io/rewrite-target: /
  nginx.org/websocket-services: "qc-report-svc"
spec:
 rules:
  - host: "gayan.test.com"
    http:
     paths:
      - path: /report
        backend:
         serviceName: qc-report-svc
         servicePort: 80