k8s v1.28.0安装哪个版本gateway-api
Gateway API v1.6.0 可以安装在 K8s v1.28.0 上运行,因为 Gateway API 是 CRD,不依赖 K8s 核心版本。但 v1.6.0 要求 K8s 最低 1.31,在 1.28 上会遇到兼容性问题。
Gateway API v1.6.0 要求
根据 Gateway API 官方发布说明:
| Gateway API 版本 | 最低 K8s 版本 | GA 资源 | Beta 资源 |
|---|---|---|---|
| v1.0.0 | 1.22 | HTTPRoute, GatewayClass, Gateway, ReferenceGrant | TCPRoute, UDPRoute |
| v1.2.0 | 1.22 | 同上 | GRPCRoute 升 Beta |
| v1.4.0 | 1.28 | 同上 | BackendTrafficPolicy GA |
| v1.6.0 | 1.31 | 同上 | 更多 Beta 资源 |
在 K8s 1.28 上安装 v1.6.0 会发生什么
尝试安装
1 | # 安装 Gateway API v1.6.0 CRD |
可能出现的问题
错误 1: API 版本不兼容
error: resource mapping not found for name: "...
unable to recognize "": no matches for kind "HTTPRoute" in version "gateway.networking.k8s.io/v1"
错误 2: CRD 的 served versions 不匹配
The CustomResourceDefinition "httproutes.gateway.networking.k8s.io" is invalid:
spec.versions[0].schema.openAPIV3Schema.properties.spec.properties.rules.properties.timeouts.properties.backendRequest:
Invalid value: "object": must be a primitive value or reference
错误 3: Controller 不兼容
nginx-ingress controller v1.6.0+ requires Gateway API v1.4.0+,
but your K8s 1.28 API server may not support newer CRD schemas
实际兼容性矩阵
| K8s 版本 | 推荐 Gateway API 版本 | v1.6.0 是否可用 |
|---|---|---|
| 1.22-1.25 | v0.8.0 | ❌ 不兼容 |
| 1.26-1.27 | v1.0.0-v1.1.0 | ❌ 不兼容 |
| 1.28 | v1.1.0-v1.2.0 | ❌ 不推荐 |
| 1.29-1.30 | v1.2.0-v1.3.0 | ⚠️ 可能部分兼容 |
| 1.31+ | v1.4.0-v1.6.0 | ✅ 完全兼容 |
K8s 1.28 的正确选择
1 | # K8s 1.28 推荐安装 Gateway API v1.1.0 或 v1.2.0 |
v1.2.0 在 K8s 1.28 上的支持情况:
| 资源 | 状态 |
|---|---|
| GatewayClass | ✅ GA |
| Gateway | ✅ GA |
| HTTPRoute | ✅ GA |
| ReferenceGrant | ✅ GA |
| TCPRoute | ✅ Beta |
| UDPRoute | ✅ Beta |
| GRPCRoute | ⚠️ Alpha |
总结
Gateway API v1.6.0 不能在 K8s 1.28 上正常使用。
- K8s 1.28 → 使用 Gateway API v1.1.0 或 v1.2.0
- K8s 1.31+ → 使用 Gateway API v1.4.0+ 或 v1.6.0
如果必须用 v1.6.0 的特性,建议升级 K8s 到 **1.31+**。
需要我帮你制定升级方案,或者在 K8s 1.28 上用 v1.2.0 搭建完整环境吗?