如何添加 IP 路由以便 Kubernetes 集群地址通过适当的适配器

How to add IP route(s) So Kubernetes cluster addresses go via through appropriate adapter

我已按照以下 link 说明分别在 CentOS-8 OS 独立服务器上安装了 Kubernetes cluster(one Master and one Worker- Node)。

https://www.tecmint.com/install-a-kubernetes-cluster-on-centos-8/

Weave-Net - CNI plugin installed 同上link。现在我可以在我们的 K8s Master & Worker-Node 服务器中看到下面的新网络适配器。

weave: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1376
inet 10.32.0.1 netmask 255.240.0.0 broadcast 10.47.255.255
inet6 fe80::a07d:21ff:fef1:4656 prefixlen 64 scopeid 0x20<link>
ether a2:7d:21:f1:46:56 txqueuelen 1000 (Ethernet)
RX packets 141 bytes 13322 (13.0 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 48 bytes 4896 (4.7 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

但问题是主机服务器无法 ping (Or) access any of our remote site/location IPs(下面给出的 ping 响应)。而 Local IPs are pinging & accessible.

ping -c 4 120.121.5.48
PING 120.121.5.48 (120.121.5.48) 56(84) bytes of data.
From 10.32.0.1 icmp_seq=1 Destination Host Unreachable
From 10.32.0.1 icmp_seq=2 Destination Host Unreachable
From 10.32.0.1 icmp_seq=3 Destination Host Unreachable
From 10.32.0.1 icmp_seq=4 Destination Host Unreachable

--- 120.121.5.48 ping statistics ---
4 packets transmitted, 0 received, +4 errors, 100% packet loss, time 2999ms
pipe 4 

也从主机服务器尝试连接我们的远程LDAP server through telnet它显示下面的错误消息。

# telnet 120.121.5.48 389
Trying 120.121.5.48...
telnet: connect to address 120.121.5.48: No route to host

在我们的K8s Master & Worker-Node server 中有23 network adapters, Statically network IP 已经配置,那么是否需要额外配置K8s CNI 在默认路由中可达?

ip route show&route -n输出如下

# ip route show
default via 45.46.47.1 dev ens1f0 proto static metric 100
10.32.0.0/12 dev weave proto kernel scope link src 10.32.0.1
45.46.47.0/24 dev ens1f0 proto kernel scope link src 45.46.47.48 metric 100
172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1
192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1 linkdown

# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         45.46.47.1      0.0.0.0         UG    100    0        0 ens1f0
10.32.0.0       0.0.0.0         255.255.255.0   U     10     0        0 ens1f0
10.32.0.0       0.0.0.0         255.240.0.0     U     0      0        0 weave
45.46.47.0      0.0.0.0         255.255.255.0   U     100    0        0 ens1f0
172.17.0.0      0.0.0.0         255.255.0.0     U     0      0        0 docker0
192.168.122.0   0.0.0.0         255.255.255.0   U     0      0        0 virbr0

尝试使用以下命令将编织路线更改为默认路线。执行成功了,还是一样的问题

ip route add 10.32.0.0/24 via 45.46.47.1 dev ens1f0 metric 100

假设我 运行 ifconfig weave down 一切正常。但是要使用 Kubernetes 集群,我需要 Weave-net network adapter。所以请帮我添加 IP 路由,以便我的 Kubernetes 集群地址通过适当的适配器,这样我就可以访问我们的本地和远程位置服务器。

我已将 CNI-Weave-Net 插件更改为 Flannel,现在它正常工作了。