0

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?

Gayan
  • 1,425
  • 4
  • 21
  • 41

1 Answers1

1

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
Sebastian
  • 16,813
  • 4
  • 49
  • 56
  • Hi @Sebastian. Thanks for the answer. Yes. Im using Nginx ingress controller (gcr.io/google_containers/nginx-ingress-controller:0.9.0-beta.15) . But I don't think all the `/report` traffic route to `/report` path. Because I'm still seeing `400 error` on ingress controller. – Gayan Jan 08 '18 at 18:51
  • The google variant uses different annotations and might not support your use case. In general I would advise to switch to the official Kubernetes Nginx ingress controller. – Sebastian Jan 08 '18 at 19:18