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

Commit

Permalink
ci/openshift-ci: Enable openshift-ci
Browse files Browse the repository at this point in the history
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 <wainersm@redhat.com>
  • Loading branch information
wainersm committed Aug 24, 2020
1 parent b9501dc commit 594da37
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .ci/openshift-ci/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# OpenShift CI files

This directory contain scripts and files used by the openshift-ci operator to test kata. For further details read this [README](https://github.com/kata-containers/tests/tree/master/.ci/openshift-ci/README.md) file.
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:8

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 runtime binary is searcheable via PATH. Notice it expects that
# kata has been built with PREFIX=/opt/kata.
#
chroot $HOST_MOUNT ln -s /opt/kata/bin/containerd-shim-kata-v2 /var/usrlocal/bin/

# 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.
#
while true; do sleep 600; done

0 comments on commit 594da37

Please sign in to comment.