Istio-learning-note-About-Gateway API(一)

Polished Notes on New Kubernetes Gateway API

I. Understanding Gateway API in Istio

  1. Gateway Class: This resource defines the provider of the Gateway control plane pod.

    • Think of it as a template specifying which implementation (e.g., Istio, Nginx) will handle gateway functionality.
  2. Gateway: This resource configures network traffic listener aspects.

    • It defines which port and protocol (e.g., port 80, protocol HTTP) the gateway should listen on.
  3. HTTPRoute: This resource associates with a specific Gateway and defines routing rules for incoming HTTP traffic.

    • It specifies how to route requests based on paths (e.g., /productpage) to backend services.

II. FAQ

A. Difference between Ingress Controller and Gateway API/Istio Ingress Gateway

  • Ingress Controller: Manages ingress for the entire Kubernetes cluster. It's often used with a single host network for multiple services.
  • Gateway API/Istio Ingress Gateway: Provides fine-grained control for individual applications and microservices. Each application can have its own Gateway and each microservice can have its own HTTPRoute for routing. They offer more separation of concerns.

B. Work and Contact Surface

  • Ingress Controller:

    • Infrastructure engineers typically manage the ingress controller itself (e.g., Nginx).
    • Application developers configure ingress resources to define how to expose services externally.
  • Gateway API:

    • Infrastructure engineers create GatewayClass resources specifying gateway implementations.
    • Cluster managers configure Gateway resources with details like domain, port, and allowed namespaces.
    • Application developers define HTTPRoute resources to specify routing rules for their microservices.

Example: Bookinfo Gateway Configuration

Gateway (bookinfo-gateway.yaml):

YAML

复制代码
apiVersion: v1
items:
- apiVersion: gateway.networking.k8s.io/v1
  kind: Gateway
  name: bookinfo-gateway
  namespace: bookinfo
  spec:
    gatewayClassName: istio  # Uses the "istio" GatewayClass
    listeners:
    - allowedRoutes:
        namespaces:
          from: All  # Allows traffic from any namespace
      name: http
      port: 80
      protocol: HTTP

HTTPRoute (bookinfo.yaml):

YAML

复制代码
apiVersion: v1
items:
- apiVersion: gateway.networking.k8s.io/v1
  kind: HTTPRoute
  name: bookinfo
  namespace: bookinfo
  spec:
    parentRefs:
    - group: gateway.networking.k8s.io
      kind: Gateway
      name: bookinfo-gateway  # Attaches to the bookinfo-gateway
    rules:
    - backendRefs:
        - group: ""  # Refers to a Service resource
          kind: Service
          name: productpage
          port: 9080
          weight: 1  # Weight for load balancing
      matches:
      - path:
          type: Exact
          value: /productpage  # Route for /productpage path
        - path:
          type: PathPrefix
          value: /static  # Route for paths starting with /static
        - path:  # Additional route examples
          type: Exact
          value: /login
        - path:
          type: Exact
          value: /logout
        - path:
          type: PathPrefix
          value: /api/v1/products

Key Points:

  • Gateway API offers more granular control over traffic management compared to a single ingress controller.
  • HTTPRoutes enable flexible routing based on path prefixes or exact paths.
  • You can configure weights for backend services in HTTPRoutes for load balancing.
相关推荐
wan5555cn3 小时前
多张图片生成视频模型技术深度解析
人工智能·笔记·深度学习·算法·音视频
Broken Arrows4 小时前
Linux学习——管理网络安全(二十一)
linux·学习·web安全
今天也要学习吖5 小时前
谷歌nano banana官方Prompt模板发布,解锁六大图像生成风格
人工智能·学习·ai·prompt·nano banana·谷歌ai
雁于飞5 小时前
vscode中使用git、githup的基操
笔记·git·vscode·学习·elasticsearch·gitee·github
rannn_1115 小时前
【Javaweb学习|实训总结|Week1】html基础,CSS(选择器、常用样式、盒子模型、弹性盒布局、CSS定位、动画),js(基本类型、运算符典例)
css·笔记·学习·html
Ro Jace5 小时前
心灵笔记:第一性原理学习与实践
笔记
aramae7 小时前
C++ -- 模板
开发语言·c++·笔记·其他
wanzhong23337 小时前
ArcGIS学习-20 实战-地形研究
学习
wanzhong23337 小时前
ArcGIS学习-20 实战-县域水文分析
学习·arcgis