其他分享
首页 > 其他分享> > 在容器环境中容器内部部署ovs

在容器环境中容器内部部署ovs

作者:互联网


宿主机ubuntu18.04,编译安装ovs2.11.1,
apt install python build-essiential
configure--with-linux=/lib/modules/(uname -r)/build
make
sudo make install
sudo make modules_install
sudo lsmod |grep openvswitch
export PATH=$PATH:/usr/local/share/openvswitch/scripts
sudo ovs-ctl start

docker pull ubuntu:18.04

sudo docker create -it -v/etc/apt/sources.list:/etc/apt/sources.list --name vswitch -h vswitch --cap-add NET_ADMIN --cap-add SYS_NICE ubuntu:18.04 /bin/bash
sudo docker start vswitch
sudo docker exec -it vswitch /bin/bash

进入容器-这里参考:https://aozsky.com/virtuallize/docker_openvswitch
apt install -y iproute2 net-tools iputils-ping
apt install -y build-essiential fakeroot
apt install -y debhelper autoconf automake automake1.10 libssl-dev graphviz python-all python-qt4 python-zopeinterface python-twisted-conch libtool

tar zxvf openvswitch-2.11.1.tar.gz

DEB_BUILD_OPTIONS='parallel=8 nocheck' fakeroot debian/rules binary

cd ../
dpkg -i ./libopenvswitch_2.11.1-1_amd64.deb
dpkg -i ./openvswitch-common_2.11.1-1_amd64.deb
dpkg -i ./openvswitch-switch_2.11.1-1_amd64.deb
dpkg -i ./python-openvswitch_2.11.1-1_all.deb
dpkg -i openvswitch-vtep_2.11.1-1_amd64.deb
出现如下错误:
invoke-rc.d: could not determine current runlevel
invoke-rc.d: policy-rc.d denied execution of start.

cd ./openvswitch-2.11.1/utilities
./ovs-ctl start

ovs-vsctl show

保存为镜像
sudo docker commit vswitch dablyo/ubuntu1804:ovs-2.11.1
sudo docker save -o ubuntu1804-ovs2.11.1.img dablyo/ubuntu1804:ovs-2.11.1


宿主机@ovs2.11.1
sudo docker create -it --privileged=true --name cpe1 --net=none dablyo/ubuntu1804:ovs-2.11.1 /bin/bash

sudo ovs-vsctl add-br br_inside
sudo ovs-vsctl add-br br_outside
sudo ovs-vsctl add-br br_wan1

~/openvswitch-2.11.1/utilities$ sudo ./ovs-docker add-port br_wan1 eth0 cpe1 --ipaddress=10.0.0.1/24
~/openvswitch-2.11.1/utilities$ sudo ./ovs-docker add-port br_outside eth1 cpe1 --ipaddress=172.1.0.2/24
~/openvswitch-2.11.1/utilities$ sudo ./ovs-docker add-port br_inside eth2 cpe1 --ipaddress=192.168.100.2/24


=================以上2.11.1版本失败===以下2.9.2版本可行====================
宿主机
sudo apt install -y openvswitch-common openvswitch-switch
sudo docker pull rastasheep/ubuntu-sshd:18.04
sudo docker create -it -v/etc/apt/sources.list:/etc/apt/sources.list -v/etc/docker/daemon.json:/etc/docker/daemon.json --name vswitch -h vswitch \
--cap-add NET_ADMIN --cap-add SYS_NICE rastasheep/ubuntu-sshd:18.04

容器内:
cd openvswitch-2.9.2
apt install -y iproute2 net-tools iputils-ping
apt install -y build-essential fakeroot
apt install -y debhelper autoconf automake automake1.10 libssl-dev graphviz python-all python-qt4 python-zopeinterface python-twisted-conch libtool
DEB_BUILD_OPTIONS='parallel=8 nocheck' fakeroot debian/rules binary
dpkg -i .deb
apt install -y uuid-runtime
uuidd start
cd openvswitch-2.9.2/utilities
./ovs-ctl start

sudo docker commit vswitch dablyo/ubuntu1804:ovs-2.11.1
sudo docker save -o ubuntu1804-ovs2.11.1.img dablyo/ubuntu1804:ovs-2.11.1


宿主机@ovs2.9.2
sudo docker create -it --privileged=true --name cpe1 -h cpe1 --net=none dablyo/ubuntu1804:ovs-2.9.2 /bin/bash

sudo ovs-vsctl add-br br_inside
sudo ovs-vsctl add-br br_outside
sudo ovs-vsctl add-br br_wan1

~/openvswitch-2.11.1/utilities$ sudo ./ovs-docker add-port br_wan1 eth0 cpe1
~/openvswitch-2.11.1/utilities$ sudo ./ovs-docker add-port br_outside eth1 cpe1
~/openvswitch-2.11.1/utilities$ sudo ./ovs-docker add-port br_inside eth2 cpe1

标签:容器,ovs,部署,openvswitch,add,br,docker,2.11
来源: https://www.cnblogs.com/dablyo/p/11617888.html