# istio_reference-policy-service.yaml
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
  name: gateway
  namespace: istio-system
spec:
  addresses:
  - value: istio-ingressgateway
    type: Hostname
  gatewayClassName: istio
  listeners:
  - name: simple
    hostname: "*.domain.example"
    port: 80
    protocol: HTTP
    allowedRoutes:
      namespaces:
        from: All
---
apiVersion: gateway.networking.k8s.io/v1beta1
kind: ReferenceGrant
metadata:
  name: allow-service
  namespace: service
spec:
  from:
  - group: gateway.networking.k8s.io
    kind: HTTPRoute
    namespace: istio-system
  to:
  - group: ""
    kind: Service
    name: my-svc
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: http
  namespace: istio-system
spec:
  parentRefs:
  - name: gateway
    namespace: istio-system
  hostnames: ["simple.domain.example"]
  rules:
  - backendRefs:
    - name: my-svc
      namespace: service
      port: 80
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: backend-not-allowed
  namespace: istio-system
spec:
  parentRefs:
  - name: gateway
    namespace: istio-system
  hostnames: ["simple2.domain.example"]
  rules:
  - backendRefs:
    - name: my-svc
      namespace: service
      port: 80
      weight: 1
    - name: httpbin
      namespace: default
      port: 80
      weight: 1