Kubernetes Gateway API 完全指南:替代 Ingress 的新标准
Complete Guide to Kubernetes Gateway API: The New Standard Replacing Ingress
| Zhang Hao | 2026-08-12T11:00:00
深入解读 Kubernetes Gateway API 的设计理念、核心资源和迁移策略,帮助团队从 Ingress 平滑过渡。
In-depth look at Kubernetes Gateway API design philosophy, core resources, and migration strategies to help teams smoothly transition from Ingress.
为什么需要 Gateway APIKubernetes Ingress 资源存在诸多限制:功能有限需要大量 annotation、不同控制器行为不一致、缺乏对 TCP/UDP 的支持。Gateway API 作为官方推出的下一代标准,解决了这些痛点。核心资源GatewayClass:定义网关实现(类似 StorageClass)Gateway:声明网关实例和监听器HTTPRoute:HTTP 路由规则(替代 Ingress)TCPRoute / GRPCRoute:支持更多协议apiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute metadata: name: app-route spec: parentRefs: - name: main-gateway hostnames: - "api.example.com" rules: - matches: - path: type: PathPrefix value: /v2 backendRefs: - name: app-v2 port: 8080 weight: 90 - name: app-v3 port: 8080 weight: 10迁移策略评估现有 Ingress 使用的 annotation,映射到 Gateway API 特性选择支持 Gateway API 的控制器(Envoy Gateway、Istio、Cilium)并行运行两套配置,逐步切流验证完成后下线旧 Ingress 资源
Why Gateway APIKubernetes Ingress resources have numerous limitations: limited functionality requiring extensive annotations, inconsistent behavior across controllers, and lack of TCP/UDP support. Gateway API, as the official next-generation standard, addresses these pain points.Core ResourcesGatewayClass: Defines gateway implementation (similar to StorageClass)Gateway: Declares gateway instances and listenersHTTPRoute: HTTP routing rules (replaces Ingress)TCPRoute / GRPCRoute: Support for more protocolsapiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute metadata: name: app-route spec: parentRefs: - name: main-gateway hostnames: - "api.example.com" rules: - matches: - path: type: PathPrefix value: /v2 backendRefs: - name: app-v2 port: 8080 weight: 90 - name: app-v3 port: 8080 weight: 10Migration StrategyAssess existing Ingress annotation usage and map to Gateway API featuresChoose a controller supporting Gateway API (Envoy Gateway, Istio, Cilium)Run both configurations in parallel, gradually shifting trafficDecommission old Ingress resources after validation