From b27c140b21ddf443c27d61ebb27834a34a1116cd Mon Sep 17 00:00:00 2001 From: Krisztian Litkey Date: Tue, 5 Mar 2024 16:47:34 +0200 Subject: [PATCH] test/e2e: switch to using pkgs.k8s.io repos. Switch provisioning of both fedora and ubuntu-based e2e test VMs to the pkgs.k8s.io repositories. Also try autodetecting and using the latest available K8s, containerd and CRI-O releases/versions, unless this is overridden by the user. Signed-off-by: Krisztian Litkey --- test/e2e/files/Vagrantfile.in | 4 +++ test/e2e/playbook/provision.yaml | 12 ++++---- test/e2e/run.sh | 51 ++++++++++++++++++++++++++++++-- 3 files changed, 60 insertions(+), 7 deletions(-) diff --git a/test/e2e/files/Vagrantfile.in b/test/e2e/files/Vagrantfile.in index 7afea5189..8597db0ad 100644 --- a/test/e2e/files/Vagrantfile.in +++ b/test/e2e/files/Vagrantfile.in @@ -14,6 +14,8 @@ HOSTNAME = "SERVER_NAME" # How many nodes to create N = 1 +K8S_RELEASE = "#{ENV['k8s_release']}" +K8S_VERSION = "#{ENV['k8s_version']}" CRI_RUNTIME = "#{ENV['k8scri']}" CRIO_RELEASE = "1.28.1" CRIO_SRC = "" @@ -88,6 +90,8 @@ Vagrant.configure("2") do |config| https_proxy: "#{ENV['HTTPS_PROXY']}", http_proxy: "#{ENV['HTTP_PROXY']}", no_proxy: "#{ENV['NO_PROXY']}", + k8s_release: K8S_RELEASE, + k8s_version: K8S_VERSION, cri_runtime: CRI_RUNTIME, containerd_release: CONTAINERD_RELEASE, containerd_src: CONTAINERD_SRC, diff --git a/test/e2e/playbook/provision.yaml b/test/e2e/playbook/provision.yaml index b27866afd..c286994ea 100644 --- a/test/e2e/playbook/provision.yaml +++ b/test/e2e/playbook/provision.yaml @@ -5,6 +5,8 @@ become_user: root vars: cri_runtime: "{{ cri_runtime }}" + k8s_release: "{{ k8s_release }}" + k8s_version: "{{ k8s_version }}" is_containerd: false is_crio: false containerd_release: "{{ containerd_release }}" @@ -50,15 +52,15 @@ - swapoff --all when: ansible_swaptotal_mb > 0 - - name: Download public signing key Kubernetes + - name: Download public signing key for Kubernetes ansible.builtin.apt_key: - url: https://packages.cloud.google.com/apt/doc/apt-key.gpg + url: https://pkgs.k8s.io/core:/stable:/v{{ k8s_version }}/deb/Release.key state: present when: ansible_facts['distribution'] == "Ubuntu" - name: Add apt repository for Kubernetes ansible.builtin.apt_repository: - repo: "deb https://apt.kubernetes.io/ kubernetes-xenial main" + repo: "https://pkgs.k8s.io/core:/stable:/v{{ k8s_version }}/deb/ /" state: present filename: /etc/apt/sources.list.d/kubernetes.list when: ansible_facts['distribution'] == "Ubuntu" @@ -66,8 +68,8 @@ - name: Add yum repository for Kubernetes ansible.builtin.yum_repository: description: Kubernetes repository - baseurl: "https://packages.cloud.google.com/yum/repos/kubernetes-el7-$basearch" - gpgkey: "https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg" + baseurl: "https://pkgs.k8s.io/core:/stable:/v{{ k8s_version }}/rpm/" + gpgkey: "https://pkgs.k8s.io/core:/stable:/v{{ k8s_version }}/rpm/repodata/repomd.xml.key" state: present name: kubernetes when: ansible_facts['distribution'] == "Fedora" diff --git a/test/e2e/run.sh b/test/e2e/run.sh index f57134261..b8ee90622 100755 --- a/test/e2e/run.sh +++ b/test/e2e/run.sh @@ -23,8 +23,35 @@ export cni_plugin=${cni_plugin:-cilium} export cni_release=${cni_release:-latest} TOPOLOGY_DIR=${TOPOLOGY_DIR:=e2e} +K8S_REPO="https://github.com/kubernetes/kubernetes" +export k8s_release=${k8s_release:-"latest"} +export k8s_version="" + source "$LIB_DIR"/vm.bash +latest-github-release () { + local repo="$1" + local latest=$(wget -q -O- $repo/releases/latest | grep '/tree/v[0-9.]*' | + sed -E 's:.*/tree/v([0-9]*\.[0-9]*)(\.[0-9]*).*:\1\2:g' | head -1) + if [ -z "$latest" ]; then + echo "failed to determine latest release of $repo" + exit 1 + fi + echo "$latest" +} + +if [ "$k8s_release" = "latest" ]; then + if ! k8s_release=$(latest-github-release $K8S_REPO); then + error "$k8s_release" + fi + echo "Latest Kubernetes release: $k8s_release" +fi + +export k8s_version=$(echo $k8s_release | sed -E 's/([0-9]*\.[0-9]*)(\.[0-9]*)/\1/g') +if [ -z "$k8s_version" ]; then + error "failed to determine latest Kubernetes version from \"$k8s_release"\" +fi + export vm_name=${vm_name:=$(vm-create-name "$k8scri" "$(basename "$TOPOLOGY_DIR")" ${distro})} ESCAPED_VM=$(printf '%s\n' "$vm_name" | sed -e 's/[\/]/-/g') export VM_HOSTNAME="$ESCAPED_VM" @@ -53,7 +80,16 @@ fi # from a release tarball with the version given below... unless # a source directory is given, which is then expected to contain # a compiled version of containerd which we should install. -export containerd_release=${containerd_release:-1.7.6} +CONTAINERD_REPO="https://github.com/containerd/containerd" +export containerd_release=${containerd_release:-latest} + +if [ "$k8scri" = "containerd" -a "$containerd_release" = "latest" ]; then + if ! containerd_release=$(latest-github-release $CONTAINERD_REPO); then + error "$containerd_release" + fi + echo "Latest containerd release: $containerd_release" +fi + export containerd_src=${containerd_src:-} @@ -61,9 +97,17 @@ export containerd_src=${containerd_src:-} # a release tarball with the version given below... unless a # source directory is given, which is then expected to contain # a compiled version of CRI-O which we should install. -export crio_release=${crio_release:-1.28.1} +CRIO_REPO="https://github.com/cri-o/cri-o" +export crio_release=${crio_release:-latest} export crio_src=${crio_src:-} +if [ "$k8scri" = "crio" -a "$crio_release" = "latest" ]; then + if ! crio_release=$(latest-github-release $CRIO_REPO); then + error "$crio_release" + fi + echo "Latest CRI-O release: $crio_release" +fi + # Default topology if not given. The run_tests.sh script will figure out # the topology from the test directory structure and contents. if [ -z "$topology" ]; then @@ -108,6 +152,9 @@ fi echo echo " VM = $vm_name" echo " Distro = $distro" +echo " Kubernetes" +echo " - release = $k8s_release" +echo " - version = $k8s_version" echo " Runtime = $k8scri" echo " Output dir = $OUTPUT_DIR" echo " Test output dir = $TEST_OUTPUT_DIR"