# istio_serviceentry.yaml
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
  name: gateway
  namespace: istio-system
spec:
  gatewayClassName: istio
  listeners:
  - name: default
    port: 80
    protocol: HTTP
    allowedRoutes:
      namespaces:
        from: All
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: http
  namespace: default
spec:
  parentRefs:
  - name: gateway
    namespace: istio-system
  rules:
  - backendRefs:
    - kind: Hostname
      group: networking.istio.io
      name: google.com
      port: 80
---
apiVersion: networking.istio.io/v1
kind: ServiceEntry
metadata:
  name: egress
  namespace: default
spec:
  hosts:
  - "google.com"
  - "*.egress.com"
  ports:
  - number: 80
    name: http
    protocol: HTTP
  - number: 443
    name: tls
    protocol: TLS
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: egress
  namespace: default
spec:
  parentRefs:
  - kind: ServiceEntry
    group: networking.istio.io
    name: egress
  hostnames:
  - "google.com"
  rules:
  - backendRefs:
    - kind: Hostname
      group: networking.istio.io
      name: google.com
      port: 80
---
apiVersion: gateway.networking.k8s.io/v1
kind: TLSRoute
metadata:
  name: egress
  namespace: default
spec:
  parentRefs:
  - kind: ServiceEntry
    group: networking.istio.io
    name: egress
  hostnames:
  - "google.com"
  rules:
  - backendRefs:
    - kind: Hostname
      group: networking.istio.io
      name: google.com
      port: 443
---
apiVersion: gateway.networking.k8s.io/v1alpha2
kind: TCPRoute
metadata:
  name: egress
  namespace: default
spec:
  parentRefs:
  - kind: ServiceEntry
    group: networking.istio.io
    name: egress
  rules:
  - backendRefs:
    - kind: Hostname
      group: networking.istio.io
      name: google.com
      port: 443
---