Kubernetes Gateway API

    1. Install the Gateway API CRDs:

    2. Install Istio, or reconfigure an existing installation to enable the Gateway API controller:

    Configuring a Gateway

    See the documentation for information about the APIs.

    1. Deploy a test application:

    2. Deploy the Gateway API configuration:

      1. $ kubectl apply -f - <<EOF
      2. apiVersion: networking.x-k8s.io/v1alpha1
      3. kind: GatewayClass
      4. metadata:
      5. name: istio
      6. spec:
      7. controller: istio.io/gateway-controller
      8. ---
      9. apiVersion: networking.x-k8s.io/v1alpha1
      10. kind: Gateway
      11. metadata:
      12. name: gateway
      13. namespace: istio-system
      14. gatewayClassName: istio
      15. listeners:
      16. - hostname: "*"
      17. port: 80
      18. routes:
      19. namespaces:
      20. from: All
      21. selector:
      22. matchLabels:
      23. selected: "yes"
      24. kind: HTTPRoute
      25. ---
      26. apiVersion: networking.x-k8s.io/v1alpha1
      27. kind: HTTPRoute
      28. metadata:
      29. name: http
      30. namespace: default
      31. labels:
      32. selected: "yes"
      33. spec:
      34. allow: All
      35. rules:
      36. - matches:
      37. - path:
      38. type: Prefix
      39. value: /get
      40. filters:
      41. - type: RequestHeaderModifier
      42. requestHeaderModifier:
      43. add:
      44. my-added-header: added-value
      45. forwardTo:
      46. - serviceName: httpbin
      47. port: 8000
      48. EOF
    3. Access the httpbin service using curl:

    4. Access any other URL that has not been explicitly exposed. You should see an HTTP 404 error:

      1. $ curl -s -I -HHost:httpbin.example.com "http://$INGRESS_HOST:$INGRESS_PORT/headers"
      2. HTTP/1.1 404 Not Found