Skip to Content
Kubernetes 认证管理员 (CKA) 学习指南 (Chinese Edition), 2nd Edition
book

Kubernetes 认证管理员 (CKA) 学习指南 (Chinese Edition), 2nd Edition

by Benjamin Muschko
January 2026
Intermediate to advanced
392 pages
4h 44m
Chinese
O'Reilly Media, Inc.
Content preview from Kubernetes 认证管理员 (CKA) 学习指南 (Chinese Edition), 2nd Edition

第19章. 网关API

本作品已使用人工智能进行翻译。欢迎您提供反馈和意见:translation-feedback@oreilly.com

网关 API( )的推出旨在标准化并继承 Ingress 及服务网格框架(如 Istio、Contour 和 Linkerd)的经验教训( )。这些框架已证明需要超越 Ingress 能力范围的更复杂流量管理功能。作为传统 Ingress 资源的更具表达力和可扩展性的替代方案,网关 API 提供基于角色的设计、支持 HTTP/HTTPS 之外的多协议,并增强了流量路由功能。

网关 API 是 Ingress 基础架构的继任者,随着企业采用这种现代化的外部流量管理方法,其重要性日益凸显。

作为考试候选人,您需要掌握如何部署网关 API 并实例化相关对象,以在集群中建立 Ingress 访问通道。

为何Ingress原语不够完善?

Ingress API( )是 Kubernetes 为服务配置外部 HTTP/HTTPS 负载均衡的标准方式,但存在局限性。虽然 Ingress 支持 TLS 终止和基于内容的简单 HTTP 请求路由,但实际应用场景需要更高级的功能。由于多种原因,扩展现有 Ingress API 模型无法轻松实现这些功能:

Ingress控制器特有的可扩展性

流量拆分、速率限制及请求/响应操作等高级功能由特定Ingress实现的非移植性注解提供 Ingress API不适用于需要强权限xml-ph-0000@deepl.internal模型的多租户环境

权限模型不足

Ingress API 不适用于需要强权限 模型的多租户环境。

本章不会详述网关 API 的所有配置选项和功能,这已超出考试所需范围。但我将说明如何参照第 18 章所学内容对 HTTP 流量进行网关建模。其他用例的实现方式请参阅网关 API 文档

使用网关API

网关 API 是 Ingress 原语的官方继任者,不仅涵盖 Ingress 的全部功能,更支持更高级的应用场景。

可将网关 API 视为统一标准化的流量管理 API,用于管控进出 Kubernetes 集群的流量,从而免去选择特定 Ingress 实现方案的困扰。配置路由选项时不再需要产品专属注解,网关 API 提供了灵活整合类似功能的途径。本质上,网关 API 是由多种实现方案共同支持的通用规范。

与 Ingress 处理单一基础组件不同,网关 API 将职责拆分为多个基础组件,具体说明详见下文。

网关API资源

网关 API 通过四种主要资源类型引入分层流量管理方法,共同处理入站流量:

网关

定义流量处理基础设施 的实例,例如Cloud负载均衡器。 每个网关 都关联一个GatewayClass,该类描述将处理网关流量的实际网关控制器类型

网关类

每个网关 都关联一个GatewayClass,该类描述实际处理网关流量的控制器类型。

HTTPRoute/GRPCRoute

定义将网关监听器( )的流量映射至后端网络端点表示形式的HTTP或GRPC特定规则。这些端点通常以服务形式呈现。

参考授权

可用于在网关 API 内启用跨命名空间引用,例如路由可将流量转发至其他命名空间的后端。

如图19-1所示,不同角色分别负责管理这些网关API资源:

图 19-1. 由角色管理的网关 API 资源

GatewayClass由平台提供商(如Cloud服务商)提供。Gateway和ReferenceGrant由Kubernetes集群管理员部署。而HTTPRoute与GRPCRoute则由应用开发者创建。 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Kubernetes 上的生成式人工智能 (Chinese Edition)

Kubernetes 上的生成式人工智能 (Chinese Edition)

Roland Huß, Daniele Zonca
游戏化头脑风暴

游戏化头脑风暴

Dave Gray, Sunni Brown, James Macanufo

Publisher Resources

ISBN: 0642572314712