summaryrefslogtreecommitdiff
path: root/utilities/docker
diff options
context:
space:
mode:
authorAliasgar Ginwala <amginwal@gmail.com>2019-08-17 00:21:45 -0700
committerBen Pfaff <blp@ovn.org>2019-08-22 13:19:46 -0700
commit6b4dc055d643735b1856f335356dbfed5c52bcde (patch)
treec2da001bfe7ba2fb0225a747b1e6d420641a0632 /utilities/docker
parentbf1f453fd26789895ae6543f7ab1945375136448 (diff)
downloadopenvswitch-6b4dc055d643735b1856f335356dbfed5c52bcde.tar.gz
OVS: Containerize components
1. Start OVS components in containers so that building and shipping of OVS components is easy. 2. Load OVS kernel modules on host from container to avoid installing ovs on host. 3. Update documentation about how to build/run ovs in docker. Acked-by: Numan Siddique <nusiddiq@redhat.com> Signed-off-by: aginwala <aginwala@ebay.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
Diffstat (limited to 'utilities/docker')
-rw-r--r--utilities/docker/Makefile22
-rwxr-xr-xutilities/docker/create_ovs_db.sh16
-rw-r--r--utilities/docker/debian/Dockerfile20
-rwxr-xr-xutilities/docker/debian/build-kernel-modules.sh44
-rw-r--r--utilities/docker/ovs-override.conf4
-rwxr-xr-xutilities/docker/start-ovs42
6 files changed, 148 insertions, 0 deletions
diff --git a/utilities/docker/Makefile b/utilities/docker/Makefile
new file mode 100644
index 000000000..8c2f7810e
--- /dev/null
+++ b/utilities/docker/Makefile
@@ -0,0 +1,22 @@
+#export OVS_BRANCH=branch-2.11
+#export OVS_VERSION=2.11
+#export KERNEL_VERSION=4.15.0-54-generic
+#export DISTRO=debian
+#export GITHUB_SRC=https://github.com/openvswitch/ovs.git
+#export DOCKER_REPO=openvswitch/ovs
+
+# Example:
+# make build
+# make push
+
+REPO = ${DOCKER_REPO}
+tag = ${OVS_VERSION}_${KERNEL_VERSION}
+
+build: ;docker build -t ${REPO}:${tag} --build-arg DISTRO=${DISTRO} \
+--build-arg OVS_BRANCH=${OVS_BRANCH} \
+--build-arg KERNEL_VERSION=${KERNEL_VERSION} \
+--build-arg GITHUB_SRC=${GITHUB_SRC} -f ${DISTRO}/Dockerfile .
+
+.PHONY: build
+
+push: ;docker push ${REPO}:${tag}
diff --git a/utilities/docker/create_ovs_db.sh b/utilities/docker/create_ovs_db.sh
new file mode 100755
index 000000000..42572967e
--- /dev/null
+++ b/utilities/docker/create_ovs_db.sh
@@ -0,0 +1,16 @@
+#!/bin/sh
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+ovsdb-tool create /etc/openvswitch/conf.db \
+/usr/share/openvswitch/vswitch.ovsschema \ No newline at end of file
diff --git a/utilities/docker/debian/Dockerfile b/utilities/docker/debian/Dockerfile
new file mode 100644
index 000000000..ed4baa8f9
--- /dev/null
+++ b/utilities/docker/debian/Dockerfile
@@ -0,0 +1,20 @@
+FROM ubuntu:16.04
+MAINTAINER "Aliasgar Ginwala" <aginwala@ebay.com>
+
+ARG OVS_BRANCH
+ARG KERNEL_VERSION
+ARG GITHUB_SRC
+ARG DISTRO
+
+copy $DISTRO/build-kernel-modules.sh /build-kernel-modules.sh
+RUN /build-kernel-modules.sh $KERNEL_VERSION $OVS_BRANCH $GITHUB_SRC
+
+COPY create_ovs_db.sh /etc/openvswitch/create_ovs_db.sh
+RUN /etc/openvswitch/create_ovs_db.sh
+
+COPY ovs-override.conf /etc/depmod.d/openvswitch.conf
+
+COPY start-ovs /bin/start-ovs
+VOLUME ["/var/log/openvswitch", "/var/lib/openvswitch",\
+ "/var/run/openvswitch", "/etc/openvswitch"]
+ENTRYPOINT ["start-ovs"]
diff --git a/utilities/docker/debian/build-kernel-modules.sh b/utilities/docker/debian/build-kernel-modules.sh
new file mode 100755
index 000000000..1b12720b9
--- /dev/null
+++ b/utilities/docker/debian/build-kernel-modules.sh
@@ -0,0 +1,44 @@
+#!/bin/sh
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+KERNEL_VERSION=$1
+OVS_BRANCH=$2
+GITHUB_SRC=$3
+
+# Install deps
+linux="linux-image-$KERNEL_VERSION linux-headers-$KERNEL_VERSION"
+build_deps="apt-utils libelf-dev build-essential libssl-dev python \
+python-six wget gdb autoconf libtool git automake bzip2 debhelper \
+dh-autoreconf openssl"
+
+apt-get update
+apt-get install -y ${linux} ${build_deps}
+
+# get the source
+mkdir /build; cd /build
+git clone --depth 1 -b $OVS_BRANCH $GITHUB_SRC
+cd ovs
+
+# build and install
+./boot.sh
+./configure --localstatedir="/var" --sysconfdir="/etc" --prefix="/usr" \
+--with-linux=/lib/modules/$KERNEL_VERSION/build --enable-ssl
+make -j8; make install; make modules_install
+
+# remove deps to make the container light weight.
+apt-get remove --purge -y ${build_deps}
+apt-get autoremove -y --purge
+cd ..; rm -rf ovs
+basic_utils="vim kmod net-tools uuid-runtime iproute2"
+apt-get install -y ${basic_utils} \ No newline at end of file
diff --git a/utilities/docker/ovs-override.conf b/utilities/docker/ovs-override.conf
new file mode 100644
index 000000000..8f792e4b4
--- /dev/null
+++ b/utilities/docker/ovs-override.conf
@@ -0,0 +1,4 @@
+override openvswitch * extra
+override vport-geneve * extra
+override vport-stt * extra
+override vport-* * extra
diff --git a/utilities/docker/start-ovs b/utilities/docker/start-ovs
new file mode 100755
index 000000000..4a1a16cd1
--- /dev/null
+++ b/utilities/docker/start-ovs
@@ -0,0 +1,42 @@
+#!/bin/bash
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+case $1 in
+ "ovsdb-server") /usr/share/openvswitch/scripts/ovs-ctl start \
+ --system-id=random --no-ovs-vswitchd
+ /usr/share/openvswitch/scripts/ovs-ctl stop
+ ovsdb-server --pidfile /etc/openvswitch/conf.db \
+ -vconsole:emer -vsyslog:err -vfile:info \
+ --remote=punix:/var/run/openvswitch/db.sock \
+ --private-key=db:Open_vSwitch,SSL,private_key \
+ --certificate=db:Open_vSwitch,SSL,certificate \
+ --bootstrap-ca-cert=db:Open_vSwitch,SSL,ca_cert \
+ --log-file=/var/log/openvswitch/ovsdb-server.log \
+ --no-chdir
+ ;;
+ "ovs-vswitchd") depmod -a
+ modprobe openvswitch
+ modprobe vport_stt
+ modprobe vport_geneve
+ /usr/share/openvswitch/scripts/ovs-ctl \
+ --no-ovsdb-server start
+ /usr/share/openvswitch/scripts/ovs-ctl \
+ --no-ovsdb-server force-reload-kmod
+ /usr/share/openvswitch/scripts/ovs-ctl stop
+ ovs-vswitchd --pidfile -vconsole:emer -vsyslog:err \
+ -vfile:info --mlockall --no-chdir \
+ --log-file=/var/log/openvswitch/ovs-vswitchd.log
+ ;;
+ *) echo "$0 [ovsdb-server|ovs-vswitchd]"
+esac