Skip to content
This repository has been archived by the owner on Jun 28, 2024. It is now read-only.

Commit

Permalink
ci: containerd_nydus_setup
Browse files Browse the repository at this point in the history
Ensure nydus is setup to be used by containerd as part of our tests.

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
Signed-off-by: ChengyuZhu6 <chengyu.zhu@intel.com>
  • Loading branch information
fidencio committed Sep 22, 2023
1 parent 336f44b commit c070c2a
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
47 changes: 47 additions & 0 deletions .ci/containerd_nydus_setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/bash
#
# Copyright (c) 2023 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0
#

set -o errexit
set -o nounset
set -o pipefail

cidir=$(dirname "$0")
source "${cidir}/../lib/common.bash"

# Nydus related configurations
NYDUS_SNAPSHOTTER_BINARY="/usr/local/bin/containerd-nydus-grpc"
NYDUS_SNAPSHOTTER_TARFS_CONFIG="/usr/local/share/nydus-snapshotter/config-coco-host-sharing.toml"
NYDUS_SNAPSHOTTER_GUEST_CONFIG="/usr/local/share/nydus-snapshotter/config-coco-guest-pulling.toml"
NYDUS_SNAPSHOTTER_CONFIG="${NYDUS_SNAPSHOTTER_CONFIG:-${NYDUS_SNAPSHOTTER_TARFS_CONFIG}}"
NYDUS_SNAPSHOTTER_TARFS_EXPORT_MODE="${NYDUS_SNAPSHOTTER_TARFS_EXPORT_MODE:-image_block}"

echo "Configure nydus snapshotter"
if [ "${IMAGE_OFFLOAD_TO_GUEST:-"no"}" == "yes" ]; then
NYDUS_SNAPSHOTTER_CONFIG="${NYDUS_SNAPSHOTTER_GUEST_CONFIG}"
else
NYDUS_SNAPSHOTTER_CONFIG="${NYDUS_SNAPSHOTTER_TARFS_CONFIG}"
sudo sed -i "s/export_mode = .*/export_mode = \"${NYDUS_SNAPSHOTTER_TARFS_EXPORT_MODE}\"/" "$NYDUS_SNAPSHOTTER_CONFIG"
fi

echo "Start nydus snapshotter"
sudo "${NYDUS_SNAPSHOTTER_BINARY}" --config "${NYDUS_SNAPSHOTTER_CONFIG}" >/dev/stdout 2>&1 &

echo "Configure containerd to use the nydus snapshotter"

containerd_config_dir="/etc/containerd"
containerd_config_file="${containerd_config_dir}/config.toml"

snapshotter_socket="/run/containerd-nydus/containerd-nydus-grpc.sock"
proxy_config=" [proxy_plugins.nydus]\n type = \"snapshot\"\n address = \"${snapshotter_socket}\""
snapshotter_config=" disable_snapshot_annotations = false\n snapshotter = \"nydus\""

# We're assuming here to be working on a clean VM.
echo -e "[proxy_plugins]" | sudo tee -a "${containerd_config_file}"
echo -e "${proxy_config}" | sudo tee -a "${containerd_config_file}"
sudo sed -i '/\[plugins.cri.containerd\]/a\'"${snapshotter_config}" "${containerd_config_file}"

restart_containerd_service
1 change: 1 addition & 0 deletions .ci/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ install_extra_tools() {
if [ "${IMAGE_OFFLOAD_TO_GUEST}" == "yes" ]; then
info "Install nydus-snapshotter"
bash -f "${cidir}/install_nydus_snapshotter.sh"
bash -f "${cidir}/containerd_nydus_setup.sh"
fi

echo "Install CNI plugins"
Expand Down

0 comments on commit c070c2a

Please sign in to comment.