This repository has been archived by the owner on Jun 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This will install runtime, shim, agent, proxy, qemu, and all dependencies to run kata-containers. Fixes #70 Signed-off-by: Gabriela Cervantes <[email protected]>
- Loading branch information
Showing
10 changed files
with
418 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash -e | ||
# | ||
# Copyright (c) 2017-2018 Intel Corporation | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
cidir=$(dirname "$0") | ||
|
||
source "${cidir}/lib.sh" | ||
|
||
clone_build_and_install "github.com/kata-containers/agent" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/bin/bash -e | ||
# | ||
# Copyright (c) 2017-2018 Intel Corporation | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
cidir=$(dirname "$0") | ||
|
||
OSBUILDER_DISTRO=${OSBUILDER_DISTRO:-clearlinux} | ||
image_name="kata-containers.img" | ||
|
||
# Build Kata agent | ||
bash -f ${cidir}/install_agent.sh | ||
|
||
osbuilder_repo="github.com/kata-containers/osbuilder" | ||
|
||
# Clone os-builder repository | ||
go get -d ${osbuilder_repo} || true | ||
|
||
pushd "${GOPATH}/src/${osbuilder_repo}/rootfs-builder" | ||
sudo -E GOPATH=$GOPATH USE_DOCKER=true ./rootfs.sh ${OSBUILDER_DISTRO} | ||
popd | ||
|
||
# Build the image | ||
pushd "${GOPATH}/src/${osbuilder_repo}/image-builder" | ||
sudo -E USE_DOCKER=true ./image_builder.sh ../rootfs-builder/rootfs | ||
|
||
# Install the image | ||
agent_commit=$("$GOPATH/src/github.com/kata-containers/agent/kata-agent" --version | awk '{print $NF}') | ||
commit=$(git log --format=%h -1 HEAD) | ||
date=$(date +%Y-%m-%d-%T.%N%z) | ||
image="kata-containers-${date}-osbuilder-${commit}-agent-${agent_commit}" | ||
|
||
sudo install -o root -g root -m 0640 -D ${image_name} "/usr/share/kata-containers/${image}" | ||
(cd /usr/share/kata-containers && sudo rm -f ${image_name} && sudo ln -s "$image" ${image_name}) | ||
|
||
popd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
#!/bin/bash -e | ||
# | ||
# Copyright (c) 2017-2018 Intel Corporation | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
# Currently we will use this repository until this issue is solved | ||
# See https://github.com/kata-containers/packaging/issues/1 | ||
|
||
repo_owner="clearcontainers" | ||
repo_name="linux" | ||
|
||
linux_releases_url="https://github.com/${repo_owner}/${repo_name}/releases" | ||
#fake repository dir to query kernel version from remote | ||
fake_repo_dir=$(mktemp -t -d kata-kernel.XXXX) | ||
|
||
function cleanup { | ||
rm -rf "${fake_repo_dir}" | ||
} | ||
trap cleanup EXIT | ||
function usage() { | ||
cat << EOT | ||
Usage: $0 <version> | ||
Install the containers clear kernel image <version> from "${repo_owner}"/"${repo_name}". | ||
version: Use 'latest' to pull latest kernel or a version from "${cc_linux_releases_url}" | ||
EOT | ||
|
||
exit 1 | ||
} | ||
|
||
#Get latest version by checking remote tags | ||
#We dont ask to github api directly because force a user to provide a GITHUB token | ||
function get_latest_version { | ||
pushd "${fake_repo_dir}" >> /dev/null | ||
git init -q | ||
git remote add origin https://github.com/clearcontainers/linux.git | ||
|
||
cc_release=$(git ls-remote --tags 2>/dev/null \ | ||
| grep -oP '\-\d+\.container' \ | ||
| grep -oP '\d+' \ | ||
| sort -n | \ | ||
tail -1 ) | ||
|
||
tag=$(git ls-remote --tags 2>/dev/null \ | ||
| grep -oP "v\d+\.\d+\.\d+\-${cc_release}.container" \ | ||
| tail -1) | ||
|
||
popd >> /dev/null | ||
echo "${tag}" | ||
} | ||
|
||
function download_kernel() { | ||
local version="$1" | ||
[ -n "${version}" ] || die "version not provided" | ||
[ "${version}" == "latest" ] && version=$(get_latest_version) | ||
echo "version to install ${version}" | ||
local binaries_dir="${version}-binaries" | ||
local binaries_tarball="${binaries_dir}.tar.gz" | ||
local shasum_file="SHA512SUMS" | ||
curl -OL "${linux_releases_url}/download/${version}/${binaries_tarball}" | ||
curl -OL "${linux_releases_url}/download/${version}/${shasum_file}" | ||
sha512sum -c "${shasum_file}" | ||
tar xf "${binaries_tarball}" | ||
pushd "${binaries_dir}" | ||
sudo make install | ||
popd | ||
} | ||
|
||
cc_kernel_version="$1" | ||
|
||
[ -z "${cc_kernel_version}" ] && usage | ||
download_kernel "${cc_kernel_version}" | ||
|
||
# Make symbolic link to kata-containers | ||
# FIXME: see https://github.com/kata-containers/packaging/issues/1 | ||
sudo ln -s /usr/share/clear-containers/vmlinux.container /usr/share/kata-containers/ | ||
sudo ln -s /usr/share/clear-containers/vmlinuz.container /usr/share/kata-containers/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash -e | ||
# | ||
# Copyright (c) 2017-2018 Intel Corporation | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
cidir=$(dirname "$0") | ||
|
||
source "${cidir}/lib.sh" | ||
|
||
clone_build_and_install "github.com/kata-containers/proxy" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/bin/bash -e | ||
# | ||
# Copyright (c) 2017-2018 Intel Corporation | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
arch=$(arch) | ||
|
||
if [ "$#" -ne 3 ]; then | ||
echo "Usage: $0 <CLEAR_RELEASE> <QEMU_LITE_VERSION> <DISTRO>" | ||
echo " Install the QEMU_LITE_VERSION from clear CLEAR_RELEASE." | ||
exit 1 | ||
fi | ||
|
||
clear_release="$1" | ||
qemu_lite_version="$2" | ||
distro="$3" | ||
qemu_lite_bin="qemu-lite-bin-${qemu_lite_version}.${arch}.rpm" | ||
qemu_lite_data="qemu-lite-data-${qemu_lite_version}.${arch}.rpm" | ||
|
||
echo -e "Install qemu-lite ${qemu_lite_version}" | ||
|
||
# download packages | ||
curl -LO "https://download.clearlinux.org/releases/${clear_release}/clear/${arch}/os/Packages/${qemu_lite_bin}" | ||
curl -LO "https://download.clearlinux.org/releases/${clear_release}/clear/${arch}/os/Packages/${qemu_lite_data}" | ||
|
||
# install packages | ||
if [ "$distro" == "ubuntu" ]; then | ||
sudo alien -i "./${qemu_lite_bin}" | ||
sudo alien -i "./${qemu_lite_data}" | ||
fi | ||
|
||
# cleanup | ||
rm -f "./${qemu_lite_bin}" | ||
rm -f "./${qemu_lite_data}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#!/bin/bash -e | ||
# | ||
# Copyright (c) 2017-2018 Intel Corporation | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
cidir=$(dirname "$0") | ||
|
||
source "${cidir}/lib.sh" | ||
|
||
# Modify the runtimes build-time defaults | ||
|
||
# enable verbose build | ||
export V=1 | ||
|
||
# tell the runtime build to use sane defaults | ||
export CC_SYSTEM_BUILD="yes" | ||
|
||
# The runtimes config file should live here | ||
export SYSCONFDIR=/etc | ||
|
||
# Artifacts (kernel + image) live below here | ||
export SHAREDIR=/usr/share | ||
|
||
runtime_config_path="${SYSCONFDIR}/kata-containers/configuration.toml" | ||
|
||
PKGDEFAULTSDIR="${SHAREDIR}/defaults/kata-containers" | ||
NEW_RUNTIME_CONFIG="${PKGDEFAULTSDIR}/configuration.toml" | ||
# Note: This will also install the config file. | ||
clone_build_and_install "github.com/kata-containers/runtime" | ||
|
||
# Check system supports running Kata Containers | ||
kata-runtime kata-check | ||
|
||
if [ -e "${NEW_RUNTIME_CONFIG}" ]; then | ||
# Remove the legacy config file | ||
sudo rm -f "${runtime_config_path}" | ||
|
||
# Use the new path | ||
runtime_config_path="${NEW_RUNTIME_CONFIG}" | ||
fi | ||
|
||
echo "Enabling global logging for runtime in file ${runtime_config_path}" | ||
sudo sed -i -e 's/^#\(\[runtime\]\|global_log_path =\)/\1/g' "${runtime_config_path}" | ||
|
||
echo "Enabling all debug options in file ${runtime_config_path}" | ||
sudo sed -i -e 's/^#\(enable_debug\).*=.*$/\1 = true/g' "${runtime_config_path}" | ||
|
||
echo "Add runtime as a new/default Docker runtime. Docker version \"$(docker --version)\" could change according to updates." | ||
docker_options="-D --add-runtime kata-runtime=/usr/local/bin/kata-runtime --default-runtime=kata-runtime" | ||
|
||
config_path="/etc/systemd/system/docker.service.d/" | ||
sudo mkdir -p ${config_path} | ||
|
||
# Check if the system has set http[s] proxy | ||
if [ ! -z "$http_proxy" ] && [ ! -z "$https_proxy" ] ;then | ||
docker_http_proxy="HTTP_PROXY=$http_proxy" | ||
docker_https_proxy="HTTPS_PROXY=$https_proxy" | ||
fi | ||
|
||
cat << EOF | sudo tee ${config_path}/clear-containers.conf | ||
[Service] | ||
Environment="$docker_http_proxy" | ||
Environment="$docker_https_proxy" | ||
ExecStart= | ||
ExecStart=/usr/bin/dockerd ${docker_options} | ||
EOF | ||
|
||
echo "Restart docker service" | ||
sudo systemctl daemon-reload | ||
sudo systemctl restart docker |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash -e | ||
# | ||
# Copyright (c) 2017-2018 Intel Corporation | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
cidir=$(dirname "$0") | ||
|
||
source "${cidir}/lib.sh" | ||
|
||
clone_build_and_install "github.com/kata-containers/shim" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#!/bin/bash -e | ||
# | ||
# Copyright (c) 2017-2018 Intel Corporation | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
_runtime_repo="github.com/kata-containers/runtime" | ||
_versions_file="$GOPATH/src/github.com/clearcontainers/runtime/versions.txt" | ||
KATA_RUNTIME=${KATA_RUNTIME:-cc} | ||
|
||
function clone_and_build() { | ||
github_project="$1" | ||
make_target="$2" | ||
project_dir="${GOPATH}/src/${github_project}" | ||
|
||
echo "Retrieve repository ${github_project}" | ||
go get -d ${github_project} || true | ||
|
||
# fixme: once tool to parse and get branches from github is | ||
# completed, add it here to fetch branches under testing | ||
|
||
pushd ${project_dir} | ||
|
||
echo "Build ${github_project}" | ||
if [ ! -f Makefile ]; then | ||
echo "Run autogen.sh to generate Makefile" | ||
bash -f autogen.sh | ||
fi | ||
|
||
if [ $1 == "github.com/kata-containers/runtime" ]; then | ||
make KATA_RUNTIME=${KATA_RUNTIME} | ||
else | ||
make | ||
fi | ||
|
||
popd | ||
} | ||
|
||
function clone_build_and_install() { | ||
clone_and_build $1 $2 | ||
pushd "${GOPATH}/src/${1}" | ||
echo "Install repository ${1}" | ||
if [ $1 == "github.com/kata-containers/runtime" ]; then | ||
sudo -E PATH=$PATH make KATA_RUNTIME=${KATA_RUNTIME} install | ||
else | ||
sudo -E PATH=$PATH make install | ||
fi | ||
|
||
popd | ||
} | ||
|
||
function get_cc_versions(){ | ||
cc_runtime_repo="github.com/clearcontainers/runtime" | ||
go get -d -u -v "$cc_runtime_repo" || true | ||
[ ! -f "$_versions_file" ] && { echo >&2 "ERROR: cannot find $_versions_file"; exit 1; } | ||
source "$_versions_file" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/bin/bash -e | ||
# | ||
# Copyright (c) 2017-2018 Intel Corporation | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
cidir=$(dirname "$0") | ||
source /etc/os-release | ||
|
||
echo "Set up environment" | ||
if [ "$ID" == ubuntu ];then | ||
bash -f "${cidir}/setup_env_ubuntu.sh" | ||
else | ||
echo >&2 "ERROR: Unrecognised distribution." | ||
exit 1 | ||
fi | ||
|
||
echo "Install shim" | ||
bash -f ${cidir}/install_shim.sh | ||
|
||
echo "Install proxy" | ||
bash -f ${cidir}/install_proxy.sh | ||
|
||
echo "Install runtime" | ||
bash -f ${cidir}/install_runtime.sh | ||
|
||
echo "Drop caches" | ||
sync | ||
sudo -E PATH=$PATH bash -c "echo 3 > /proc/sys/vm/drop_caches" |
Oops, something went wrong.