@@ -542,6 +542,46 @@ function install-containerd-ubuntu {
542
542
sudo systemctl start containerd
543
543
}
544
544
545
+ # If we are on cos we can try to install containerd
546
+ function install-containerd-cos {
547
+ # bailout if we are not on COS
548
+ if [ -e /etc/os-release ] && ! grep -q " ID=cos" /etc/os-release; then
549
+ echo " Unable to automatically install containerd in non-cos image. Bailing out..."
550
+ exit 2
551
+ fi
552
+
553
+ # Override to latest versions of containerd and runc
554
+ systemctl stop containerd
555
+ mkdir -p /home/containerd/
556
+ mount --bind /home/containerd /home/containerd
557
+ mount -o remount,exec /home/containerd
558
+ if [[ -n " ${COS_INSTALL_CONTAINERD_VERSION:- } " ]]; then
559
+ # containerd versions have slightly different url(s), so try both
560
+ # shellcheck disable=SC2086
561
+ ( curl ${CURL_FLAGS} \
562
+ --location \
563
+ " https://github.com/containerd/containerd/releases/download/${COS_INSTALL_CONTAINERD_VERSION} /containerd-${COS_INSTALL_CONTAINERD_VERSION: 1} -${HOST_PLATFORM} -${HOST_ARCH} .tar.gz" \
564
+ || curl ${CURL_FLAGS} \
565
+ --location \
566
+ " https://github.com/containerd/containerd/releases/download/${COS_INSTALL_CONTAINERD_VERSION} /containerd-${COS_INSTALL_CONTAINERD_VERSION: 1} .${HOST_PLATFORM} -${HOST_ARCH} .tar.gz" ) \
567
+ | tar --overwrite -xzv -C /home/containerd/
568
+ cp /usr/lib/systemd/system/containerd.service /etc/systemd/system/containerd.service
569
+ # fix the path of the new containerd binary
570
+ sed -i ' s|ExecStart=.*|ExecStart=/home/containerd/bin/containerd|' /etc/systemd/system/containerd.service
571
+ fi
572
+ if [[ -n " ${COS_INSTALL_RUNC_VERSION:- } " ]]; then
573
+ # shellcheck disable=SC2086
574
+ curl ${CURL_FLAGS} \
575
+ --location \
576
+ " https://github.com/opencontainers/runc/releases/download/${COS_INSTALL_RUNC_VERSION} /runc.${HOST_ARCH} " --output /home/containerd/bin/runc \
577
+ && chmod 755 /home/containerd/bin/runc
578
+ # ensure runc gets picked up from the correct location
579
+ sed -i " /\[Service\]/a Environment=PATH=/home/containerd/bin:$PATH " /etc/systemd/system/containerd.service
580
+ fi
581
+ systemctl daemon-reload
582
+ sudo systemctl start containerd
583
+ }
584
+
545
585
function install-auth-provider-gcp {
546
586
local -r filename=" auth-provider-gcp"
547
587
local -r auth_provider_storage_full_path=" ${AUTH_PROVIDER_GCP_STORAGE_PATH} /${AUTH_PROVIDER_GCP_VERSION} /${HOST_PLATFORM} _${HOST_ARCH} /${filename} "
@@ -587,6 +627,9 @@ function ensure-containerd-runtime {
587
627
if [[ -n " ${UBUNTU_INSTALL_CONTAINERD_VERSION:- } " || -n " ${UBUNTU_INSTALL_RUNC_VERSION:- } " ]]; then
588
628
log-wrap " InstallContainerdUbuntu" install-containerd-ubuntu
589
629
fi
630
+ if [[ -n " ${COS_INSTALL_CONTAINERD_VERSION:- } " || -n " ${COS_INSTALL_RUNC_VERSION:- } " ]]; then
631
+ log-wrap " InstallContainerdCOS" install-containerd-cos
632
+ fi
590
633
591
634
# Fall back to installing distro specific containerd, if not found
592
635
if ! command -v containerd > /dev/null 2>&1 ; then
@@ -598,6 +641,9 @@ function ensure-containerd-runtime {
598
641
Ubuntu)
599
642
log-wrap " InstallContainerdUbuntu" install-containerd-ubuntu
600
643
;;
644
+ cos)
645
+ log-wrap " InstallContainerdCOS" install-containerd-cos
646
+ ;;
601
647
* )
602
648
echo " Installing containerd for linux release ${linuxrelease} not supported" >&2
603
649
exit 2
0 commit comments