---
# ServiceEntry: registers httpbin.org as an external service in the mesh
# Applied in the sample namespace where the product workload runs.
apiVersion: networking.istio.io/v1beta1
kind: ServiceEntry
metadata:
  name: httpbin-external
  namespace: sample
spec:
  hosts:
    - httpbin.org
  ports:
    - number: 80
      name: http
      protocol: HTTP
  resolution: DNS
  location: MESH_EXTERNAL
---
# VirtualService: routes mesh sidecar traffic for httpbin.org through the
# egress gateway, then from the egress gateway to the external host.
# Both "mesh" and the egress gateway must be listed in gateways.
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
  name: httpbin-via-egress
  namespace: sample
spec:
  hosts:
    - httpbin.org
  gateways:
    - istio-system/egressgateway
    - mesh
  http:
    - match:
        - gateways:
            - mesh
          port: 80
      route:
        - destination:
            host: istio-egressgateway.istio-system.svc.cluster.local
          weight: 100
    - match:
        - gateways:
            - istio-system/egressgateway
          port: 80
      route:
        - destination:
            host: httpbin.org
            port:
              number: 80
          weight: 100
