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.
相关推荐
小徐不会敲代码~7 小时前
Vue3 学习2
前端·javascript·学习
我命由我123457 小时前
Python Flask 开发 - Flask 快速上手(Flask 最简单的案例、Flask 处理跨域、Flask 基础接口)
服务器·开发语言·后端·python·学习·flask·学习方法
深蓝海拓7 小时前
PySide6从0开始学习的笔记(二) 控件(Widget)之容器类控件
笔记·qt·学习·pyqt
_李小白7 小时前
【Android GLSurfaceView源码学习】第二天:GLSurfaceView深度分析
android·学习
摇滚侠7 小时前
Redis 零基础到进阶,Spring Boot 整合 Redis,笔记93-99
spring boot·redis·笔记
秋深枫叶红7 小时前
嵌入式第三十七篇——linux系统编程——线程控制
linux·学习·线程·系统编程
猫天意7 小时前
【即插即用模块】AAAI2025 | 高频 + 空间感知!新 HS-FPN 让“极小目标”不再消失!SCI保二区争一区!彻底疯狂!!!
网络·人工智能·深度学习·学习·音视频
Voyager_47 小时前
算法学习记录17——力扣“股票系列题型”
学习·算法·leetcode
XFF不秃头7 小时前
【力扣刷题笔记-在排序数组中查找元素的第一个和最后一个位置】
c++·笔记·算法·leetcode
正经教主7 小时前
【Trae+AI】和Trae学习搭建App_2.1:第3章·手搓后端基础框架Express
人工智能·后端·学习·express