网关:
- 集中式
- 分布式
subnet GatewayType 指的是公网网关类型: 内网网关都是(ovn 原生)分布式的。
vpc:
- 默认 vpc
- 自定义 vpc
结论:自定义 VPC 下的 subnet 不会自动设置 gatewayType 默认值,只有默认 VPC(ovn-cluster)下的非 join subnet 会被自动设为 distributed。如果自定义 VPC 的 subnet 创建时没有显式指定该字段,它就是空的,kubectl get 的 GATEWAYTYPE 列就为空。
自定义 VPC 的 subnet 根本不走 GatewayType 相关的网关逻辑,
GatewayType 对自定义 VPC 没有任何意义。
核心调用链分岔点
在 subnet.go 中,路由 reconcile 对默认 VPC 和自定义 VPC 走的是完全不同的分支:
if subnet.Spec.Vpc == c.config.ClusterRouter {
// 默认 VPC → 根据 GatewayType 决定 distributed / centralized 策略路由
c.reconcileOvnDefaultVpcRoute(subnet)
} else {
// 自定义 VPC → 完全不看 GatewayType
c.reconcileCustomVpcStaticRoute(subnet)
}
自定义 VPC 的路由方式
reconcileCustomVpcStaticRoute() 的注释也明确说明了这一点(subnet.go):
// in custom vpc, subnet gw type is unmeaning
// 1. vpc out to public network through vpc nat gw pod
// 2. vpc out to public network through ovn nat lrp (with bfd ecmp)
// 3. vpc out to public network through ovn nat lrp (without bfd ecmp)
自定义 VPC 使用的是 OVN 逻辑路由器的静态路由(static route),出公网依赖 VPC 级别的配置(NAT 网关 Pod 或 OVN LRP NAT),而不是通过 policy route + port group 实现的分布式/集中式网关。
三种模式对比
| 维度 | 默认 VPC distributed | 默认 VPC centralized | 自定义 VPC(GatewayType 空) |
|---|---|---|---|
| 路由类型 | OVN policy route(per-node) | OVN policy route(per-subnet CIDR) | OVN static route |
| port group | 每 (subnet, node) 一个 | 无 | 无 |
| 网关节点 | 每个 node 做自己的网关 | 指定 GatewayNode | 不适用 |
| 出公网方式 | node 本地 SNAT | 经 GatewayNode SNAT | VPC NAT GW Pod / OVN LRP NAT |
| GatewayType 字段 | 必须 distributed | 必须 centralized | 无意义,被忽略 |
自定义 VPC 内部 subnet 间互通
同一自定义 VPC 下的多个 subnet(如你环境中 vpc-69aa4fbc 下的 192.168.0.0/24 和 192.168.1.0/24)之间的互通,是通过 OVN 逻辑路由器直连路由(connected route)实现的——每个 subnet 作为 logical switch 连接到 VPC 对应的 logical router 上,路由器自动有直连路由条目,不需要 distributed/centralized 机制。
结论:自定义 VPC 的 GatewayType 为空是正常的设计行为,它不影响任何功能。自定义 VPC 不使用 distributed/centralized 网关模型,而是使用 VPC 级别的静态路由 + NAT 配置。