Skip to content

Commit acd286d

Browse files
committed
Install containerd package depending on CONTAINER_RUNTIME
1 parent c4ef6a9 commit acd286d

File tree

1 file changed

+42
-3
lines changed

1 file changed

+42
-3
lines changed

cluster/gce/gci/configure.sh

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,39 @@ function install-docker {
436436
rm -rf /var/lib/apt/lists/*
437437
}
438438

439+
# If we are on ubuntu we can try to install containerd
440+
function install-containerd {
441+
# bailout if we are not on ubuntu
442+
if ! command -v apt-get >/dev/null 2>&1; then
443+
echo "Unable to install automatically install docker. Bailing out..."
444+
return
445+
fi
446+
# Install dependencies, some of these are already installed in the image but
447+
# that's fine since they won't re-install and we can reuse the code below
448+
# for another image someday.
449+
apt-get update
450+
apt-get install -y --no-install-recommends \
451+
apt-transport-https \
452+
ca-certificates \
453+
socat \
454+
curl \
455+
gnupg2 \
456+
software-properties-common \
457+
lsb-release
458+
459+
# Add the Docker apt-repository (as we install containerd from there)
460+
curl -fsSL https://download.docker.com/linux/$(. /etc/os-release; echo "$ID")/gpg \
461+
| apt-key add -
462+
add-apt-repository \
463+
"deb [arch=amd64] https://download.docker.com/linux/$(. /etc/os-release; echo "$ID") \
464+
$(lsb_release -cs) stable"
465+
466+
# Install containerd from Docker repo
467+
apt-get update && \
468+
apt-get install -y --no-install-recommends containerd
469+
rm -rf /var/lib/apt/lists/*
470+
}
471+
439472
function ensure-container-runtime {
440473
container_runtime="${CONTAINER_RUNTIME:-docker}"
441474
if [[ "${container_runtime}" == "docker" ]]; then
@@ -448,11 +481,17 @@ function ensure-container-runtime {
448481
fi
449482
docker version
450483
elif [[ "${container_runtime}" == "containerd" ]]; then
484+
set -x
451485
if ! command -v ctr >/dev/null 2>&1; then
452-
echo "ERROR ctr not found. Aborting."
453-
exit 2
486+
install-containerd
487+
if ! command -v containerd >/dev/null 2>&1; then
488+
echo "ERROR containerd not found. Aborting."
489+
exit 2
490+
fi
454491
fi
455-
ctr version
492+
ctr --version
493+
containerd --version
494+
runc --version
456495
fi
457496
}
458497

0 commit comments

Comments
 (0)