Adding a domain in ingress gateway and map using hosts file in addition to a FQDN?

We have a requirement where our developers want to access the service from their workstation using the kubernetes service url.
For example, our service name is “core-service”, within the k8s cluster other services can communicate to this service by http://core-service/
The devs want to connect from outside k8s so they setup a record in the windows hosts file such as

172.20.20.20 core-service

We also have a FQDN that connects to this service via a Ingress Gateway. For example, “service.mydomain.com/core-service

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: private-gateway
  namespace: istio-system
spec:
  selector:
    istio: internal-ingressgateway
  servers:
    - port:
        number: 80
        name: http
        protocol: HTTP
      tls:
        httpsRedirect: true
      hosts:
        - "*"
    - port:
        number: 443
        name: https
        protocol: HTTPS
      tls:
        mode: SIMPLE
        credentialName: dc-ssl
      hosts:
        - "*"



apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: core-service
  namespace: core
spec:
  gateways:
    - private-gateway.istio-system.svc.cluster.local
  hosts:
    - service.mydomain.com
  http:
    - match:
        - uri:
            prefix: /core-service/
      rewrite:
        uri: /
      route:
        - destination:
            host: core-service
            port:
              number: 80
      timeout: 60s

Now, how can I add “core-service” as the domain so that both are routed to the pod correctly?

I tried to create a new VirtualService

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: core-config-developer
  namespace: dit
spec:
  gateways:
    - internal-gateway.istio-system.svc.cluster.local
  hosts:
    - core-service
  http:
    - match:
        - uri:
            prefix: /
      rewrite:
        uri: /
      route:
        - destination:
            host: core-service
            port:
              number: 80
      timeout: 60s

But this doesn’t work as we are getting 404

2020-12-11T14:50:50.084645237Z [2020-12-11T14:50:44.292Z] “GET /health/heartbeat HTTP/1.1” 404 NR “-” “-” 0 0 0 - “172.23.176.4” “Wget/1.19.4 (linux-gnu)” “09a41214-ad71-4909-95a7-63afc71a920a” “core-config” “-” - - 172.23.176.84:8080 172.23.176.4:11155 - -

i think you just have some configuration issues (based on your 404 error), you are trying to call http://core-service/core-service/health/heartbeat, but shouldnt you be calling http://core-service/health/heartbeat? also i dont think you need a rewrite in your second virtual service.

I was trying both, and I mistakenly copied the log from the other one. I corrected the post. Both returns 404.