Kubernetes Service APIs

    1. 调用 Service APIs 创建 CRDs:

    2. 安装 Istio 或重新配置 Istio,启动 Service APIs 控制器:

    配置网关

    参见 文档中的 APIs 信息.

    1. 部署一个测试应用:

    2. 部署 Service APIs 配置:

      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. 使用 curl 访问刚才部署的 httpbin 服务:

    4. 访问尚未显式公开的任何其他 URL,将会收到 HTTP 404 错误:

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