# Gateway API (gateway.networking.k8s.io/v1): the successor to Ingress.
# Needs the Gateway API CRDs plus a controller that implements them.
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
  name: public
  namespace: demo
spec:
  gatewayClassName: example     # provided by your gateway controller
  listeners:
    - name: https
      protocol: HTTPS
      port: 443
      hostname: app.example.com
      tls:
        mode: Terminate
        certificateRefs:
          - name: web-tls
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: web
  namespace: demo
spec:
  parentRefs:
    - name: public
  hostnames: ["app.example.com"]
  rules:
    - matches:
        - path:
            type: PathPrefix
            value: /api
      backendRefs:
        - name: web
          port: 80
          weight: 90
        - name: web-canary      # 10% canary traffic
          port: 80
          weight: 10
    - backendRefs:
        - name: web
          port: 80
