From b7dc3bd193aad9fb1b8e4ded29220caebd6a2692 Mon Sep 17 00:00:00 2001 From: lixiaoyuner <35456895+lixiaoyuner@users.noreply.github.com> Date: Wed, 6 Mar 2024 21:46:31 -0800 Subject: [PATCH] [Build] Install k8s packages from sonic build storage to mitigate k8s source deprecation issue (#18280) Why I did it pkgs.k8s.io: Introducing Kubernetes Community-Owned Package Repositories | Kubernetes For 1.22.2 k8s packages, source repo has been deprecated, going to store these packages in sonic build storage for installation to mitigate the issue. Will migrate to new repo when we are ready to upgrade k8s version. Work item tracking Microsoft ADO (number only): 27075924 How I did it Store the 1.22.2 k8s package in sonic build storage and install the package there. How to verify it "apt list" to check if it's installed. --- Makefile.work | 1 + build_debian.sh | 29 +++++++++++++++++++---------- rules/config | 1 + 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/Makefile.work b/Makefile.work index 286510d1eeb1..ba2dd7b6f067 100644 --- a/Makefile.work +++ b/Makefile.work @@ -514,6 +514,7 @@ SONIC_BUILD_INSTRUCTION := $(MAKE) \ INCLUDE_KUBERNETES=$(INCLUDE_KUBERNETES) \ KUBERNETES_VERSION=$(KUBERNETES_VERSION) \ KUBERNETES_CNI_VERSION=$(KUBERNETES_CNI_VERSION) \ + KUBERNETES_CRI_TOOLS_VERSION=$(KUBERNETES_CRI_TOOLS_VERSION) \ K8s_GCR_IO_PAUSE_VERSION=$(K8s_GCR_IO_PAUSE_VERSION) \ INCLUDE_KUBERNETES_MASTER=$(INCLUDE_KUBERNETES_MASTER) \ SONIC_ENABLE_PFCWD_ON_START=$(ENABLE_PFCWD_ON_START) \ diff --git a/build_debian.sh b/build_debian.sh index f8de45c7f3d6..41d8e432879a 100755 --- a/build_debian.sh +++ b/build_debian.sh @@ -277,16 +277,25 @@ sudo LANG=C chroot $FILESYSTEM_ROOT apt-get -y remove software-properties-common install_kubernetes () { local ver="$1" - sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT curl -fsSL \ - https://packages.cloud.google.com/apt/doc/apt-key.gpg | \ - sudo LANG=C chroot $FILESYSTEM_ROOT apt-key add - - ## Check out the sources list update matches current Debian version - sudo cp files/image_config/kubernetes/kubernetes.list $FILESYSTEM_ROOT/etc/apt/sources.list.d/ - sudo LANG=C chroot $FILESYSTEM_ROOT apt-get update - sudo LANG=C chroot $FILESYSTEM_ROOT apt-get -y install kubernetes-cni=${KUBERNETES_CNI_VERSION} - sudo LANG=C chroot $FILESYSTEM_ROOT apt-get -y install kubelet=${ver} - sudo LANG=C chroot $FILESYSTEM_ROOT apt-get -y install kubectl=${ver} - sudo LANG=C chroot $FILESYSTEM_ROOT apt-get -y install kubeadm=${ver} + ## Install k8s package from storage + local storage_prefix="https://sonicstorage.blob.core.windows.net/public/kubernetes" + sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT curl -o /tmp/cri-tools.deb -fsSL \ + ${storage_prefix}/cri-tools_${KUBERNETES_CRI_TOOLS_VERSION}_${CONFIGURED_ARCH}.deb + sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT curl -o /tmp/kubernetes-cni.deb -fsSL \ + ${storage_prefix}/kubernetes-cni_${KUBERNETES_CNI_VERSION}_${CONFIGURED_ARCH}.deb + sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT curl -o /tmp/kubelet.deb -fsSL \ + ${storage_prefix}/kubelet_${ver}_${CONFIGURED_ARCH}.deb + sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT curl -o /tmp/kubectl.deb -fsSL \ + ${storage_prefix}/kubectl_${ver}_${CONFIGURED_ARCH}.deb + sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT curl -o /tmp/kubeadm.deb -fsSL \ + ${storage_prefix}/kubeadm_${ver}_${CONFIGURED_ARCH}.deb + + sudo LANG=C chroot $FILESYSTEM_ROOT apt-get -y install -f /tmp/cri-tools.deb + sudo LANG=C chroot $FILESYSTEM_ROOT apt-get -y install -f /tmp/kubernetes-cni.deb + sudo LANG=C chroot $FILESYSTEM_ROOT apt-get -y install -f /tmp/kubelet.deb + sudo LANG=C chroot $FILESYSTEM_ROOT apt-get -y install -f /tmp/kubectl.deb + sudo LANG=C chroot $FILESYSTEM_ROOT apt-get -y install -f /tmp/kubeadm.deb + sudo LANG=C chroot $FILESYSTEM_ROOT rm -f /tmp/{cri-tools,kubernetes-cni,kubelet,kubeadm,kubectl}.deb } if [ "$INCLUDE_KUBERNETES" == "y" ] diff --git a/rules/config b/rules/config index 8ac564dea220..994b626f99bc 100644 --- a/rules/config +++ b/rules/config @@ -195,6 +195,7 @@ KUBE_DOCKER_PROXY = http://172.16.1.1:3128/ # KUBERNETES_VERSION = 1.22.2-00 KUBERNETES_CNI_VERSION = 0.8.7-00 +KUBERNETES_CRI_TOOLS_VERSION = 1.26.0-00 K8s_GCR_IO_PAUSE_VERSION = 3.5 # INCLUDE_KUBERNETES_MASTER - if set to y kubernetes packages are installed o be able