[ovs-dev] [PATCH] docker: add testing on local docker localhost:5000

Ginwala, Aliasgar aginwala at ebay.com
Thu Apr 8 20:15:42 UTC 2021


Sure Ben.

Thanks Hunchback for the patches. Added few comments/queries to that.

From: Ben Pfaff <blp at ovn.org>
Date: Thursday, April 8, 2021 at 9:06 AM
To: hunchback <aidan.shribman at gmail.com>, Ginwala, Aliasgar <aginwala at ebay.com>, Han Zhou <hzhou at ovn.org>, Numan Siddique <nusiddiq at redhat.com>
Cc: ovs <dev at openvswitch.org>
Subject: Re: [ovs-dev] [PATCH] docker: add testing on local docker localhost:5000
External Email

Hi Ali and Han, you guys wrote the docker stuff in OVS, and Numan, you
reviewed it.  Do you think you could comment on these proposed changes
from Aidan/hunchback?  I am not competent in Docker myself.

On Fri, Apr 02, 2021 at 07:27:00PM +0000, hunchback wrote:
> add a set of docker targets which ease the building and testing of
> docker images both on local registry (localhost:5000) as well as on the
> public default registry (docker.io).
>
> Signed-off-by: hunchback <aidan.shribman at gmail.com>
> ---
>  .gitignore                              |  1 +
>  Documentation/intro/install/general.rst | 38 +++++++++---------
>  Makefile.am                             |  1 +
>  utilities/automake.mk                   |  2 +-
>  utilities/docker/.gitignore             |  2 +
>  utilities/docker/Makefile               | 22 ----------
>  utilities/docker/automake.mk            | 53 +++++++++++++++++++++++++
>  utilities/docker/debian/Dockerfile      |  5 ++-
>  8 files changed, 79 insertions(+), 45 deletions(-)
>  create mode 100644 utilities/docker/.gitignore
>  delete mode 100644 utilities/docker/Makefile
>  create mode 100644 utilities/docker/automake.mk
>
> diff --git a/.gitignore b/.gitignore
> index f1cdcf124..b46a0528a 100644
> --- a/.gitignore
> +++ b/.gitignore
> @@ -79,3 +79,4 @@ testsuite.tmp.orig
>  /Documentation/_build
>  /.venv
>  /cxx-check
> +*.mod
> diff --git a/Documentation/intro/install/general.rst b/Documentation/intro/install/general.rst
> index c4300cd53..8a3609627 100644
> --- a/Documentation/intro/install/general.rst
> +++ b/Documentation/intro/install/general.rst
> @@ -510,40 +510,38 @@ For ovs vswitchd, we need to load ovs kernel modules on host.
>
>  Hence, OVS containers kernel version needs to be same as that of host kernel.
>
> -Export following variables in .env  and place it under
> -project root::
> +If you want to change the default values for building an image then set these
> +variables::
>
> -    $ OVS_BRANCH=<BRANCH>
> -    $ OVS_VERSION=<VERSION>
> -    $ DISTRO=<LINUX_DISTRO>
> -    $ KERNEL_VERSION=<LINUX_KERNEL_VERSION>
> -    $ GITHUB_SRC=<GITHUB_URL>
> -    $ DOCKER_REPO=<REPO_TO_PUSH_IMAGE>
> +    $ export OVS_BRANCH=<BRANCH>
> +    $ export OVS_VERSION=<VERSION>
> +    $ export DISTRO=<LINUX_DISTRO>
> +    $ export KERNEL_VERSION=<LINUX_KERNEL_VERSION>
> +    $ export GITHUB_SRC=<GITHUB_URL>
> +    $ export DOCKER_REPO=<REPO_TO_PUSH_IMAGE>
> +    $ export DOCKER_TAG=<DOCKER_IMAGE_TAG>
>
> -To build ovs modules::
> +To setup for using a local registry (localhost:5000)::
>
> -    $ cd utilities/docker
> -    $ make build
> +    $ make docker-registry
> +    $ export DOCKER_REPO=localhost:5000/ovsvswitch/ovs
>
> -Compiled Modules will be tagged with docker image
> +To build ovs modules (tagged with docker image)::
>
> -To Push ovs modules::
> +    $ make docker-build
Docker is default container engine that is already being used so why need to rename.
Not sure if you are planning to add another container run time support ?

>
> -    $ make push
> +To push ovs modules to docker repo::
>
> -OVS docker image will be pushed to specified docker repo.
> +     $ make docker-push
>
>  Start ovsdb-server using below command::
>
> -    $ docker run -itd --net=host --name=ovsdb-server \
> -      <docker_repo>:<tag> ovsdb-server
> +     $ make docker-ovsdb-server
>
>  Start ovs-vswitchd with priviledged mode as it needs to load kernel module in
>  host using below command::
>
> -    $ docker run -itd --net=host --name=ovs-vswitchd \
> -      --volumes-from=ovsdb-server -v /lib:/lib --privileged \
> -      <docker_repo>:<tag> ovs-vswitchd
> +    $ make docker-ovs-vswitchd
The intent of make is to compile/build the binary/image.  I don’t get the intent of running the binary using docker itself in a make file.
May be you can add new instructions say make run xxx if you still want to bundle docker run in make?
>
>  .. note::
>      The debian docker file uses ubuntu 16.04 as a base image for reference.
> diff --git a/Makefile.am b/Makefile.am
> index 691a005ad..e75df1be6 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -499,3 +499,4 @@ include datapath-windows/include/automake.mk
>  include windows/automake.mk
>  include selinux/automake.mk
>  include build-aux/automake.mk
> +include utilities/docker/automake.mk
> diff --git a/utilities/automake.mk b/utilities/automake.mk
> index e2e22c39a..4d2f20570 100644
> --- a/utilities/automake.mk
> +++ b/utilities/automake.mk
> @@ -56,7 +56,7 @@ EXTRA_DIST += \
>        utilities/ovs-vlan-test.in \
>        utilities/ovs-vsctl-bashcomp.bash \
>        utilities/checkpatch.py \
> -        utilities/docker/Makefile \
> +        utilities/docker/automake.mk \
>          utilities/docker/ovs-override.conf \
>          utilities/docker/start-ovs \
>          utilities/docker/create_ovs_db.sh \
> diff --git a/utilities/docker/.gitignore b/utilities/docker/.gitignore
> new file mode 100644
> index 000000000..5d05c158b
> --- /dev/null
> +++ b/utilities/docker/.gitignore
> @@ -0,0 +1,2 @@
> +vswitch.ovsschema
> +ovsdb-tool
> diff --git a/utilities/docker/Makefile b/utilities/docker/Makefile
> deleted file mode 100644
> index d8b08a3c9..000000000
> --- a/utilities/docker/Makefile
> +++ /dev/null
> @@ -1,22 +0,0 @@
> -#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://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fopenvswitch%2Fovs.git&data=04%7C01%7Caginwala%40ebay.com%7Cf32ecf458d9c4ba3f64b08d8faa84500%7C46326bff992841a0baca17c16c94ea99%7C0%7C0%7C637534947913020219%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=L3heGJgILIDo8EXX2LGtgvFdfug%2BfL3iO1gESmR8CO0%3D&reserved=0
> -#export DOCKER_REPO=openvswitch/ovs
> -
> -# Example:
> -#   make build
> -#   make push
> -
> -REPO = ${DOCKER_REPO}
> -tag = ${OVS_VERSION}_${DISTRO}_${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/automake.mk b/utilities/docker/automake.mk
> new file mode 100644
> index 000000000..1ca3702be
> --- /dev/null
> +++ b/utilities/docker/automake.mk
> @@ -0,0 +1,53 @@
> +DIR := utilities/docker
> +
> +OVS_BRANCH ?= branch-2.11
> +OVS_VERSION ?= 2.11
> +KERNEL_VERSION ?= 4.15.0-54-generic
> +DISTRO ?= debian
> +GITHUB_SRC ?= https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fopenvswitch%2Fovs.git&data=04%7C01%7Caginwala%40ebay.com%7Cf32ecf458d9c4ba3f64b08d8faa84500%7C46326bff992841a0baca17c16c94ea99%7C0%7C0%7C637534947913020219%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=L3heGJgILIDo8EXX2LGtgvFdfug%2BfL3iO1gESmR8CO0%3D&reserved=0
> +DOCKER_REPO ?= openvswitch/ovs
> +DOCKER_TAG ?= ${OVS_VERSION}_${DISTRO}_${KERNEL_VERSION}
> +DOCKER_SERVER ?= localhost:5000
> +
> +.PHONY: docker-registry
> +docker-registry:
> +     docker rm --force registry 2>/dev/null || true
> +     docker run -d -p 5000:5000 --restart=always --name registry registry:2
By default docker build saves image on your local so why need localhost specific details?

> +     @echo
> +     @echo "# For using local repo set:"
> +     @echo "export DOCKER_REPO=localhost:5000/openvswitch/ovs"
> +     @echo
> +     @echo "# For returning to public repo set:"
> +     @echo "export DOCKER_REPO=openvswitch/ovs"
> +
> +$(DIR)/vswitch.ovsschema: vswitchd/vswitch.ovsschema
> +     cp $< $@
> +
> +$(DIR)/ovsdb-tool: ovsdb/ovsdb-tool
> +     cp $< $@
> +
> +.PHONY: docker-build
> +docker-build: $(DIR)/vswitch.ovsschema $(DIR)/ovsdb-tool
> +     cd $(DIR) && docker build -t ${DOCKER_REPO}:${DOCKER_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: docker-push
> +docker-push:
> +     cd $(DIR) && docker push ${DOCKER_REPO}:${DOCKER_TAG}
> +
> +.PHONY: docker-ovsdb-server
> +docker-ovsdb-server:
> +     docker rm --force ovsdb-server 2>/dev/null || true
> +     docker run -itd --net=host --name=ovsdb-server \
> +             ${DOCKER_REPO}:${DOCKER_TAG} ovsdb-server
> +
> +.PHONY: docker-ovs-vswitchd
> +docker-ovs-vswitchd:
> +     docker rm --force ovs-vswitchd 2>/dev/null || true
> +     docker run -itd --net=host --name=ovs-vswitchd \
> +             --volumes-from=ovsdb-server -v /lib:/lib --privileged \
> +             ${DOCKER_REPO}:${DOCKER_TAG} ovs-vswitchd
> diff --git a/utilities/docker/debian/Dockerfile b/utilities/docker/debian/Dockerfile
> index ed4baa8f9..be8e79277 100644
> --- a/utilities/docker/debian/Dockerfile
> +++ b/utilities/docker/debian/Dockerfile
> @@ -6,14 +6,15 @@ ARG KERNEL_VERSION
>  ARG GITHUB_SRC
>  ARG DISTRO
>
> -copy $DISTRO/build-kernel-modules.sh /build-kernel-modules.sh
> +COPY $DISTRO/build-kernel-modules.sh /build-kernel-modules.sh
>  RUN /build-kernel-modules.sh $KERNEL_VERSION $OVS_BRANCH $GITHUB_SRC
>
> +COPY vswitch.ovsschema /usr/share/openvswitch/vswitch.ovsschema
> +COPY ovsdb-tool /bin/ovsdb-tool
>  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"]
> --
> 2.25.1
>
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmail.openvswitch.org%2Fmailman%2Flistinfo%2Fovs-dev&data=04%7C01%7Caginwala%40ebay.com%7Cf32ecf458d9c4ba3f64b08d8faa84500%7C46326bff992841a0baca17c16c94ea99%7C0%7C0%7C637534947913020219%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=pDOEqNXKfVwE6bgJrGKRspsdTeQbAEwib29FyPL5Jmc%3D&reserved=0


More information about the dev mailing list