首页 / 最佳实践 / 网络 / Kube-OVN Overlay Pod IP 集群外暴露

Kube-OVN Overlay Pod IP 集群外暴露

在 Kube-OVN 集群中,Overlay 网络模式的 Pod 无法被外部网络直接访问,可通过调整外部网络的路由配置,以实现对 Pod IP 的直接访问。

前提条件

操作步骤

传统物理网络

针对传统物理网络,需在外部核心交换机或路由器上增加静态路由,目的地址为 Overlay 集群子网的地址段,下一跳指向集群 VIP 地址。

H3C 交换机配置示例:

ip route-static 10.3.0.0 16 192.168.66.15 description example

公有云网络

针对公有云网络,需在集群节点关联子网的路由表中增加路由条目,目的地址为 Overlay 集群子网的地址段,下一跳指向集群 VIP 地址。

结果验证

以传统物理网络为例,在集群中部署一个应用,在集群外部通过 curl 访问 Pod 的地址和端口,可以正常访问。

~ curl 10.3.0.48:80
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
 
<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>
 
<p><em>Thank you for using nginx.</em></p>
</body>
</html>