–
下面为通过openvswitch来打通网络供pod通信,不使用flanae来通信 三台机器 10.216.4.21 10.216.4.22 10.216.4.23 pod段规则 10.216.4.21 pod段 192.168.21.x 10.216.4.22 pod段 192.168.22.x 10.216.4.23 pod段 192.168.23.x 下面在 10.216.4.21 上面操作 yum -y install openvswitch openvswitch-devel openvswitch-test bridge-utils systemctl enable openvswitch systemctl start openvswitch ovs-vsctl show systemctl stop docker ip link set dev docker0 down brctl delbr docker0 brctl addbr docker0 # ifconfig docker0 mtu 1450 up 默认是1450,一般来说docker根据 DOCKER_NETWORK_OPTIONS=" --bip=172.18.14.1/24 --ip-masq=true --mtu=1450 " 来配置mtu,不一样的话,应该是网络通信的时候会自动改为1450,不用人为改 ip addr add 192.168.1.1/24 dev docker0 ovs-vsctl add-br br0 ovs-vsctl add-port br0 vxlan2 -- set interface vxlan2 type=vxlan option:remote_ip=10.216.4.22 (对端ip,要互相添加) ovs-vsctl add-port br0 vxlan3 -- set interface vxlan3 type=vxlan option:remote_ip=10.216.4.23 (对端ip,要互相添加) #ovs-vsctl del-port br0 vxlan1 ovs-vsctl show systemctl start docker ip link set dev br0 up ip link set dev docker0 up ip route add 192.168.0.0/16 dev docker0 brctl addif docker0 br0 查看生成树 ovs-vsctl set bridge br0 stp_enable=true ovs-vsctl get bridge br0 stp_enable ip route add 172.18.0.0/16 dev docker0 下面在 10.216.4.22 上面操作 yum -y install openvswitch openvswitch-devel openvswitch-test bridge-utils systemctl enable openvswitch systemctl start openvswitch ovs-vsctl show systemctl stop docker ip link set dev docker0 down brctl delbr docker0 brctl addbr docker0 ip addr add 192.168.2.1/24 dev docker0 ovs-vsctl add-br br0 ovs-vsctl add-port br0 vxlan2 -- set interface vxlan2 type=vxlan option:remote_ip=10.216.4.21 (对端ip,要互相添加) #ovs-vsctl del-port br0 vxlan2 ovs-vsctl show ip link set dev br0 up ip link set dev docker0 up ip route add 192.168.0.0/16 dev docker0 brctl addif docker0 br0 查看生成树 ovs-vsctl set bridge br0 stp_enable=true ovs-vsctl get bridge br0 stp_enable 下面在 10.216.4.23 上面操作 yum -y install openvswitch openvswitch-devel openvswitch-test bridge-utils systemctl enable openvswitch systemctl start openvswitch ovs-vsctl show systemctl stop docker ip link set dev docker0 down brctl delbr docker0 brctl addbr docker0 ip addr add 192.168.3.1/24 dev docker0 ovs-vsctl add-br br0 ovs-vsctl add-port br0 vxlan3 -- set interface vxlan3 type=vxlan option:remote_ip=10.216.4.21 (对端ip,要互相添加) #ovs-vsctl del-port br0 vxlan3 ovs-vsctl show ip link set dev br0 up ip link set dev docker0 up ip route add 192.168.0.0/16 dev docker0 brctl addif docker0 br0 查看生成树 ovs-vsctl set bridge br0 stp_enable=true ovs-vsctl get bridge br0 stp_enable docker服务文件修改 EnvironmentFile=-/etc/kubernetes/ovs-network.conf cat /etc/kubernetes/ovs-network.conf DOCKER_NETWORK_OPTIONS=" --bip=192.168.1.1/24 --ip-masq=true --mtu=1450 " 这里要注意mtu值,一般要小于等于1450,不然mtu超过后,大文件传输会有问题。重启物理机生效,还没找到更好的方法 mtu要等有实际通信的时候才会在网卡上面看到更改后的值
–
–
–
评论前必须登录!
注册