apiVersion: networking.istio.io/v1alpha3
kind: ServiceEntry
metadata:
  name: websocket-extsvc
  namespace: testns
spec:
   hosts:
   - websocket.test.istio.io
   ports:
   - number: 9002
     name: http
     protocol: HTTP
   resolution: STATIC
   endpoints:
    - address: 127.0.0.2
      ports:
        http: 7072
      labels:
        version: v1

---
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
  name: websocket
  namespace: testns
spec:
  host: websocket.test.istio.io
  subsets:
    - name: v1
      labels:
        version: v1


---

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: websocket-route
  namespace: testns
spec:
  hosts:
    - websocket.test.istio.io
  http:
    - match:
      - headers:
          testwebsocket:
            exact: enabled
      route:
      - destination:
          host: websocket.test.istio.io
          subset: v1
          port:
            number: 9002
      websocketUpgrade: true

---

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: websocket-route2
  namespace: testns
spec:
  hosts:
    - websocket2.extsvc.com
  http:
    - match:
      - headers:
          testwebsocket:
            exact: enabled
      route:
      - destination:
          host: websocket.test.istio.io
          subset: v1
          port:
            number: 9002
      websocketUpgrade: true
