From 0971e7eed66a252861b2a4617c4f82edcd838902 Mon Sep 17 00:00:00 2001 From: Fang Fenghua <449171342@qq.com> Date: Thu, 11 Jun 2015 20:40:41 +0800 Subject: [PATCH] Add openvswitch container Add openvswitch containers. Openvswitch is seperated into two running containers: ovs-db-server ovs-vswitchd The db container is what everything interacts with. Neutron tells the db its information, the vswitchd container reads this db and talks to the kernel module. The db does not need to be persistent since the plugin agent will repopulate all the information each time it is restarted and the plugin agent is required to be restarted when the ovs-vswitchd container is stopped/started to ensure the ports are setup properly. This container requires /run for the socket and /lib/modules:ro to load the appropriate host kernel module. This userspace tools and the kernel module do _not_ have to match versions. Additionally, even though it is recommended that the userspace tool be newer than the kernel version to take advantage of all the features, it is not required. Partially Implements blueprint: openvswitch-container Co-Authored-By: Sam Yaple Change-Id: I70e3807be32c9a07346d316e7856421ecf468b9a --- .../binary/openvswitch/ovs-base/Dockerfile | 5 +++++ docker/centos/binary/openvswitch/ovs-base/build | 1 + .../binary/openvswitch/ovs-db-server/Dockerfile | 7 +++++++ .../binary/openvswitch/ovs-db-server/build | 1 + .../binary/openvswitch/ovs-db-server/start.sh | 1 + .../binary/openvswitch/ovs-vswitchd/Dockerfile | 6 ++++++ .../centos/binary/openvswitch/ovs-vswitchd/build | 1 + .../binary/openvswitch/ovs-vswitchd/start.sh | 1 + docker/common/openvswitch/ovs-db-server/start.sh | 16 ++++++++++++++++ docker/common/openvswitch/ovs-vswitchd/start.sh | 14 ++++++++++++++ 10 files changed, 53 insertions(+) create mode 100644 docker/centos/binary/openvswitch/ovs-base/Dockerfile create mode 120000 docker/centos/binary/openvswitch/ovs-base/build create mode 100644 docker/centos/binary/openvswitch/ovs-db-server/Dockerfile create mode 120000 docker/centos/binary/openvswitch/ovs-db-server/build create mode 120000 docker/centos/binary/openvswitch/ovs-db-server/start.sh create mode 100644 docker/centos/binary/openvswitch/ovs-vswitchd/Dockerfile create mode 120000 docker/centos/binary/openvswitch/ovs-vswitchd/build create mode 120000 docker/centos/binary/openvswitch/ovs-vswitchd/start.sh create mode 100755 docker/common/openvswitch/ovs-db-server/start.sh create mode 100755 docker/common/openvswitch/ovs-vswitchd/start.sh diff --git a/docker/centos/binary/openvswitch/ovs-base/Dockerfile b/docker/centos/binary/openvswitch/ovs-base/Dockerfile new file mode 100644 index 0000000000..7d4ade54cd --- /dev/null +++ b/docker/centos/binary/openvswitch/ovs-base/Dockerfile @@ -0,0 +1,5 @@ +FROM %%KOLLA_NAMESPACE%%/%%KOLLA_PREFIX%%base:%%KOLLA_TAG%% +MAINTAINER Kolla Project (https://launchpad.net/kolla) + +RUN yum install -y openvswitch \ + && yum clean all diff --git a/docker/centos/binary/openvswitch/ovs-base/build b/docker/centos/binary/openvswitch/ovs-base/build new file mode 120000 index 0000000000..0e4aef422e --- /dev/null +++ b/docker/centos/binary/openvswitch/ovs-base/build @@ -0,0 +1 @@ +../../../../../../../tools/build-docker-image \ No newline at end of file diff --git a/docker/centos/binary/openvswitch/ovs-db-server/Dockerfile b/docker/centos/binary/openvswitch/ovs-db-server/Dockerfile new file mode 100644 index 0000000000..5728995b3a --- /dev/null +++ b/docker/centos/binary/openvswitch/ovs-db-server/Dockerfile @@ -0,0 +1,7 @@ +FROM %%KOLLA_NAMESPACE%%/%%KOLLA_PREFIX%%ovs-base:%%KOLLA_TAG%% +MAINTAINER Kolla Project (https://launchpad.net/kolla) + +COPY ./start.sh /start.sh + +CMD ["/start.sh"] + diff --git a/docker/centos/binary/openvswitch/ovs-db-server/build b/docker/centos/binary/openvswitch/ovs-db-server/build new file mode 120000 index 0000000000..ec19138031 --- /dev/null +++ b/docker/centos/binary/openvswitch/ovs-db-server/build @@ -0,0 +1 @@ +../../../../../tools/build-docker-image \ No newline at end of file diff --git a/docker/centos/binary/openvswitch/ovs-db-server/start.sh b/docker/centos/binary/openvswitch/ovs-db-server/start.sh new file mode 120000 index 0000000000..145b2426fc --- /dev/null +++ b/docker/centos/binary/openvswitch/ovs-db-server/start.sh @@ -0,0 +1 @@ +../../../../common/openvswitch/ovs-db-server/start.sh \ No newline at end of file diff --git a/docker/centos/binary/openvswitch/ovs-vswitchd/Dockerfile b/docker/centos/binary/openvswitch/ovs-vswitchd/Dockerfile new file mode 100644 index 0000000000..4acdb5d53f --- /dev/null +++ b/docker/centos/binary/openvswitch/ovs-vswitchd/Dockerfile @@ -0,0 +1,6 @@ +FROM %%KOLLA_NAMESPACE%%/%%KOLLA_PREFIX%%ovs-base:%%KOLLA_TAG%% +MAINTAINER Kolla Project (https://launchpad.net/kolla) + +COPY ./start.sh /start.sh + +CMD ["/start.sh"] diff --git a/docker/centos/binary/openvswitch/ovs-vswitchd/build b/docker/centos/binary/openvswitch/ovs-vswitchd/build new file mode 120000 index 0000000000..ec19138031 --- /dev/null +++ b/docker/centos/binary/openvswitch/ovs-vswitchd/build @@ -0,0 +1 @@ +../../../../../tools/build-docker-image \ No newline at end of file diff --git a/docker/centos/binary/openvswitch/ovs-vswitchd/start.sh b/docker/centos/binary/openvswitch/ovs-vswitchd/start.sh new file mode 120000 index 0000000000..c1038c338b --- /dev/null +++ b/docker/centos/binary/openvswitch/ovs-vswitchd/start.sh @@ -0,0 +1 @@ +../../../../common/openvswitch/ovs-vswitchd/start.sh \ No newline at end of file diff --git a/docker/common/openvswitch/ovs-db-server/start.sh b/docker/common/openvswitch/ovs-db-server/start.sh new file mode 100755 index 0000000000..a2b4d6c8fe --- /dev/null +++ b/docker/common/openvswitch/ovs-db-server/start.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +set -o errexit + +LOG_FILE="/var/log/openvswitch/ovsdb-server.log" +DB_FILE="/etc/openvswitch/conf.db" +UNIXSOCK_DIR="/var/run/openvswitch" +UNIXSOCK="${UNIXSOCK_DIR}/db.sock" + +mkdir -p "${UNIXSOCK_DIR}" + +if [[ ! -e "${DB_FILE}" ]]; then + ovsdb-tool create "${DB_FILE}" +fi + +exec ovsdb-server $DB_FILE -vconsole:emer -vsyslog:err -vfile:info --remote=punix:"${UNIXSOCK}" --log-file="${LOG_FILE}" diff --git a/docker/common/openvswitch/ovs-vswitchd/start.sh b/docker/common/openvswitch/ovs-vswitchd/start.sh new file mode 100755 index 0000000000..5ed1fbe755 --- /dev/null +++ b/docker/common/openvswitch/ovs-vswitchd/start.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +set -o errexit + +modprobe openvswitch + +LOG_FILE="/var/log/openvswitch/ovs-vswitchd.log" +DB_FILE="/etc/openvswitch/conf.db" +UNIXSOCK_DIR="/var/run/openvswitch" +UNIXSOCK="${UNIXSOCK_DIR}/db.sock" + +mkdir -p "${UNIXSOCK_DIR}" + +exec ovs-vswitchd unix:"${UNIXSOCK}" -vconsole:emer -vsyslog:err -vfile:info --mlockall --log-file="${LOG_FILE}"