diff mbox series

[ovs-dev,v3,ovn] Containerize components

Message ID 20190821170721.62313-1-amginwal@gmail.com
State Superseded
Headers show
Series [ovs-dev,v3,ovn] Containerize components | expand

Commit Message

aginwala aginwala Aug. 21, 2019, 5:07 p.m. UTC
From: Aliasgar Ginwala <aginwala@ebay.com>

1. Containerize ovn central components
2. Containerize ovn host
3. Update documentation about building/running ovn in containers.

Signed-off-by: Aliasgar Ginwala <aginwala@ebay.com>
---
 Documentation/intro/install/general.rst  | 83 ++++++++++++++++++++++++
 utilities/automake.mk                    |  8 +++
 utilities/docker/Makefile                | 22 +++++++
 utilities/docker/create_ovn_dbs.sh       | 18 +++++
 utilities/docker/debian/Dockerfile       | 22 +++++++
 utilities/docker/debian/build.sh         | 44 +++++++++++++
 utilities/docker/ovn_default_nb_port     |  1 +
 utilities/docker/ovn_default_northd_host |  1 +
 utilities/docker/ovn_default_sb_port     |  1 +
 utilities/docker/start-ovn               | 40 ++++++++++++
 10 files changed, 240 insertions(+)
 create mode 100644 utilities/docker/Makefile
 create mode 100755 utilities/docker/create_ovn_dbs.sh
 create mode 100644 utilities/docker/debian/Dockerfile
 create mode 100755 utilities/docker/debian/build.sh
 create mode 100644 utilities/docker/ovn_default_nb_port
 create mode 100644 utilities/docker/ovn_default_northd_host
 create mode 100644 utilities/docker/ovn_default_sb_port
 create mode 100755 utilities/docker/start-ovn

Comments

Numan Siddique Aug. 21, 2019, 7:10 p.m. UTC | #1
On Wed, Aug 21, 2019 at 10:38 PM <amginwal@gmail.com> wrote:

> From: Aliasgar Ginwala <aginwala@ebay.com>
>
> 1. Containerize ovn central components
> 2. Containerize ovn host
> 3. Update documentation about building/running ovn in containers.
>
> Signed-off-by: Aliasgar Ginwala <aginwala@ebay.com>
>

Hi Aliasgar,

There's something odd with this patch. I am not able to compile when I
apply this patch. I get the below error

**************
cd . && /bin/sh /home/nusiddiq/workspace_cpp/ovn-org/ovn/build-aux/missing
automake-1.16 --foreign Makefile
 cd . && /bin/sh ./config.status Makefile depfiles
config.status: creating Makefile
config.status: executing depfiles commands
config.status: error: in `/home/nusiddiq/workspace_cpp/ovn-org/ovn':
config.status: error: Something went wrong bootstrapping makefile fragments
    for automatic dependency tracking.  Try re-running configure with the
    '--disable-dependency-tracking' option to at least be able to build
    the package (albeit without support for automatic dependency tracking).
See `config.log' for more details
make: *** [Makefile:1763: Makefile] Error 1

************************

Thanks
Numan


> ---
>  Documentation/intro/install/general.rst  | 83 ++++++++++++++++++++++++
>  utilities/automake.mk                    |  8 +++
>  utilities/docker/Makefile                | 22 +++++++
>  utilities/docker/create_ovn_dbs.sh       | 18 +++++
>  utilities/docker/debian/Dockerfile       | 22 +++++++
>  utilities/docker/debian/build.sh         | 44 +++++++++++++
>  utilities/docker/ovn_default_nb_port     |  1 +
>  utilities/docker/ovn_default_northd_host |  1 +
>  utilities/docker/ovn_default_sb_port     |  1 +
>  utilities/docker/start-ovn               | 40 ++++++++++++
>  10 files changed, 240 insertions(+)
>  create mode 100644 utilities/docker/Makefile
>  create mode 100755 utilities/docker/create_ovn_dbs.sh
>  create mode 100644 utilities/docker/debian/Dockerfile
>  create mode 100755 utilities/docker/debian/build.sh
>  create mode 100644 utilities/docker/ovn_default_nb_port
>  create mode 100644 utilities/docker/ovn_default_northd_host
>  create mode 100644 utilities/docker/ovn_default_sb_port
>  create mode 100755 utilities/docker/start-ovn
>
> diff --git a/Documentation/intro/install/general.rst
> b/Documentation/intro/install/general.rst
> index 99d8fec04..1d5323f76 100644
> --- a/Documentation/intro/install/general.rst
> +++ b/Documentation/intro/install/general.rst
> @@ -380,6 +380,60 @@ domain socket::
>
>      $ ovn-northd --pidfile --detach --log-file
>
> +
> +Starting OVN Central services in containers
> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> +
> +For OVN central node, we dont need to load ovs kernel modules on host.
> +Hence, OVN central containers OS need not depend on host OS.
> +
> +Also we can leverage deploying entire OVN control plane in a pod spec for
> use
> +cases like OVN-kubernetes
> +
> +Export following variables in .env  and place it under
> +project root::
> +
> +    $ OVN_BRANCH=<BRANCH>
> +    $ OVN_VERSION=<VERSION>
> +    $ DISTRO=<LINUX_DISTRO>
> +    $ KERNEL_VERSION=<LINUX_KERNEL_VERSION>
> +    $ GITHUB_SRC=<GITHUB_URL>
> +    $ DOCKER_REPO=<REPO_TO_PUSH_IMAGE>
> +
> +To build ovn modules::
> +
> +    $ cd utilities/docker
> +    $ make build
> +
> +Compiled Modules will be tagged with docker image
> +
> +To Push ovn modules::
> +
> +    $ make push
> +
> +OVN docker image will be pushed to specified docker repo.
> +
> +Start OVN containers using below command::
> +
> +    $ docker run -itd --net=host --name=ovn-nb \
> +      <docker_repo>:<tag> ovn-nb-tcp
> +
> +    $ docker run -itd --net=host --name=ovn-sb \
> +      <docker_repo>:<tag> ovn-sb-tcp
> +
> +    $ docker run -itd --net=host --name=ovn-northd \
> +      <docker_repo>:<tag> ovn-northd-tcp
> +
> +.. note::
> +    Current ovn central components comes up in docker image in a
> standalone
> +    mode with protocol tcp.
> +
> +    The debian docker file use ubuntu 16.04 as a base image for reference.
> +
> +    User can use any other base image for debian, e.g. u14.04, etc.
> +
> +    RHEL based docker build support needs to be added.
> +
>  Starting OVN host service
>  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> @@ -406,6 +460,32 @@ domain socket::
>
>      $ ovn-controller --pidfile --detach --log-file
>
> +Starting OVN host service in containers
> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> +
> +For OVN host too, we dont need to load ovs kernel modules on host.
> +Hence, OVN host container OS need not depend on host OS.
> +
> +Also we can leverage deploying OVN host in a pod spec for use cases like
> +OVN-kubernetes to manage OVS which can be running as a service on host or
> in
> +container.
> +
> +Start ovsdb-server and ovs-vswitchd components as per
> +http://docs.openvswitch.org/en/latest/intro/install/general/
> +
> +start local ovn-controller with below command if ovs is also running in
> +container::
> +
> +    $ docker run -itd --net=host --name=ovn-controller \
> +      --volumes-from=ovsdb-server \
> +      <docker_repo>:<tag> ovn-controller
> +
> +start local ovn-controller with below command if ovs is running as a
> service::
> +
> +    $ docker run -itd --net=host --name=ovn-controller \
> +      -v /var/run/openvswitch/:/var/run/openvswitch/ \
> +      <docker_repo>:<tag> ovn-controller
> +
>  Validating
>  ----------
>
> @@ -419,6 +499,9 @@ logical switch ``sw0`` and add logical port ``sw0-p1``
> ::
>
>  Refer to ovn-nbctl(8) and ovn-sbctl (8) for more details.
>
> +When using ovn in container, exec to container to run above commands::
> +
> +    $ docker exec -it <ovn-nb/ovn-sb/ovn-northd/ovn-controller> /bin/bash
>
>  Reporting Bugs
>  --------------
> diff --git a/utilities/automake.mk b/utilities/automake.mk
> index b2b026f57..3142d177f 100644
> --- a/utilities/automake.mk
> +++ b/utilities/automake.mk
> @@ -29,6 +29,14 @@ EXTRA_DIST += \
>      utilities/ovn-detrace.in \
>      utilities/ovndb-servers.ocf \
>      utilities/checkpatch.py
> +    utilities/docker/Makefile \
> +    utilities/docker/start-ovn \
> +    utilities/docker/create_ovn_dbs.sh \
> +    utilities/docker/ovn_default_nb_port \
> +    utilities/docker/ovn_default_sb_port \
> +    utilities/docker/ovn_default_northd_host \
> +    utilities/docker/debian/Dockerfile \
> +    utilities/docker/debian/build.sh
>
>  CLEANFILES += \
>      utilities/ovn-ctl.8 \
> diff --git a/utilities/docker/Makefile b/utilities/docker/Makefile
> new file mode 100644
> index 000000000..e2b2c2a17
> --- /dev/null
> +++ b/utilities/docker/Makefile
> @@ -0,0 +1,22 @@
> +#export OVN_BRANCH=master
> +#export OVN_VERSION=2.12
> +#export KERNEL_VERSION=4.15.0-54-generic
> +#export DISTRO=debian
> +#export GITHUB_SRC=https://github.com/ovn-org/ovn.git
> +#export DOCKER_REPO=ovn-org/ovn
> +
> +# Example:
> +#   make build
> +#   make push
> +
> +REPO = ${DOCKER_REPO}
> +tag = ${OVN_VERSION}_${KERNEL_VERSION}
> +
> +build: ;docker build -t ${REPO}:${tag} --build-arg DISTRO=${DISTRO} \
> +--build-arg OVN_BRANCH=${OVN_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_ovn_dbs.sh
> b/utilities/docker/create_ovn_dbs.sh
> new file mode 100755
> index 000000000..43ab367d6
> --- /dev/null
> +++ b/utilities/docker/create_ovn_dbs.sh
> @@ -0,0 +1,18 @@
> +#!/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/ovnnb_db.db \
> +/usr/share/openvswitch/ovn-nb.ovsschema
> +ovsdb-tool create /etc/openvswitch/ovnsb_db.db \
> +/usr/share/openvswitch/ovn-sb.ovsschema
> diff --git a/utilities/docker/debian/Dockerfile
> b/utilities/docker/debian/Dockerfile
> new file mode 100644
> index 000000000..fe72c3a33
> --- /dev/null
> +++ b/utilities/docker/debian/Dockerfile
> @@ -0,0 +1,22 @@
> +FROM ubuntu:16.04
> +MAINTAINER "Aliasgar Ginwala" <aginwala@ebay.com>
> +
> +ARG OVN_BRANCH
> +ARG KERNEL_VERSION
> +ARG GITHUB_SRC
> +ARG DISTRO
> +
> +copy $DISTRO/build.sh /build.sh
> +RUN /build.sh $KERNEL_VERSION $OVN_BRANCH $GITHUB_SRC
> +
> +COPY create_ovn_dbs.sh /etc/openvswitch/create_ovn_dbs.sh
> +RUN /etc/openvswitch/create_ovn_dbs.sh
> +
> +COPY ovn_default_nb_port /etc/openvswitch/ovn_default_nb_port
> +COPY ovn_default_sb_port /etc/openvswitch/ovn_default_sb_port
> +COPY ovn_default_northd_host /etc/openvswitch/ovn_default_northd_host
> +
> +COPY start-ovn /bin/start-ovn
> +VOLUME ["/var/log/openvswitch", \
> +"/var/lib/openvswitch", "/var/run/openvswitch", "/etc/openvswitch"]
> +ENTRYPOINT ["start-ovn"]
> diff --git a/utilities/docker/debian/build.sh
> b/utilities/docker/debian/build.sh
> new file mode 100755
> index 000000000..fd26a8aa8
> --- /dev/null
> +++ b/utilities/docker/debian/build.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
> +OVN_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 $OVN_BRANCH $GITHUB_SRC
> +cd ovn
> +
> +# 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
> +
> +# remove deps to make the container light weight.
> +apt-get remove --purge -y ${build_deps}
> +apt-get autoremove -y --purge
> +cd ..; rm -rf ovn
> +basic_utils="vim kmod net-tools uuid-runtime iproute2"
> +apt-get install -y ${basic_utils}
> diff --git a/utilities/docker/ovn_default_nb_port
> b/utilities/docker/ovn_default_nb_port
> new file mode 100644
> index 000000000..d83211678
> --- /dev/null
> +++ b/utilities/docker/ovn_default_nb_port
> @@ -0,0 +1 @@
> +nb_db_port=6641
> diff --git a/utilities/docker/ovn_default_northd_host
> b/utilities/docker/ovn_default_northd_host
> new file mode 100644
> index 000000000..55d4ab7aa
> --- /dev/null
> +++ b/utilities/docker/ovn_default_northd_host
> @@ -0,0 +1 @@
> +northd_host=127.0.0.1
> diff --git a/utilities/docker/ovn_default_sb_port
> b/utilities/docker/ovn_default_sb_port
> new file mode 100644
> index 000000000..4c9e3f585
> --- /dev/null
> +++ b/utilities/docker/ovn_default_sb_port
> @@ -0,0 +1 @@
> +sb_db_port=6642
> diff --git a/utilities/docker/start-ovn b/utilities/docker/start-ovn
> new file mode 100755
> index 000000000..7f87e65a3
> --- /dev/null
> +++ b/utilities/docker/start-ovn
> @@ -0,0 +1,40 @@
> +#!/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
> +        "ovn-nb-tcp") source /etc/openvswitch/ovn_default_nb_port
> +                      /usr/share/openvswitch/scripts/ovn-ctl start_ovsdb
> +                      ovn-nbctl set-connection ptcp:$nb_db_port
> +                      /usr/share/openvswitch/scripts/ovn-ctl stop_ovsdb
> +                      /usr/share/openvswitch/scripts/ovn-ctl run_nb_ovsdb
> +        ;;
> +        "ovn-sb-tcp") source /etc/openvswitch/ovn_default_sb_port
> +                      /usr/share/openvswitch/scripts/ovn-ctl start_ovsdb
> +                      ovn-sbctl set-connection ptcp:$sb_db_port
> +                      /usr/share/openvswitch/scripts/ovn-ctl stop_ovsdb
> +                      /usr/share/openvswitch/scripts/ovn-ctl run_sb_ovsdb
> +        ;;
> +        "ovn-northd-tcp") source /etc/openvswitch/ovn_default_northd_host
> +                          source /etc/openvswitch/ovn_default_nb_port
> +                          source /etc/openvswitch/ovn_default_sb_port
> +                          ovn-northd --pidfile \
> +                          --ovnnb-db="tcp:$northd_host:$nb_db_port" \
> +                          --ovnsb-db="tcp:$northd_host:$sb_db_port" \
> +                          --log-file=/var/log/openvswitch/ovn-northd.log
> +        ;;
> +        "ovn-controller") ovn-controller --pidfile \
> +
> --log-file=/var/log/openvswitch/ovn-controller.log
> +        ;;
> +        *) echo "$0 [ovn-nb-tcp|ovn-sb-tcp|ovn-northd-tcp|ovn-controller]"
> +esac
> --
> 2.20.1 (Apple Git-117)
>
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
>
Aaron Conole Aug. 21, 2019, 7:20 p.m. UTC | #2
amginwal@gmail.com writes:

> From: Aliasgar Ginwala <aginwala@ebay.com>
>
> 1. Containerize ovn central components
> 2. Containerize ovn host
> 3. Update documentation about building/running ovn in containers.
>
> Signed-off-by: Aliasgar Ginwala <aginwala@ebay.com>
> ---

Hi Aliasgar,

It seems this patch has some issues with the Makefile syntax.

See:

https://travis-ci.com/ovsrobot/ovn/builds/124110711

>  Documentation/intro/install/general.rst  | 83 ++++++++++++++++++++++++
>  utilities/automake.mk                    |  8 +++
>  utilities/docker/Makefile                | 22 +++++++
>  utilities/docker/create_ovn_dbs.sh       | 18 +++++
>  utilities/docker/debian/Dockerfile       | 22 +++++++
>  utilities/docker/debian/build.sh         | 44 +++++++++++++
>  utilities/docker/ovn_default_nb_port     |  1 +
>  utilities/docker/ovn_default_northd_host |  1 +
>  utilities/docker/ovn_default_sb_port     |  1 +
>  utilities/docker/start-ovn               | 40 ++++++++++++
>  10 files changed, 240 insertions(+)
>  create mode 100644 utilities/docker/Makefile
>  create mode 100755 utilities/docker/create_ovn_dbs.sh
>  create mode 100644 utilities/docker/debian/Dockerfile
>  create mode 100755 utilities/docker/debian/build.sh
>  create mode 100644 utilities/docker/ovn_default_nb_port
>  create mode 100644 utilities/docker/ovn_default_northd_host
>  create mode 100644 utilities/docker/ovn_default_sb_port
>  create mode 100755 utilities/docker/start-ovn
>
> diff --git a/Documentation/intro/install/general.rst b/Documentation/intro/install/general.rst
> index 99d8fec04..1d5323f76 100644
> --- a/Documentation/intro/install/general.rst
> +++ b/Documentation/intro/install/general.rst
> @@ -380,6 +380,60 @@ domain socket::
>  
>      $ ovn-northd --pidfile --detach --log-file
>  
> +
> +Starting OVN Central services in containers
> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> +
> +For OVN central node, we dont need to load ovs kernel modules on host.
> +Hence, OVN central containers OS need not depend on host OS.
> +
> +Also we can leverage deploying entire OVN control plane in a pod spec for use
> +cases like OVN-kubernetes
> +
> +Export following variables in .env  and place it under
> +project root::
> +
> +    $ OVN_BRANCH=<BRANCH>
> +    $ OVN_VERSION=<VERSION>
> +    $ DISTRO=<LINUX_DISTRO>
> +    $ KERNEL_VERSION=<LINUX_KERNEL_VERSION>
> +    $ GITHUB_SRC=<GITHUB_URL>
> +    $ DOCKER_REPO=<REPO_TO_PUSH_IMAGE>
> +
> +To build ovn modules::
> +
> +    $ cd utilities/docker
> +    $ make build
> +
> +Compiled Modules will be tagged with docker image
> +
> +To Push ovn modules::
> +
> +    $ make push
> +
> +OVN docker image will be pushed to specified docker repo.
> +
> +Start OVN containers using below command::
> +
> +    $ docker run -itd --net=host --name=ovn-nb \
> +      <docker_repo>:<tag> ovn-nb-tcp
> +
> +    $ docker run -itd --net=host --name=ovn-sb \
> +      <docker_repo>:<tag> ovn-sb-tcp
> +
> +    $ docker run -itd --net=host --name=ovn-northd \
> +      <docker_repo>:<tag> ovn-northd-tcp
> +
> +.. note::
> +    Current ovn central components comes up in docker image in a standalone
> +    mode with protocol tcp.
> +
> +    The debian docker file use ubuntu 16.04 as a base image for reference.
> +
> +    User can use any other base image for debian, e.g. u14.04, etc.
> +
> +    RHEL based docker build support needs to be added.
> +
>  Starting OVN host service
>  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>  
> @@ -406,6 +460,32 @@ domain socket::
>  
>      $ ovn-controller --pidfile --detach --log-file
>  
> +Starting OVN host service in containers
> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> +
> +For OVN host too, we dont need to load ovs kernel modules on host.
> +Hence, OVN host container OS need not depend on host OS.
> +
> +Also we can leverage deploying OVN host in a pod spec for use cases like
> +OVN-kubernetes to manage OVS which can be running as a service on host or in
> +container.
> +
> +Start ovsdb-server and ovs-vswitchd components as per
> +http://docs.openvswitch.org/en/latest/intro/install/general/
> +
> +start local ovn-controller with below command if ovs is also running in
> +container::
> +
> +    $ docker run -itd --net=host --name=ovn-controller \
> +      --volumes-from=ovsdb-server \
> +      <docker_repo>:<tag> ovn-controller
> +
> +start local ovn-controller with below command if ovs is running as a service::
> +
> +    $ docker run -itd --net=host --name=ovn-controller \
> +      -v /var/run/openvswitch/:/var/run/openvswitch/ \
> +      <docker_repo>:<tag> ovn-controller
> +
>  Validating
>  ----------
>  
> @@ -419,6 +499,9 @@ logical switch ``sw0`` and add logical port ``sw0-p1`` ::
>  
>  Refer to ovn-nbctl(8) and ovn-sbctl (8) for more details.
>  
> +When using ovn in container, exec to container to run above commands::
> +
> +    $ docker exec -it <ovn-nb/ovn-sb/ovn-northd/ovn-controller> /bin/bash
>  
>  Reporting Bugs
>  --------------
> diff --git a/utilities/automake.mk b/utilities/automake.mk
> index b2b026f57..3142d177f 100644
> --- a/utilities/automake.mk
> +++ b/utilities/automake.mk
> @@ -29,6 +29,14 @@ EXTRA_DIST += \
>      utilities/ovn-detrace.in \
>      utilities/ovndb-servers.ocf \
>      utilities/checkpatch.py
> +    utilities/docker/Makefile \
> +    utilities/docker/start-ovn \
> +    utilities/docker/create_ovn_dbs.sh \
> +    utilities/docker/ovn_default_nb_port \
> +    utilities/docker/ovn_default_sb_port \
> +    utilities/docker/ovn_default_northd_host \
> +    utilities/docker/debian/Dockerfile \
> +    utilities/docker/debian/build.sh
>  
>  CLEANFILES += \
>      utilities/ovn-ctl.8 \
> diff --git a/utilities/docker/Makefile b/utilities/docker/Makefile
> new file mode 100644
> index 000000000..e2b2c2a17
> --- /dev/null
> +++ b/utilities/docker/Makefile
> @@ -0,0 +1,22 @@
> +#export OVN_BRANCH=master
> +#export OVN_VERSION=2.12
> +#export KERNEL_VERSION=4.15.0-54-generic
> +#export DISTRO=debian
> +#export GITHUB_SRC=https://github.com/ovn-org/ovn.git
> +#export DOCKER_REPO=ovn-org/ovn
> +
> +# Example:
> +#   make build
> +#   make push
> +
> +REPO = ${DOCKER_REPO}
> +tag = ${OVN_VERSION}_${KERNEL_VERSION}
> +
> +build: ;docker build -t ${REPO}:${tag} --build-arg DISTRO=${DISTRO} \
> +--build-arg OVN_BRANCH=${OVN_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_ovn_dbs.sh b/utilities/docker/create_ovn_dbs.sh
> new file mode 100755
> index 000000000..43ab367d6
> --- /dev/null
> +++ b/utilities/docker/create_ovn_dbs.sh
> @@ -0,0 +1,18 @@
> +#!/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/ovnnb_db.db \
> +/usr/share/openvswitch/ovn-nb.ovsschema
> +ovsdb-tool create /etc/openvswitch/ovnsb_db.db \
> +/usr/share/openvswitch/ovn-sb.ovsschema
> diff --git a/utilities/docker/debian/Dockerfile b/utilities/docker/debian/Dockerfile
> new file mode 100644
> index 000000000..fe72c3a33
> --- /dev/null
> +++ b/utilities/docker/debian/Dockerfile
> @@ -0,0 +1,22 @@
> +FROM ubuntu:16.04
> +MAINTAINER "Aliasgar Ginwala" <aginwala@ebay.com>
> +
> +ARG OVN_BRANCH
> +ARG KERNEL_VERSION
> +ARG GITHUB_SRC
> +ARG DISTRO
> +
> +copy $DISTRO/build.sh /build.sh
> +RUN /build.sh $KERNEL_VERSION $OVN_BRANCH $GITHUB_SRC
> +
> +COPY create_ovn_dbs.sh /etc/openvswitch/create_ovn_dbs.sh
> +RUN /etc/openvswitch/create_ovn_dbs.sh
> +
> +COPY ovn_default_nb_port /etc/openvswitch/ovn_default_nb_port
> +COPY ovn_default_sb_port /etc/openvswitch/ovn_default_sb_port
> +COPY ovn_default_northd_host /etc/openvswitch/ovn_default_northd_host
> +
> +COPY start-ovn /bin/start-ovn
> +VOLUME ["/var/log/openvswitch", \
> +"/var/lib/openvswitch", "/var/run/openvswitch", "/etc/openvswitch"]
> +ENTRYPOINT ["start-ovn"]
> diff --git a/utilities/docker/debian/build.sh b/utilities/docker/debian/build.sh
> new file mode 100755
> index 000000000..fd26a8aa8
> --- /dev/null
> +++ b/utilities/docker/debian/build.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
> +OVN_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 $OVN_BRANCH $GITHUB_SRC
> +cd ovn
> +
> +# 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
> +
> +# remove deps to make the container light weight.
> +apt-get remove --purge -y ${build_deps}
> +apt-get autoremove -y --purge
> +cd ..; rm -rf ovn
> +basic_utils="vim kmod net-tools uuid-runtime iproute2"
> +apt-get install -y ${basic_utils}
> diff --git a/utilities/docker/ovn_default_nb_port b/utilities/docker/ovn_default_nb_port
> new file mode 100644
> index 000000000..d83211678
> --- /dev/null
> +++ b/utilities/docker/ovn_default_nb_port
> @@ -0,0 +1 @@
> +nb_db_port=6641
> diff --git a/utilities/docker/ovn_default_northd_host b/utilities/docker/ovn_default_northd_host
> new file mode 100644
> index 000000000..55d4ab7aa
> --- /dev/null
> +++ b/utilities/docker/ovn_default_northd_host
> @@ -0,0 +1 @@
> +northd_host=127.0.0.1
> diff --git a/utilities/docker/ovn_default_sb_port b/utilities/docker/ovn_default_sb_port
> new file mode 100644
> index 000000000..4c9e3f585
> --- /dev/null
> +++ b/utilities/docker/ovn_default_sb_port
> @@ -0,0 +1 @@
> +sb_db_port=6642
> diff --git a/utilities/docker/start-ovn b/utilities/docker/start-ovn
> new file mode 100755
> index 000000000..7f87e65a3
> --- /dev/null
> +++ b/utilities/docker/start-ovn
> @@ -0,0 +1,40 @@
> +#!/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
> +        "ovn-nb-tcp") source /etc/openvswitch/ovn_default_nb_port
> +                      /usr/share/openvswitch/scripts/ovn-ctl start_ovsdb
> +                      ovn-nbctl set-connection ptcp:$nb_db_port
> +                      /usr/share/openvswitch/scripts/ovn-ctl stop_ovsdb
> +                      /usr/share/openvswitch/scripts/ovn-ctl run_nb_ovsdb
> +        ;;
> +        "ovn-sb-tcp") source /etc/openvswitch/ovn_default_sb_port
> +                      /usr/share/openvswitch/scripts/ovn-ctl start_ovsdb
> +                      ovn-sbctl set-connection ptcp:$sb_db_port
> +                      /usr/share/openvswitch/scripts/ovn-ctl stop_ovsdb
> +                      /usr/share/openvswitch/scripts/ovn-ctl run_sb_ovsdb
> +        ;;
> +        "ovn-northd-tcp") source /etc/openvswitch/ovn_default_northd_host
> +                          source /etc/openvswitch/ovn_default_nb_port
> +                          source /etc/openvswitch/ovn_default_sb_port
> +                          ovn-northd --pidfile \
> +                          --ovnnb-db="tcp:$northd_host:$nb_db_port" \
> +                          --ovnsb-db="tcp:$northd_host:$sb_db_port" \
> +                          --log-file=/var/log/openvswitch/ovn-northd.log
> +        ;;
> +        "ovn-controller") ovn-controller --pidfile \
> +                          --log-file=/var/log/openvswitch/ovn-controller.log
> +        ;;
> +        *) echo "$0 [ovn-nb-tcp|ovn-sb-tcp|ovn-northd-tcp|ovn-controller]"
> +esac
Li,Rongqing via dev Aug. 21, 2019, 8:06 p.m. UTC | #3
Ah I see, the issue is in syntax of automake.mk due to rebase with checkpatch.py:

diff --git a/utilities/automake.mk b/utilities/automake.mk
index 3142d177f..9b46940ae 100644
--- a/utilities/automake.mk
+++ b/utilities/automake.mk
@@ -28,7 +28,7 @@ EXTRA_DIST += \
     utilities/ovn-trace.8.xml \
     utilities/ovn-detrace.in \
     utilities/ovndb-servers.ocf \
-    utilities/checkpatch.py
+    utilities/checkpatch.py \
     utilities/docker/Makefile \
     utilities/docker/start-ovn \
     utilities/docker/create_ovn_dbs.sh \


I just tried rebuilding newest docker image with this fix and it built fine:
LM-SJC-11015761:ovn aginwala$ export OVN_BRANCH=ovn_container
LM-SJC-11015761:ovn aginwala$ export OVN_VERSION=2.12
LM-SJC-11015761:ovn aginwala$ export KERNEL_VERSION=4.15.0-54-generic
LM-SJC-11015761:ovn aginwala$ export DISTRO=debian
LM-SJC-11015761:ovn aginwala$ export GITHUB_SRC=https://github.com/noah8713/ovn.git
LM-SJC-11015761:ovn aginwala$ export DOCKER_REPO=aginwala/ovn
LM-SJC-11015761:ovn aginwala$ cd utilities/
LM-SJC-11015761:utilities aginwala$ cd docker/
LM-SJC-11015761:docker aginwala$ make build


Sent V4 to address the same.

Regards,
Aliasgar

From: Numan Siddique <nusiddiq@redhat.com>
Date: Wednesday, August 21, 2019 at 12:11 PM
To: aginwala <amginwal@gmail.com>
Cc: ovs dev <dev@openvswitch.org>, "Ginwala, Aliasgar" <aginwala@ebay.com>
Subject: Re: [ovs-dev] [PATCH v3 ovn] Containerize components



On Wed, Aug 21, 2019 at 10:38 PM <amginwal@gmail.com<mailto:amginwal@gmail.com>> wrote:
From: Aliasgar Ginwala <aginwala@ebay.com<mailto:aginwala@ebay.com>>

1. Containerize ovn central components
2. Containerize ovn host
3. Update documentation about building/running ovn in containers.

Signed-off-by: Aliasgar Ginwala <aginwala@ebay.com<mailto:aginwala@ebay.com>>

Hi Aliasgar,

There's something odd with this patch. I am not able to compile when I apply this patch. I get the below error

**************
cd . && /bin/sh /home/nusiddiq/workspace_cpp/ovn-org/ovn/build-aux/missing automake-1.16 --foreign Makefile
 cd . && /bin/sh ./config.status Makefile depfiles
config.status: creating Makefile
config.status: executing depfiles commands
config.status: error: in `/home/nusiddiq/workspace_cpp/ovn-org/ovn':
config.status: error: Something went wrong bootstrapping makefile fragments
    for automatic dependency tracking.  Try re-running configure with the
    '--disable-dependency-tracking' option to at least be able to build
    the package (albeit without support for automatic dependency tracking).
See `config.log' for more details
make: *** [Makefile:1763: Makefile] Error 1

************************

Thanks
Numan

---
 Documentation/intro/install/general.rst  | 83 ++++++++++++++++++++++++
 utilities/automake.mk<https://nam01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fautomake.mk&data=02%7C01%7Caginwala%40ebay.com%7C5c887b75459948d3c90208d7266b5201%7C46326bff992841a0baca17c16c94ea99%7C0%7C0%7C637020114699089802&sdata=IFwvFotxdpCE913klL68ZrPDXdzwgmocsXgP%2FBv3HtY%3D&reserved=0>                    |  8 +++
 utilities/docker/Makefile                | 22 +++++++
 utilities/docker/create_ovn_dbs.sh       | 18 +++++
 utilities/docker/debian/Dockerfile       | 22 +++++++
 utilities/docker/debian/build.sh         | 44 +++++++++++++
 utilities/docker/ovn_default_nb_port     |  1 +
 utilities/docker/ovn_default_northd_host |  1 +
 utilities/docker/ovn_default_sb_port     |  1 +
 utilities/docker/start-ovn               | 40 ++++++++++++
 10 files changed, 240 insertions(+)
 create mode 100644 utilities/docker/Makefile
 create mode 100755 utilities/docker/create_ovn_dbs.sh
 create mode 100644 utilities/docker/debian/Dockerfile
 create mode 100755 utilities/docker/debian/build.sh
 create mode 100644 utilities/docker/ovn_default_nb_port
 create mode 100644 utilities/docker/ovn_default_northd_host
 create mode 100644 utilities/docker/ovn_default_sb_port
 create mode 100755 utilities/docker/start-ovn

diff --git a/Documentation/intro/install/general.rst b/Documentation/intro/install/general.rst
index 99d8fec04..1d5323f76 100644
--- a/Documentation/intro/install/general.rst
+++ b/Documentation/intro/install/general.rst
@@ -380,6 +380,60 @@ domain socket::

     $ ovn-northd --pidfile --detach --log-file

+
+Starting OVN Central services in containers
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+For OVN central node, we dont need to load ovs kernel modules on host.
+Hence, OVN central containers OS need not depend on host OS.
+
+Also we can leverage deploying entire OVN control plane in a pod spec for use
+cases like OVN-kubernetes
+
+Export following variables in .env  and place it under
+project root::
+
+    $ OVN_BRANCH=<BRANCH>
+    $ OVN_VERSION=<VERSION>
+    $ DISTRO=<LINUX_DISTRO>
+    $ KERNEL_VERSION=<LINUX_KERNEL_VERSION>
+    $ GITHUB_SRC=<GITHUB_URL>
+    $ DOCKER_REPO=<REPO_TO_PUSH_IMAGE>
+
+To build ovn modules::
+
+    $ cd utilities/docker
+    $ make build
+
+Compiled Modules will be tagged with docker image
+
+To Push ovn modules::
+
+    $ make push
+
+OVN docker image will be pushed to specified docker repo.
+
+Start OVN containers using below command::
+
+    $ docker run -itd --net=host --name=ovn-nb \
+      <docker_repo>:<tag> ovn-nb-tcp
+
+    $ docker run -itd --net=host --name=ovn-sb \
+      <docker_repo>:<tag> ovn-sb-tcp
+
+    $ docker run -itd --net=host --name=ovn-northd \
+      <docker_repo>:<tag> ovn-northd-tcp
+
+.. note::
+    Current ovn central components comes up in docker image in a standalone
+    mode with protocol tcp.
+
+    The debian docker file use ubuntu 16.04 as a base image for reference.
+
+    User can use any other base image for debian, e.g. u14.04, etc.
+
+    RHEL based docker build support needs to be added.
+
 Starting OVN host service
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~

@@ -406,6 +460,32 @@ domain socket::

     $ ovn-controller --pidfile --detach --log-file

+Starting OVN host service in containers
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+For OVN host too, we dont need to load ovs kernel modules on host.
+Hence, OVN host container OS need not depend on host OS.
+
+Also we can leverage deploying OVN host in a pod spec for use cases like
+OVN-kubernetes to manage OVS which can be running as a service on host or in
+container.
+
+Start ovsdb-server and ovs-vswitchd components as per
+http://docs.openvswitch.org/en/latest/intro/install/general/<https://nam01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fdocs.openvswitch.org%2Fen%2Flatest%2Fintro%2Finstall%2Fgeneral%2F&data=02%7C01%7Caginwala%40ebay.com%7C5c887b75459948d3c90208d7266b5201%7C46326bff992841a0baca17c16c94ea99%7C0%7C0%7C637020114699099797&sdata=YtZ2Gd8Nx6HlmVqgIjJsV6zFGfsKHZnuOPHuDrXfvf8%3D&reserved=0>
+
+start local ovn-controller with below command if ovs is also running in
+container::
+
+    $ docker run -itd --net=host --name=ovn-controller \
+      --volumes-from=ovsdb-server \
+      <docker_repo>:<tag> ovn-controller
+
+start local ovn-controller with below command if ovs is running as a service::
+
+    $ docker run -itd --net=host --name=ovn-controller \
+      -v /var/run/openvswitch/:/var/run/openvswitch/ \
+      <docker_repo>:<tag> ovn-controller
+
 Validating
 ----------

@@ -419,6 +499,9 @@ logical switch ``sw0`` and add logical port ``sw0-p1`` ::

 Refer to ovn-nbctl(8) and ovn-sbctl (8) for more details.

+When using ovn in container, exec to container to run above commands::
+
+    $ docker exec -it <ovn-nb/ovn-sb/ovn-northd/ovn-controller> /bin/bash

 Reporting Bugs
 --------------
diff --git a/utilities/automake.mk<https://nam01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fautomake.mk&data=02%7C01%7Caginwala%40ebay.com%7C5c887b75459948d3c90208d7266b5201%7C46326bff992841a0baca17c16c94ea99%7C0%7C0%7C637020114699099797&sdata=8HSH7MXu%2BOor33%2Br9K3suzj2WMZWDjEB2Kpd0HSWBQ0%3D&reserved=0> b/utilities/automake.mk<https://nam01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fautomake.mk&data=02%7C01%7Caginwala%40ebay.com%7C5c887b75459948d3c90208d7266b5201%7C46326bff992841a0baca17c16c94ea99%7C0%7C0%7C637020114699109793&sdata=xG24JmoccdK3DFiKhHWZijLOwkJfjoEigQV19FsMMLo%3D&reserved=0>
index b2b026f57..3142d177f 100644
--- a/utilities/automake.mk<https://nam01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fautomake.mk&data=02%7C01%7Caginwala%40ebay.com%7C5c887b75459948d3c90208d7266b5201%7C46326bff992841a0baca17c16c94ea99%7C0%7C0%7C637020114699109793&sdata=xG24JmoccdK3DFiKhHWZijLOwkJfjoEigQV19FsMMLo%3D&reserved=0>
+++ b/utilities/automake.mk<https://nam01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fautomake.mk&data=02%7C01%7Caginwala%40ebay.com%7C5c887b75459948d3c90208d7266b5201%7C46326bff992841a0baca17c16c94ea99%7C0%7C0%7C637020114699119789&sdata=EYD23ODKzsLVmxEmXiAxu4WLkHr2nD5M7YSaSSZcgO0%3D&reserved=0>
@@ -29,6 +29,14 @@ EXTRA_DIST += \
     utilities/ovn-detrace.in<https://nam01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fovn-detrace.in&data=02%7C01%7Caginwala%40ebay.com%7C5c887b75459948d3c90208d7266b5201%7C46326bff992841a0baca17c16c94ea99%7C0%7C0%7C637020114699119789&sdata=ChCO6liYz%2Fz36O3ObmemkJLgtRkWptVYBF4tkppx9x4%3D&reserved=0> \
     utilities/ovndb-servers.ocf \
     utilities/checkpatch.py
+    utilities/docker/Makefile \
+    utilities/docker/start-ovn \
+    utilities/docker/create_ovn_dbs.sh \
+    utilities/docker/ovn_default_nb_port \
+    utilities/docker/ovn_default_sb_port \
+    utilities/docker/ovn_default_northd_host \
+    utilities/docker/debian/Dockerfile \
+    utilities/docker/debian/build.sh

 CLEANFILES += \
     utilities/ovn-ctl.8 \
diff --git a/utilities/docker/Makefile b/utilities/docker/Makefile
new file mode 100644
index 000000000..e2b2c2a17
--- /dev/null
+++ b/utilities/docker/Makefile
@@ -0,0 +1,22 @@
+#export OVN_BRANCH=master
+#export OVN_VERSION=2.12
+#export KERNEL_VERSION=4.15.0-54-generic
+#export DISTRO=debian
+#export GITHUB_SRC=https://github.com/ovn-org/ovn.git<https://nam01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fovn-org%2Fovn.git&data=02%7C01%7Caginwala%40ebay.com%7C5c887b75459948d3c90208d7266b5201%7C46326bff992841a0baca17c16c94ea99%7C0%7C0%7C637020114699129785&sdata=wucY35GEh8T6qrot4zcb3eA7K2lKbrdiY6rLntTY%2BSI%3D&reserved=0>
+#export DOCKER_REPO=ovn-org/ovn
+
+# Example:
+#   make build
+#   make push
+
+REPO = ${DOCKER_REPO}
+tag = ${OVN_VERSION}_${KERNEL_VERSION}
+
+build: ;docker build -t ${REPO}:${tag} --build-arg DISTRO=${DISTRO} \
+--build-arg OVN_BRANCH=${OVN_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_ovn_dbs.sh b/utilities/docker/create_ovn_dbs.sh
new file mode 100755
index 000000000..43ab367d6
--- /dev/null
+++ b/utilities/docker/create_ovn_dbs.sh
@@ -0,0 +1,18 @@
+#!/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<https://nam01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.apache.org%2Flicenses%2FLICENSE-2.0&data=02%7C01%7Caginwala%40ebay.com%7C5c887b75459948d3c90208d7266b5201%7C46326bff992841a0baca17c16c94ea99%7C0%7C0%7C637020114699139783&sdata=h%2Fkh%2BZ%2FNyrYs7SSaIzhQmk8%2BAfc49mLPe28gnw197YE%3D&reserved=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/ovnnb_db.db \
+/usr/share/openvswitch/ovn-nb.ovsschema
+ovsdb-tool create /etc/openvswitch/ovnsb_db.db \
+/usr/share/openvswitch/ovn-sb.ovsschema
diff --git a/utilities/docker/debian/Dockerfile b/utilities/docker/debian/Dockerfile
new file mode 100644
index 000000000..fe72c3a33
--- /dev/null
+++ b/utilities/docker/debian/Dockerfile
@@ -0,0 +1,22 @@
+FROM ubuntu:16.04
+MAINTAINER "Aliasgar Ginwala" <aginwala@ebay.com<mailto:aginwala@ebay.com>>
+
+ARG OVN_BRANCH
+ARG KERNEL_VERSION
+ARG GITHUB_SRC
+ARG DISTRO
+
+copy $DISTRO/build.sh /build.sh
+RUN /build.sh $KERNEL_VERSION $OVN_BRANCH $GITHUB_SRC
+
+COPY create_ovn_dbs.sh /etc/openvswitch/create_ovn_dbs.sh
+RUN /etc/openvswitch/create_ovn_dbs.sh
+
+COPY ovn_default_nb_port /etc/openvswitch/ovn_default_nb_port
+COPY ovn_default_sb_port /etc/openvswitch/ovn_default_sb_port
+COPY ovn_default_northd_host /etc/openvswitch/ovn_default_northd_host
+
+COPY start-ovn /bin/start-ovn
+VOLUME ["/var/log/openvswitch", \
+"/var/lib/openvswitch", "/var/run/openvswitch", "/etc/openvswitch"]
+ENTRYPOINT ["start-ovn"]
diff --git a/utilities/docker/debian/build.sh b/utilities/docker/debian/build.sh
new file mode 100755
index 000000000..fd26a8aa8
--- /dev/null
+++ b/utilities/docker/debian/build.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<https://nam01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.apache.org%2Flicenses%2FLICENSE-2.0&data=02%7C01%7Caginwala%40ebay.com%7C5c887b75459948d3c90208d7266b5201%7C46326bff992841a0baca17c16c94ea99%7C0%7C0%7C637020114699139783&sdata=h%2Fkh%2BZ%2FNyrYs7SSaIzhQmk8%2BAfc49mLPe28gnw197YE%3D&reserved=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
+OVN_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 $OVN_BRANCH $GITHUB_SRC
+cd ovn
+
+# 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
+
+# remove deps to make the container light weight.
+apt-get remove --purge -y ${build_deps}
+apt-get autoremove -y --purge
+cd ..; rm -rf ovn
+basic_utils="vim kmod net-tools uuid-runtime iproute2"
+apt-get install -y ${basic_utils}
diff --git a/utilities/docker/ovn_default_nb_port b/utilities/docker/ovn_default_nb_port
new file mode 100644
index 000000000..d83211678
--- /dev/null
+++ b/utilities/docker/ovn_default_nb_port
@@ -0,0 +1 @@
+nb_db_port=6641
diff --git a/utilities/docker/ovn_default_northd_host b/utilities/docker/ovn_default_northd_host
new file mode 100644
index 000000000..55d4ab7aa
--- /dev/null
+++ b/utilities/docker/ovn_default_northd_host
@@ -0,0 +1 @@
+northd_host=127.0.0.1
diff --git a/utilities/docker/ovn_default_sb_port b/utilities/docker/ovn_default_sb_port
new file mode 100644
index 000000000..4c9e3f585
--- /dev/null
+++ b/utilities/docker/ovn_default_sb_port
@@ -0,0 +1 @@
+sb_db_port=6642
diff --git a/utilities/docker/start-ovn b/utilities/docker/start-ovn
new file mode 100755
index 000000000..7f87e65a3
--- /dev/null
+++ b/utilities/docker/start-ovn
@@ -0,0 +1,40 @@
+#!/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<https://nam01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.apache.org%2Flicenses%2FLICENSE-2.0&data=02%7C01%7Caginwala%40ebay.com%7C5c887b75459948d3c90208d7266b5201%7C46326bff992841a0baca17c16c94ea99%7C0%7C0%7C637020114699149779&sdata=BtONq6vWL9r7Gq2dWLBB3vuVT4P2Cg8qmwSYRiuYLs4%3D&reserved=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
+        "ovn-nb-tcp") source /etc/openvswitch/ovn_default_nb_port
+                      /usr/share/openvswitch/scripts/ovn-ctl start_ovsdb
+                      ovn-nbctl set-connection ptcp:$nb_db_port
+                      /usr/share/openvswitch/scripts/ovn-ctl stop_ovsdb
+                      /usr/share/openvswitch/scripts/ovn-ctl run_nb_ovsdb
+        ;;
+        "ovn-sb-tcp") source /etc/openvswitch/ovn_default_sb_port
+                      /usr/share/openvswitch/scripts/ovn-ctl start_ovsdb
+                      ovn-sbctl set-connection ptcp:$sb_db_port
+                      /usr/share/openvswitch/scripts/ovn-ctl stop_ovsdb
+                      /usr/share/openvswitch/scripts/ovn-ctl run_sb_ovsdb
+        ;;
+        "ovn-northd-tcp") source /etc/openvswitch/ovn_default_northd_host
+                          source /etc/openvswitch/ovn_default_nb_port
+                          source /etc/openvswitch/ovn_default_sb_port
+                          ovn-northd --pidfile \
+                          --ovnnb-db="tcp:$northd_host:$nb_db_port" \
+                          --ovnsb-db="tcp:$northd_host:$sb_db_port" \
+                          --log-file=/var/log/openvswitch/ovn-northd.log
+        ;;
+        "ovn-controller") ovn-controller --pidfile \
+                          --log-file=/var/log/openvswitch/ovn-controller.log
+        ;;
+        *) echo "$0 [ovn-nb-tcp|ovn-sb-tcp|ovn-northd-tcp|ovn-controller]"
+esac
--
2.20.1 (Apple Git-117)
diff mbox series

Patch

diff --git a/Documentation/intro/install/general.rst b/Documentation/intro/install/general.rst
index 99d8fec04..1d5323f76 100644
--- a/Documentation/intro/install/general.rst
+++ b/Documentation/intro/install/general.rst
@@ -380,6 +380,60 @@  domain socket::
 
     $ ovn-northd --pidfile --detach --log-file
 
+
+Starting OVN Central services in containers
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+For OVN central node, we dont need to load ovs kernel modules on host.
+Hence, OVN central containers OS need not depend on host OS.
+
+Also we can leverage deploying entire OVN control plane in a pod spec for use
+cases like OVN-kubernetes
+
+Export following variables in .env  and place it under
+project root::
+
+    $ OVN_BRANCH=<BRANCH>
+    $ OVN_VERSION=<VERSION>
+    $ DISTRO=<LINUX_DISTRO>
+    $ KERNEL_VERSION=<LINUX_KERNEL_VERSION>
+    $ GITHUB_SRC=<GITHUB_URL>
+    $ DOCKER_REPO=<REPO_TO_PUSH_IMAGE>
+
+To build ovn modules::
+
+    $ cd utilities/docker
+    $ make build
+
+Compiled Modules will be tagged with docker image
+
+To Push ovn modules::
+
+    $ make push
+
+OVN docker image will be pushed to specified docker repo.
+
+Start OVN containers using below command::
+
+    $ docker run -itd --net=host --name=ovn-nb \
+      <docker_repo>:<tag> ovn-nb-tcp
+
+    $ docker run -itd --net=host --name=ovn-sb \
+      <docker_repo>:<tag> ovn-sb-tcp
+
+    $ docker run -itd --net=host --name=ovn-northd \
+      <docker_repo>:<tag> ovn-northd-tcp
+
+.. note::
+    Current ovn central components comes up in docker image in a standalone
+    mode with protocol tcp.
+
+    The debian docker file use ubuntu 16.04 as a base image for reference.
+
+    User can use any other base image for debian, e.g. u14.04, etc.
+
+    RHEL based docker build support needs to be added.
+
 Starting OVN host service
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
@@ -406,6 +460,32 @@  domain socket::
 
     $ ovn-controller --pidfile --detach --log-file
 
+Starting OVN host service in containers
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+For OVN host too, we dont need to load ovs kernel modules on host.
+Hence, OVN host container OS need not depend on host OS.
+
+Also we can leverage deploying OVN host in a pod spec for use cases like
+OVN-kubernetes to manage OVS which can be running as a service on host or in
+container.
+
+Start ovsdb-server and ovs-vswitchd components as per
+http://docs.openvswitch.org/en/latest/intro/install/general/
+
+start local ovn-controller with below command if ovs is also running in
+container::
+
+    $ docker run -itd --net=host --name=ovn-controller \
+      --volumes-from=ovsdb-server \
+      <docker_repo>:<tag> ovn-controller
+
+start local ovn-controller with below command if ovs is running as a service::
+
+    $ docker run -itd --net=host --name=ovn-controller \
+      -v /var/run/openvswitch/:/var/run/openvswitch/ \
+      <docker_repo>:<tag> ovn-controller
+
 Validating
 ----------
 
@@ -419,6 +499,9 @@  logical switch ``sw0`` and add logical port ``sw0-p1`` ::
 
 Refer to ovn-nbctl(8) and ovn-sbctl (8) for more details.
 
+When using ovn in container, exec to container to run above commands::
+
+    $ docker exec -it <ovn-nb/ovn-sb/ovn-northd/ovn-controller> /bin/bash
 
 Reporting Bugs
 --------------
diff --git a/utilities/automake.mk b/utilities/automake.mk
index b2b026f57..3142d177f 100644
--- a/utilities/automake.mk
+++ b/utilities/automake.mk
@@ -29,6 +29,14 @@  EXTRA_DIST += \
     utilities/ovn-detrace.in \
     utilities/ovndb-servers.ocf \
     utilities/checkpatch.py
+    utilities/docker/Makefile \
+    utilities/docker/start-ovn \
+    utilities/docker/create_ovn_dbs.sh \
+    utilities/docker/ovn_default_nb_port \
+    utilities/docker/ovn_default_sb_port \
+    utilities/docker/ovn_default_northd_host \
+    utilities/docker/debian/Dockerfile \
+    utilities/docker/debian/build.sh
 
 CLEANFILES += \
     utilities/ovn-ctl.8 \
diff --git a/utilities/docker/Makefile b/utilities/docker/Makefile
new file mode 100644
index 000000000..e2b2c2a17
--- /dev/null
+++ b/utilities/docker/Makefile
@@ -0,0 +1,22 @@ 
+#export OVN_BRANCH=master
+#export OVN_VERSION=2.12
+#export KERNEL_VERSION=4.15.0-54-generic
+#export DISTRO=debian
+#export GITHUB_SRC=https://github.com/ovn-org/ovn.git
+#export DOCKER_REPO=ovn-org/ovn
+
+# Example:
+#   make build
+#   make push
+
+REPO = ${DOCKER_REPO}
+tag = ${OVN_VERSION}_${KERNEL_VERSION}
+
+build: ;docker build -t ${REPO}:${tag} --build-arg DISTRO=${DISTRO} \
+--build-arg OVN_BRANCH=${OVN_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_ovn_dbs.sh b/utilities/docker/create_ovn_dbs.sh
new file mode 100755
index 000000000..43ab367d6
--- /dev/null
+++ b/utilities/docker/create_ovn_dbs.sh
@@ -0,0 +1,18 @@ 
+#!/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/ovnnb_db.db \
+/usr/share/openvswitch/ovn-nb.ovsschema
+ovsdb-tool create /etc/openvswitch/ovnsb_db.db \
+/usr/share/openvswitch/ovn-sb.ovsschema
diff --git a/utilities/docker/debian/Dockerfile b/utilities/docker/debian/Dockerfile
new file mode 100644
index 000000000..fe72c3a33
--- /dev/null
+++ b/utilities/docker/debian/Dockerfile
@@ -0,0 +1,22 @@ 
+FROM ubuntu:16.04
+MAINTAINER "Aliasgar Ginwala" <aginwala@ebay.com>
+
+ARG OVN_BRANCH
+ARG KERNEL_VERSION
+ARG GITHUB_SRC
+ARG DISTRO
+
+copy $DISTRO/build.sh /build.sh
+RUN /build.sh $KERNEL_VERSION $OVN_BRANCH $GITHUB_SRC
+
+COPY create_ovn_dbs.sh /etc/openvswitch/create_ovn_dbs.sh
+RUN /etc/openvswitch/create_ovn_dbs.sh
+
+COPY ovn_default_nb_port /etc/openvswitch/ovn_default_nb_port
+COPY ovn_default_sb_port /etc/openvswitch/ovn_default_sb_port
+COPY ovn_default_northd_host /etc/openvswitch/ovn_default_northd_host
+
+COPY start-ovn /bin/start-ovn
+VOLUME ["/var/log/openvswitch", \
+"/var/lib/openvswitch", "/var/run/openvswitch", "/etc/openvswitch"]
+ENTRYPOINT ["start-ovn"]
diff --git a/utilities/docker/debian/build.sh b/utilities/docker/debian/build.sh
new file mode 100755
index 000000000..fd26a8aa8
--- /dev/null
+++ b/utilities/docker/debian/build.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
+OVN_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 $OVN_BRANCH $GITHUB_SRC
+cd ovn
+
+# 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
+
+# remove deps to make the container light weight.
+apt-get remove --purge -y ${build_deps}
+apt-get autoremove -y --purge
+cd ..; rm -rf ovn
+basic_utils="vim kmod net-tools uuid-runtime iproute2"
+apt-get install -y ${basic_utils}
diff --git a/utilities/docker/ovn_default_nb_port b/utilities/docker/ovn_default_nb_port
new file mode 100644
index 000000000..d83211678
--- /dev/null
+++ b/utilities/docker/ovn_default_nb_port
@@ -0,0 +1 @@ 
+nb_db_port=6641
diff --git a/utilities/docker/ovn_default_northd_host b/utilities/docker/ovn_default_northd_host
new file mode 100644
index 000000000..55d4ab7aa
--- /dev/null
+++ b/utilities/docker/ovn_default_northd_host
@@ -0,0 +1 @@ 
+northd_host=127.0.0.1
diff --git a/utilities/docker/ovn_default_sb_port b/utilities/docker/ovn_default_sb_port
new file mode 100644
index 000000000..4c9e3f585
--- /dev/null
+++ b/utilities/docker/ovn_default_sb_port
@@ -0,0 +1 @@ 
+sb_db_port=6642
diff --git a/utilities/docker/start-ovn b/utilities/docker/start-ovn
new file mode 100755
index 000000000..7f87e65a3
--- /dev/null
+++ b/utilities/docker/start-ovn
@@ -0,0 +1,40 @@ 
+#!/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
+        "ovn-nb-tcp") source /etc/openvswitch/ovn_default_nb_port
+                      /usr/share/openvswitch/scripts/ovn-ctl start_ovsdb
+                      ovn-nbctl set-connection ptcp:$nb_db_port
+                      /usr/share/openvswitch/scripts/ovn-ctl stop_ovsdb
+                      /usr/share/openvswitch/scripts/ovn-ctl run_nb_ovsdb
+        ;;
+        "ovn-sb-tcp") source /etc/openvswitch/ovn_default_sb_port
+                      /usr/share/openvswitch/scripts/ovn-ctl start_ovsdb
+                      ovn-sbctl set-connection ptcp:$sb_db_port
+                      /usr/share/openvswitch/scripts/ovn-ctl stop_ovsdb
+                      /usr/share/openvswitch/scripts/ovn-ctl run_sb_ovsdb
+        ;;
+        "ovn-northd-tcp") source /etc/openvswitch/ovn_default_northd_host
+                          source /etc/openvswitch/ovn_default_nb_port
+                          source /etc/openvswitch/ovn_default_sb_port
+                          ovn-northd --pidfile \
+                          --ovnnb-db="tcp:$northd_host:$nb_db_port" \
+                          --ovnsb-db="tcp:$northd_host:$sb_db_port" \
+                          --log-file=/var/log/openvswitch/ovn-northd.log
+        ;;
+        "ovn-controller") ovn-controller --pidfile \
+                          --log-file=/var/log/openvswitch/ovn-controller.log
+        ;;
+        *) echo "$0 [ovn-nb-tcp|ovn-sb-tcp|ovn-northd-tcp|ovn-controller]"
+esac