Expose Kube-OVN Overlay Pod IP Outside Cluster
In a Kube-OVN cluster, Pods in Overlay network mode cannot be directly accessed from external networks. However, it is possible to achieve direct access to the Pod IP by adjusting the routing configuration of the external network.
Prerequisites
-
The nodes in the cluster need to have a VIP (Virtual IP) and ensure that the VIP can be used properly.
-
Turn off the outbound traffic NAT switch for the Overlay subnet. After turning it off, Pods within the subnet will not be able to use the host IP as the access address when accessing the external network, and the Pods IP within the subnet will be directly exposed to the external network.
Procedure of operation
Traditional Physical Network
For traditional physical networks, static routes need to be added on external core switches or routers. The destination address should be the address range of the Overlay cluster subnet, and the next hop should be the cluster VIP address.
H3C Switch Configuration Example:
ip route-static 10.3.0.0 16 192.168.66.15 description examplePublic Cloud Network
For public cloud networks, it is necessary to add routing entries to the subnet’s route table associated with the cluster nodes. The destination address should be the address range of the Overlay cluster subnet, and the next hop should point to the cluster VIP address.
Validation of results
Taking traditional physical networks as an example, when deploying an application in a cluster, it can be accessed normally from outside the cluster by using curl to access the address and port of the 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>