calico cilium kubeovn 这些容器网络都提供了默认的 nat out going 方案:
- 但是这种需要走 node 默认路由,然后 snat 为 node 默认路由对应的 ip, 然后出公网
- 如果存在租户的概念,这个流量就伪装起来了。
- 伪装后的流量不易于审计
- 所以业务流量和管理流量还是要分两个出口便于审计租户面的网络流量等内容
所以 cilium 为业务 pod 的出口提出了一种 Egress Gateway 的方案 该方案本质上是一种 k8s 感知的 SNAT 方案:
Egress Gateway is essentially Kubernetes-Aware Source-NAT: for example, for pods in a particular namespace, we can force the traffic to exit via a certain interface and to be NATed with a specific IP, enabling the firewall to apply a rule accordingly.
比如,某个 ns 内的 pod ,可以强制所有 pod 的流量都走到该 Egress Gateway 再出去。并且应用防火墙策略。
cilium egress gw 策略
当 ns:default 下的 pod 配置了 label: org: empire 。 这些 pod 最终会通过 label 选择到一个 node 上的 gw pod 出去。所有包会被源地址为 10. 168. 60. 100。
值得注意的是: 10. 168. 60. 100 这个 ip 文档说是在 node 上,而不是像 kube-ovn 的 vpc-nat-gw pod 那样在 pod 里面。
开源方案会存在单点故障,但是企业版是高可用设计的。
cilium 和 hubble 都有开源和企业版本,并且已经毕业了。建议高级功能还是自己维护。