Custom gateway detects wrong port for the service


#1

I have a weird issue where istio detects wrong port for one of the services. routes from envoy:

[
    {
        "cluster":  "outbound|443||A.dev.svc.cluster.local", <<<< should be 8088 as well
        "timeout":  "0.000s",
        "maxGrpcTimeout":  "0.000s"
    },
    {
        "cluster":  "outbound|8088||B.dev.svc.cluster.local",
        "timeout":  "0.000s",
        "maxGrpcTimeout":  "0.000s"
    }
]

virtual services:

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: a
  namespace: istio-system
spec:
  gateways:
  - custom-gateway.istio-system.svc.cluster.local
  hosts:
  - istio.xxx.com
  http:
  - match:
    - uri:
        prefix: /path_a
    route:
    - destination:
        host: a.dev.svc.cluster.local
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: b
  namespace: istio-system
spec:
  gateways:
  - custom-gateway.istio-system.svc.cluster.local
  hosts:
  - istio.xxx.com
  http:
  - match:
    - uri:
        prefix: /path_b
    route:
    - destination:
        host: b.dev.svc.cluster.local

services:

apiVersion: v1
kind: Service
metadata:
  name: a
  namespace: dev
spec:
  clusterIP: 10.64.3.112
  ports:
  - name: http
    port: 8088
    protocol: TCP
    targetPort: http
  - name: metrics
    port: 8090
    protocol: TCP
    targetPort: metrics
  selector:
    app.kubernetes.io/instance: a
    app.kubernetes.io/name: a
  sessionAffinity: None
  type: ClusterIP
apiVersion: v1
kind: Service
metadata:
  name: b
  namespace: dev
spec:
  clusterIP: 10.64.10.252
  ports:
  - name: http
    port: 8088
    protocol: TCP
    targetPort: http
  selector:
    app.kubernetes.io/instance: b
    app.kubernetes.io/name: b
  sessionAffinity: None
  type: ClusterIP

I dont really understand why its doing that, and\or how to fix it. more info: https://github.com/istio/istio/issues/11785


#2

folks, any ideas? this is extremely annoying and looks like a bug.