From patchwork Thu Apr 8 22:34:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aidan Shribman X-Patchwork-Id: 1464073 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.137; helo=smtp4.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=sVDZhaV+; dkim-atps=neutral Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FGbgp61snz9sTD for ; Fri, 9 Apr 2021 08:35:34 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 0C018419E8; Thu, 8 Apr 2021 22:35:32 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Nkq9xJ-R9cGC; Thu, 8 Apr 2021 22:35:30 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp4.osuosl.org (Postfix) with ESMTP id 96D2C419DC; Thu, 8 Apr 2021 22:35:29 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 6613DC000C; Thu, 8 Apr 2021 22:35:29 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 01C3BC000A for ; Thu, 8 Apr 2021 22:35:28 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id CFFB1607CD for ; Thu, 8 Apr 2021 22:35:28 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp3.osuosl.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id f4Npi8UfQ0SA for ; Thu, 8 Apr 2021 22:35:27 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by smtp3.osuosl.org (Postfix) with ESMTPS id 7CDE160733 for ; Thu, 8 Apr 2021 22:35:27 +0000 (UTC) Received: by mail-wr1-x42f.google.com with SMTP id i18so3715476wrm.5 for ; Thu, 08 Apr 2021 15:35:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ARZ2vvm1ASVr22N3r4ZzJVGWempJ/lJtEoq2Xk1Fyaw=; b=sVDZhaV+ztxZ50ah//vRXLbC7QLJ+32N1LN7nrcRGocBK09xZjpzP+VSEb7sKjJGSk GlNavY6nVQBUI/Pf4Gf9OCTLw1uLN9Z1zMlH/o97HKdh2kyhvOEHgWsJsce4zJL4yppl w1TsOsg2C2hZ1nhEBCqRQGtzAobx+fu9JN6OgTJx1z+0QUGVuNrLwOthVu56IAXZl2yJ 1NKDf5icaIV1pc6c54mKt1BzTu2Dauv7AM6t4pPbLlt7jcXaYE1PcSO0lz+pxTSJl00G QdyQbb/dswcbAkAC22aMzoLrA3SHQ2UpJJpxnYp+hchJQn9G57hJ2hlApxHQzW7+wIgb qJ5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ARZ2vvm1ASVr22N3r4ZzJVGWempJ/lJtEoq2Xk1Fyaw=; b=pu6Sqj+ElQ+A66xuqV3/j482Hodph2pzWd3lBstF2nDFNCm7OkDZdubgZ3svZEjIkH WxbWIgI8Efia7rmhHo2ALLZHr7CX/sJO6mm0UhV6nB6PeSC1QEw5SvXcX09/cthyO/ky 9F9c4vIntwj5OsoXp/imKpL72gMuIwlicVzXXaoq4c8/8e8gNxH8+AUxsXRChMTfrZse 73ZCGGaX8tV1qYb0IDHvJoQTeLsSXN8gMl1NRNtA913NfGGCce2OTyEicvOseMf/CHD1 H9h8OjUUoWKqzQzRFjhYhDyLwM1mfZOaQR7OdgNOi2T+8PXJmYwO8QtG1OTVNwcIReb1 y+FQ== X-Gm-Message-State: AOAM530ytjhYFDi+fd616vKLTbnTJCIrXRPtsMSOola92yaqQvQda8b3 P1Vt7ju0MgGs6j4150TF/DEsUZqV7oZYUg== X-Google-Smtp-Source: ABdhPJwkaUhHfQF0K9pAjJHparjLQKmzdZemaOumXe1J5TTiRYJ/24UBrPqWdmIRta78sLP/DGSCnw== X-Received: by 2002:adf:f682:: with SMTP id v2mr14668182wrp.263.1617921325245; Thu, 08 Apr 2021 15:35:25 -0700 (PDT) Received: from localhost.localdomain (bl9-205-140.dsl.telepac.pt. [85.242.205.140]) by smtp.gmail.com with ESMTPSA id a4sm1046279wrx.86.2021.04.08.15.35.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Apr 2021 15:35:24 -0700 (PDT) From: Aidan Shribman To: ovs Date: Thu, 8 Apr 2021 22:34:38 +0000 Message-Id: <20210408223437.1368544-1-aidan.shribman@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Cc: Aidan Shribman Subject: [ovs-dev] [PATCH v2] docker: add testing on local docker localhost:5000 X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" 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: Aidan Shribman --- .gitignore | 1 + Documentation/intro/install/general.rst | 31 +++++++++---------- Makefile.am | 1 + utilities/automake.mk | 2 +- utilities/docker/.gitignore | 2 ++ utilities/docker/Makefile | 22 -------------- utilities/docker/automake.mk | 40 +++++++++++++++++++++++++ utilities/docker/debian/Dockerfile | 5 ++-- 8 files changed, 64 insertions(+), 40 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..804b7af52 100644 --- a/Documentation/intro/install/general.rst +++ b/Documentation/intro/install/general.rst @@ -510,28 +510,29 @@ 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= - $ OVS_VERSION= - $ DISTRO= - $ KERNEL_VERSION= - $ GITHUB_SRC= - $ DOCKER_REPO= + $ export OVS_BRANCH= + $ export OVS_VERSION= + $ export DISTRO= + $ export KERNEL_VERSION= + $ export GITHUB_SRC= + $ export DOCKER_REPO= + $ export DOCKER_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 - $ 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:: diff --git a/Makefile.am b/Makefile.am index cb8076433..5dcec201d 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://github.com/openvswitch/ovs.git -#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..4d9385ac8 --- /dev/null +++ b/utilities/docker/automake.mk @@ -0,0 +1,40 @@ +DIR := utilities/docker + +OVS_BRANCH ?= branch-2.11 +OVS_VERSION ?= 2.11 +KERNEL_VERSION ?= 4.15.0-54-generic +DISTRO ?= debian +GITHUB_SRC ?= https://github.com/openvswitch/ovs.git +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 + @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} 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"]