From 598b4fe8c30d06d28f923c92a9b093ce98fad86b Mon Sep 17 00:00:00 2001 From: Wainer dos Santos Moschetta Date: Wed, 6 May 2020 14:15:38 -0400 Subject: [PATCH] ci/openshift-ci: Enable openshift-ci Enable openshift-ci on runtime repository. Fixes: github.com/kata-containers/tests#2527 Depends-on: github.com/kata-containers/tests#2802 Signed-off-by: Wainer dos Santos Moschetta --- .ci/openshift-ci/build.sh | 28 +++++++++++++ .ci/openshift-ci/images/Dockerfile | 17 ++++++++ .ci/openshift-ci/images/entrypoint.sh | 57 +++++++++++++++++++++++++++ 3 files changed, 102 insertions(+) create mode 100755 .ci/openshift-ci/build.sh create mode 100644 .ci/openshift-ci/images/Dockerfile create mode 100755 .ci/openshift-ci/images/entrypoint.sh diff --git a/.ci/openshift-ci/build.sh b/.ci/openshift-ci/build.sh new file mode 100755 index 0000000000..2437ef7592 --- /dev/null +++ b/.ci/openshift-ci/build.sh @@ -0,0 +1,28 @@ +#!/bin/bash +# +# Copyright (c) 2020 Red Hat Inc. +# +# SPDX-License-Identifier: Apache-2.0 +# +# Build and install kata-containers under /_out/build_install +# + +set -e + +export GOPATH=${GOPATH:-${HOME}/go} +cidir=$(dirname "$0")/.. +source "${cidir}/lib.sh" + +export kata_repo=$(git config --get remote.origin.url | sed -e 's#http\(s\)*://##') + +mkdir -p $cidir/../_out/build_install +destdir=$(realpath $cidir/../_out/build_install) + +clone_tests_repo +pushd "${tests_repo_dir}" +# Resolve the kata-container repositories. It relies on branch and +# kata_repo variables. +export branch=master +.ci/resolve-kata-dependencies.sh +.ci/openshift-ci/buildall_install.sh $destdir +popd diff --git a/.ci/openshift-ci/images/Dockerfile b/.ci/openshift-ci/images/Dockerfile new file mode 100644 index 0000000000..9ed3ce4348 --- /dev/null +++ b/.ci/openshift-ci/images/Dockerfile @@ -0,0 +1,17 @@ +# Copyright (c) 2020 Red Hat Inc. +# +# SPDX-License-Identifier: Apache-2.0 +# +# Build the image which wraps the kata-containers installation along with the +# install script. It is used on a daemonset to deploy kata on OpenShift. +# +FROM centos:7 + +RUN yum install -y rsync + +# Load the installation files. +COPY ./_out ./_out + +COPY ./entrypoint.sh /usr/bin + +ENTRYPOINT /usr/bin/entrypoint.sh diff --git a/.ci/openshift-ci/images/entrypoint.sh b/.ci/openshift-ci/images/entrypoint.sh new file mode 100755 index 0000000000..21be638c1b --- /dev/null +++ b/.ci/openshift-ci/images/entrypoint.sh @@ -0,0 +1,57 @@ +#!/bin/bash +# +# Copyright (c) 2020 Red Hat Inc. +# +# SPDX-License-Identifier: Apache-2.0 +# +# Synchronize the kata-containers installation with in the host filesystem. +# +set -x + +install_status=1 + +SRC="${PWD}/_out/build_install" + +# Expect the host filesystem to be mounted in following path. +HOST_MOUNT=/host + +# Some files are copied over /usr which on Red Hat CoreOS (rhcos) is mounted +# read-only by default. So re-mount it as read-write, otherwise files won't +# get copied. +mount -o remount,rw $HOST_MOUNT/usr + +# The host's '/opt' and '/usr/local' are symlinks to, respectively, '/var/opt' +# and '/var/usrlocal'. Adjust the installation files accordingly. +# +cd $SRC +if [ -d 'opt' ]; then + mkdir -p var + mv opt var +fi + +if [ -d "usr/local" ]; then + mkdir -p var + mv usr/local var/usrlocal +fi + +# Copy the installation over the host filesystem. +rsync -a . $HOST_MOUNT + +# Ensure the binaries are searcheable via PATH. Notice it expects that +# kata has been built with PREFIX=/opt/kata. +# +chroot $HOST_MOUNT sh -c 'for t in /opt/kata/bin/*; do ln -s $t /var/usrlocal/bin/; done' + +# Check the installation is good (or not). +chroot $HOST_MOUNT /opt/kata/bin/kata-runtime kata-check +install_status=$? + +# Sending a termination message. Can be used by an orchestrator that will +# look into this file to check the installation has finished and is good. +# +echo "$install_status" >> /tmp/kata_install_status + +# By using it in an openshift daemonset it should spin forever until an +# orchestrator kills it. +# +tail -f /dev/null