mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
Install containerd package depending on CONTAINER_RUNTIME
This commit is contained in:
parent
c4ef6a94b3
commit
acd286d95d
@ -436,6 +436,39 @@ function install-docker {
|
|||||||
rm -rf /var/lib/apt/lists/*
|
rm -rf /var/lib/apt/lists/*
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# If we are on ubuntu we can try to install containerd
|
||||||
|
function install-containerd {
|
||||||
|
# bailout if we are not on ubuntu
|
||||||
|
if ! command -v apt-get >/dev/null 2>&1; then
|
||||||
|
echo "Unable to install automatically install docker. Bailing out..."
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
# Install dependencies, some of these are already installed in the image but
|
||||||
|
# that's fine since they won't re-install and we can reuse the code below
|
||||||
|
# for another image someday.
|
||||||
|
apt-get update
|
||||||
|
apt-get install -y --no-install-recommends \
|
||||||
|
apt-transport-https \
|
||||||
|
ca-certificates \
|
||||||
|
socat \
|
||||||
|
curl \
|
||||||
|
gnupg2 \
|
||||||
|
software-properties-common \
|
||||||
|
lsb-release
|
||||||
|
|
||||||
|
# Add the Docker apt-repository (as we install containerd from there)
|
||||||
|
curl -fsSL https://download.docker.com/linux/$(. /etc/os-release; echo "$ID")/gpg \
|
||||||
|
| apt-key add -
|
||||||
|
add-apt-repository \
|
||||||
|
"deb [arch=amd64] https://download.docker.com/linux/$(. /etc/os-release; echo "$ID") \
|
||||||
|
$(lsb_release -cs) stable"
|
||||||
|
|
||||||
|
# Install containerd from Docker repo
|
||||||
|
apt-get update && \
|
||||||
|
apt-get install -y --no-install-recommends containerd
|
||||||
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
}
|
||||||
|
|
||||||
function ensure-container-runtime {
|
function ensure-container-runtime {
|
||||||
container_runtime="${CONTAINER_RUNTIME:-docker}"
|
container_runtime="${CONTAINER_RUNTIME:-docker}"
|
||||||
if [[ "${container_runtime}" == "docker" ]]; then
|
if [[ "${container_runtime}" == "docker" ]]; then
|
||||||
@ -448,11 +481,17 @@ function ensure-container-runtime {
|
|||||||
fi
|
fi
|
||||||
docker version
|
docker version
|
||||||
elif [[ "${container_runtime}" == "containerd" ]]; then
|
elif [[ "${container_runtime}" == "containerd" ]]; then
|
||||||
|
set -x
|
||||||
if ! command -v ctr >/dev/null 2>&1; then
|
if ! command -v ctr >/dev/null 2>&1; then
|
||||||
echo "ERROR ctr not found. Aborting."
|
install-containerd
|
||||||
exit 2
|
if ! command -v containerd >/dev/null 2>&1; then
|
||||||
|
echo "ERROR containerd not found. Aborting."
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
ctr version
|
ctr --version
|
||||||
|
containerd --version
|
||||||
|
runc --version
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user