From 6b937d0dc0f36596c9bc1ef8766ba7363451458d Mon Sep 17 00:00:00 2001 From: Alexandru Avadanii Date: Tue, 25 Jun 2019 17:46:42 +0200 Subject: [PATCH] [docker] Add sonobuoy multiarch image build Upstream sonobuoy lacks 2 images for AArch64 architecture, so build our own multiarch amd64 (x86_64) + arm64 (AArch64) images for: - sonobuoy-plugin-systemd-logs (tag version 'latest'); - kube-conformance (tag version 'v1.11'); The new images will be pushed to Dockerhub as: - akraino/validation:sonobuoy-plugin-systemd-logs-latest - akraino/validation:kube-conformance-v1.11 Since upstream Dockerfiles require small changes for AArch64 support, implement a new patching mechanism via new make targets in `docker/build.mk`: - .submodules_init * initializes the (newly added) git submodules in this repository and pulls the pinned-down commit for each submodule; - .submodules_patched * Applies patches found in the `patches` and/or `patches/` subdirectories for each submodule (using `git am -3`), so we can apply AArch64-specific changes only on arm64 platforms; - .submodules_clean * Un-applies patches by resetting each git submodule to its pinned-down commit; To add support for pre-build actions like submodules init + patching, turn `.build` make target into a double-colon target and extend it for the two new containers accordingly. To prevent tox verify failures, adjust ui .eslintrc and tox.ini to remove the git submodules first (second one being a temporary workaround until ci-management allows configuring verify jobs with git submodule handling disabled). JIRA: VAL-24 Change-Id: Ibfeb3551e44e82fdade2886985ca4577b7d32522 Signed-off-by: Alexandru Avadanii --- .gitignore | 2 + .gitmodules | 8 ++ docker/README.rst | 98 ++++++++++++++++++++-- docker/build.mk | 45 +++++++++- docker/kube-conformance/Makefile | 30 +++++++ docker/kube-conformance/kube-conformance | 1 + ...1-Dockerfile-Makefile-Add-AArch64-support.patch | 55 ++++++++++++ docker/sonobuoy-plugin-systemd-logs/Makefile | 28 +++++++ .../aarch64/0001-Dockerfile-AArch64-support.patch | 28 +++++++ .../sonobuoy-plugin-systemd-logs | 1 + tox.ini | 4 +- ui/src/main/webapp/.eslintrc | 4 +- 12 files changed, 293 insertions(+), 11 deletions(-) create mode 100644 .gitmodules create mode 100644 docker/kube-conformance/Makefile create mode 160000 docker/kube-conformance/kube-conformance create mode 100644 docker/kube-conformance/patches/aarch64/0001-Dockerfile-Makefile-Add-AArch64-support.patch create mode 100644 docker/sonobuoy-plugin-systemd-logs/Makefile create mode 100644 docker/sonobuoy-plugin-systemd-logs/patches/aarch64/0001-Dockerfile-AArch64-support.patch create mode 160000 docker/sonobuoy-plugin-systemd-logs/sonobuoy-plugin-systemd-logs diff --git a/.gitignore b/.gitignore index e83e681..2d802ce 100644 --- a/.gitignore +++ b/.gitignore @@ -49,3 +49,5 @@ pmd-bin-6.15.0* !/.coafile !/ui/src/main/webapp/.eslintrc +# git submodule patching mechanism local artifacts +.submodules_* diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..a51136e --- /dev/null +++ b/.gitmodules @@ -0,0 +1,8 @@ +[submodule "sonobuoy-plugin-systemd-logs"] + path = docker/sonobuoy-plugin-systemd-logs/sonobuoy-plugin-systemd-logs + url = https://github.com/heptio/sonobuoy-plugin-systemd-logs + branch = master +[submodule "kube-conformance"] + path = docker/kube-conformance/kube-conformance + url = https://github.com/heptio/kube-conformance + branch = master diff --git a/docker/README.rst b/docker/README.rst index 3a979af..34e7641 100644 --- a/docker/README.rst +++ b/docker/README.rst @@ -78,7 +78,7 @@ enter the container, add */bin/sh* at the end of the command above The postgresql container -================= +======================== Building and pushing the container ---------------------------------- @@ -87,26 +87,28 @@ To build just the postgresql container, use the command: .. code-block:: console - make postgresql-build [ REGISTRY= NAME=] + make postgresql-build [ REGISTRY= NAME=] To both build and push the container, use the command: .. code-block:: console - make postgresql [ REGISTRY= NAME=] + make postgresql [ REGISTRY= NAME=] Using the container ------------------- + If you want to deploy the container, you can run the corresponding deploy.sh script with the appropriate parameters. Example: .. code-block:: console + ./deploy.sh POSTGRES_PASSWORD=password The ui container -================= +================ Building and pushing the container ---------------------------------- @@ -116,20 +118,104 @@ Then use the command: .. code-block:: console - make ui-build [ REGISTRY= NAME=] + make ui-build [ REGISTRY= NAME=] To both build and push the container, use the command: .. code-block:: console - make ui [ REGISTRY= NAME=] + make ui [ REGISTRY= NAME=] Using the container ------------------- + If you want to deploy the container, you can run the corresponding deploy.sh script with the appropriate parameters. Note, that you must also build and run the postgresql container for a functional UI. Example: .. code-block:: console + ./deploy.sh postgres_db_user_pwd=password jenkins_url=http://192.168.2.2:8080 jenkins_user_name=name jenkins_user_pwd=jenkins_pwd jenkins_job_name=job1 nexus_results_url=https://nexus.akraino.org/content/sites/logs proxy_ip=172.28.40.9 proxy_port=3128 + +The kube-conformance container +============================== + +Building and pushing the container +---------------------------------- + +To build just the kube-conformance container, use the command: + +.. code-block:: console + + make kube-conformance-build [ REGISTRY= NAME=] + +To both build and push the container, use the command: + +.. code-block:: console + + make kube-conformance [ REGISTRY= NAME=] + +Using the container +------------------- + +This is a standalone container able to launch Kubernetes end-to-end tests, +for the purposes of conformance testing. + +It is a thin wrapper around the `e2e.test` binary in the upstream Kubernetes +distribution, which drops results in a predetermined location for use as a +[Heptio Sonobuoy](https://github.com/heptio/sonobuoy) plugin. + +To learn more about conformance testing and its Sonobuoy integration, read the +[conformance guide](https://github.com/heptio/sonobuoy/blob/master/docs/conformance-testing.md). + +Example: + +.. code-block:: console + + docker run -ti akraino/validation:kube-conformance-v1.11 + +By default, the container will run the `run_e2e.sh` script. If you want to +enter the container, add */bin/sh* at the end of the command above + +Normally, this conainer is not used directly, but instead leveraged via +sonobuoy. + +The sonobuoy-plugin-systemd-logs container +========================================== + +Building and pushing the container +---------------------------------- + +To build just the sonobuoy-plugin-systemd-logs container, use the command: + +.. code-block:: console + + make sonobuoy-plugin-systemd-logs-build [ REGISTRY= NAME=] + +To both build and push the container, use the command: + +.. code-block:: console + + make sonobuoy-plugin-systemd-logs [ REGISTRY= NAME=] + +Using the container +------------------- + +This is a simple standalone container that gathers log information from +systemd, by chrooting into the node's filesystem and running `journalctl`. + +This container is used by [Heptio Sonobuoy](https://github.com/heptio/sonobuoy) +for gathering host logs in a Kubernetes cluster. + +Example: + +.. code-block:: console + + docker run -ti akraino/validation:sonobuoy-plugin-systemd-logs-latest + +By default, the container will run the `get_systemd_logs.sh` script. If you +want to enter the container, add */bin/sh* at the end of the command above. + +Normally, this conainer is not used directly, but instead leveraged via +sonobuoy. diff --git a/docker/build.mk b/docker/build.mk index 988f2a9..2f7d398 100644 --- a/docker/build.mk +++ b/docker/build.mk @@ -14,15 +14,27 @@ # limitations under the License. # ############################################################################## - # declare the variables REGISTRY ?= akraino NAME ?= validation TAG_PRE ?= $(notdir $(CURDIR)) TAG_VER ?= latest DOCKERFILE ?= Dockerfile +WORK_DIR ?= $(CURDIR) MTOOL ?= $(dir $(realpath $(lastword $(MAKEFILE_LIST))))/manifest-tool +# git submodule & patch locations for upstream patching before build +GIT_ROOT := $(shell git rev-parse --show-toplevel) +GIT_DIR := $(shell git rev-parse --git-dir) +PATCH_DIR := $(shell pwd)/patches +AKRAINO_TAG := akraino-validation +SHELL = /bin/sh +PATCHES = $(shell find $(PATCH_DIR) $(PATCH_DIR)/$$(uname -m) \ + -maxdepth 1 -name '*.patch' 2> /dev/null) + +export GIT_COMMITTER_NAME?=Akraino Validation +export GIT_COMMITTER_EMAIL?=validation@akraino.org + # get the architecture of the host HOST_ARCH = amd64 ifeq ($(shell uname -m), aarch64) @@ -34,7 +46,8 @@ $(MTOOL): sudo chmod +x $@ .PHONY: .build -.build: +.build:: + cd $(WORK_DIR) && \ docker build \ -t $(REGISTRY)/$(NAME):$(TAG_PRE)-$(HOST_ARCH)-$(TAG_VER) \ -f $(DOCKERFILE) \ @@ -50,3 +63,31 @@ $(MTOOL): --platforms linux/amd64,linux/arm64 \ --template $(REGISTRY)/$(NAME):$(TAG_PRE)-ARCH-$(TAG_VER) \ --target $(REGISTRY)/$(NAME):$(TAG_PRE)-$(TAG_VER) + +.submodules_init: + cd $(GIT_ROOT) && git submodule update --init 2>/dev/null; \ + touch $@ + +.submodules_patched: .submodules_init $(PATCHES) + $(MAKE) .submodules_clean + @cd $(GIT_ROOT) && git submodule -q foreach ' \ + if [ $$name = $$(basename $(TAG_PRE)) ] && [ -n "$(PATCHES)" ]; then \ + git tag $(AKRAINO_TAG)-upstream && \ + git checkout -q -b akraino-validation && \ + echo "`tput setaf 2`-- patching $$name`tput sgr0`";\ + git am -3 --ignore-whitespace --patch-format=mbox \ + --committer-date-is-author-date $(PATCHES) && \ + git tag $(AKRAINO_TAG) || exit 1; \ + fi'; \ + touch $@ + +.PHONY: .submodules_clean +.submodules_clean: + @cd $(GIT_ROOT) && git submodule -q foreach ' \ + git am -q --abort > /dev/null 2>&1; \ + git checkout -q -f $(AKRAINO_TAG)-upstream > /dev/null 2>&1; \ + git branch -q -D akraino-validation > /dev/null 2>&1; \ + git tag | grep $(AKRAINO_TAG) | xargs git tag -d > /dev/null 2>&1; \ + git reset -q --hard HEAD; \ + git clean -xdff' + @rm -f .submodules_patched diff --git a/docker/kube-conformance/Makefile b/docker/kube-conformance/Makefile new file mode 100644 index 0000000..a5b5b99 --- /dev/null +++ b/docker/kube-conformance/Makefile @@ -0,0 +1,30 @@ +############################################################################## +# Copyright (c) 2019 AT&T, ENEA AB, Nokia and others # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you maynot 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. # +############################################################################## + +export WORK_DIR?=$(TAG_PRE) +export TAG_VER?=v1.11 + +.PHONY: .build +.build:: .submodules_patched + $(MAKE) -C $(TAG_PRE) e2e.test kubectl ginkgo + +.PHONY: all +all: .push_image .push_manifest + +.PHONY: build +build: .build + +include ../build.mk diff --git a/docker/kube-conformance/kube-conformance b/docker/kube-conformance/kube-conformance new file mode 160000 index 0000000..32d9e2a --- /dev/null +++ b/docker/kube-conformance/kube-conformance @@ -0,0 +1 @@ +Subproject commit 32d9e2a4edd5c354c97da0d1bd308473bf4f0c89 diff --git a/docker/kube-conformance/patches/aarch64/0001-Dockerfile-Makefile-Add-AArch64-support.patch b/docker/kube-conformance/patches/aarch64/0001-Dockerfile-Makefile-Add-AArch64-support.patch new file mode 100644 index 0000000..770f6bd --- /dev/null +++ b/docker/kube-conformance/patches/aarch64/0001-Dockerfile-Makefile-Add-AArch64-support.patch @@ -0,0 +1,55 @@ +From: Alexandru Avadanii +Date: Tue, 25 Jun 2019 17:59:13 +0200 +Subject: [PATCH] Dockerfile, Makefile: Add AArch64 support + +Signed-off-by: Alexandru Avadanii +--- + Dockerfile | 6 ++++-- + Makefile | 8 +++++--- + 2 files changed, 9 insertions(+), 5 deletions(-) + +diff --git a/Dockerfile b/Dockerfile +index 289ac88..102685d 100644 +--- a/Dockerfile ++++ b/Dockerfile +@@ -13,10 +13,12 @@ + # See the License for the specific language governing permissions and + # limitations under the License. + +-FROM buildpack-deps:jessie-scm ++FROM arm64v8/buildpack-deps:jessie-scm + MAINTAINER Timothy St. Clair "tstclair@heptio.com" + +-RUN apt-get update && apt-get -y --no-install-recommends install \ ++RUN echo 'Acquire::Check-Valid-Until "0";' > /etc/apt/apt.conf.d/10no--check-valid-until \ ++ && sed -i -e '/security/s/^/#/g' -e 's|deb.debian.org/debian|snapshot.debian.org/archive/debian/20190301T035241Z|g' /etc/apt/sources.list \ ++ && apt-get update && apt-get -y --no-install-recommends install \ + ca-certificates \ + && rm -rf /var/cache/apt/* \ + && rm -rf /var/lib/apt/lists/* +diff --git a/Makefile b/Makefile +index 4335cfd..bdaa52c 100644 +--- a/Makefile ++++ b/Makefile +@@ -29,6 +29,8 @@ is_root=$(filter 0,$(shell id -u)) + DOCKER?=$(if $(or $(in_docker_group),$(is_root)),docker,sudo docker) + DIR := ${CURDIR} + ++export KUBERNETES_SERVER_ARCH=arm64 ++ + .PHONY: all container getbins clean + + all: container +@@ -47,9 +49,9 @@ _cache/.getbins.$(kube_version_full).timestamp: + KUBERNETES_DOWNLOAD_TESTS=true \ + KUBERNETES_SKIP_CONFIRM=true ./kubernetes/cluster/get-kube-binaries.sh + mv _cache/$(kube_version_full)/kubernetes/cluster ./ +- mv _cache/$(kube_version_full)/kubernetes/platforms/linux/amd64/e2e.test ./ +- mv _cache/$(kube_version_full)/kubernetes/platforms/linux/amd64/ginkgo ./ +- mv _cache/$(kube_version_full)/kubernetes/platforms/linux/amd64/kubectl ./ ++ mv _cache/$(kube_version_full)/kubernetes/platforms/linux/arm64/e2e.test ./ ++ mv _cache/$(kube_version_full)/kubernetes/platforms/linux/arm64/ginkgo ./ ++ mv _cache/$(kube_version_full)/kubernetes/platforms/linux/arm64/kubectl ./ + touch $@ + + container: e2e.test kubectl ginkgo diff --git a/docker/sonobuoy-plugin-systemd-logs/Makefile b/docker/sonobuoy-plugin-systemd-logs/Makefile new file mode 100644 index 0000000..d06875d --- /dev/null +++ b/docker/sonobuoy-plugin-systemd-logs/Makefile @@ -0,0 +1,28 @@ +############################################################################## +# Copyright (c) 2019 AT&T, ENEA AB, Nokia and others # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you maynot 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. # +############################################################################## + +export WORK_DIR?=$(TAG_PRE) + +.PHONY: .build +.build:: .submodules_patched + +.PHONY: all +all: .push_image .push_manifest + +.PHONY: build +build: .build + +include ../build.mk diff --git a/docker/sonobuoy-plugin-systemd-logs/patches/aarch64/0001-Dockerfile-AArch64-support.patch b/docker/sonobuoy-plugin-systemd-logs/patches/aarch64/0001-Dockerfile-AArch64-support.patch new file mode 100644 index 0000000..199e923 --- /dev/null +++ b/docker/sonobuoy-plugin-systemd-logs/patches/aarch64/0001-Dockerfile-AArch64-support.patch @@ -0,0 +1,28 @@ +From: Alexandru Avadanii +Date: Tue, 25 Jun 2019 17:45:29 +0200 +Subject: [PATCH] Dockerfile: AArch64 support + +Signed-off-by: Alexandru Avadanii +--- + Dockerfile | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/Dockerfile b/Dockerfile +index 06d872c..687d541 100644 +--- a/Dockerfile ++++ b/Dockerfile +@@ -13,10 +13,12 @@ + # See the License for the specific language governing permissions and + # limitations under the License. + +-FROM buildpack-deps:jessie-scm ++FROM arm64v8/buildpack-deps:jessie-scm + MAINTAINER Ken Simon "ken@heptio.com" + +-RUN apt-get update && apt-get -y --no-install-recommends install \ ++RUN echo 'Acquire::Check-Valid-Until "0";' > /etc/apt/apt.conf.d/10no--check-valid-until \ ++ && sed -i -e '/security/s/^/#/g' -e 's|deb.debian.org/debian|snapshot.debian.org/archive/debian/20190301T035241Z|g' /etc/apt/sources.list \ ++ && apt-get update && apt-get -y --no-install-recommends install \ + ca-certificates \ + && rm -rf /var/cache/apt/* \ + && rm -rf /var/lib/apt/lists/* diff --git a/docker/sonobuoy-plugin-systemd-logs/sonobuoy-plugin-systemd-logs b/docker/sonobuoy-plugin-systemd-logs/sonobuoy-plugin-systemd-logs new file mode 160000 index 0000000..f49e35d --- /dev/null +++ b/docker/sonobuoy-plugin-systemd-logs/sonobuoy-plugin-systemd-logs @@ -0,0 +1 @@ +Subproject commit f49e35d220772879aa057da7d103af35a21439b6 diff --git a/tox.ini b/tox.ini index a1cdceb..bfba457 100644 --- a/tox.ini +++ b/tox.ini @@ -18,6 +18,7 @@ whitelist_externals = wget unzip bash + rm passenv = http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY install_command = python -m pip install --no-cache-dir {opts} {packages} @@ -28,8 +29,9 @@ deps = requests~=2.21.0 nodeenv commands = + rm -rf docker/kube-conformance/kube-conformance docker/sonobuoy-plugin-systemd-logs/sonobuoy-plugin-systemd-logs nodeenv -p npm install --global write-good eslint complexity-report@2.0.0-alpha wget --timeout=120 -q https://github.com/pmd/pmd/releases/download/pmd_releases/6.15.0/pmd-bin-6.15.0.zip unzip -q pmd-bin-6.15.0.zip - bash -c "export PATH=$PATH:$PWD/pmd-bin-6.15.0/bin/ && coala --non-interactive" \ No newline at end of file + bash -c "export PATH=$PATH:$PWD/pmd-bin-6.15.0/bin/ && coala --non-interactive" diff --git a/ui/src/main/webapp/.eslintrc b/ui/src/main/webapp/.eslintrc index 53fe50e..d1e9531 100644 --- a/ui/src/main/webapp/.eslintrc +++ b/ui/src/main/webapp/.eslintrc @@ -1,9 +1,9 @@ { "globals": { - "angular": 1, + "angular": writable, "console": 1, "confirm":1, "localStorage":1, "window":1 } -} \ No newline at end of file +} -- 2.16.6