Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
Merge pull request #2891 from wainersm/enable_openshift-ci
Browse files Browse the repository at this point in the history
ci/openshift-ci: Enable openshift-ci
  • Loading branch information
c3d committed Sep 25, 2020
2 parents bf9b86e + 598b4fe commit cf5d190
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 0 deletions.
28 changes: 28 additions & 0 deletions .ci/openshift-ci/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash
#
# Copyright (c) 2020 Red Hat Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
# Build and install kata-containers under <repository>/_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
17 changes: 17 additions & 0 deletions .ci/openshift-ci/images/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
57 changes: 57 additions & 0 deletions .ci/openshift-ci/images/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit cf5d190

Please sign in to comment.