From c93a43c130ca26e5938d3f65061ad2c001ce0c7e Mon Sep 17 00:00:00 2001 From: Markus Lehtonen Date: Fri, 6 Sep 2024 09:09:11 +0300 Subject: [PATCH] e2e: fix kubernetes repo key import for older ubuntu and debian They still need to use apt-key. Even if apt-key is deprecated we should be able to use it as long it exists on the host. --- demo/lib/distro.bash | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/demo/lib/distro.bash b/demo/lib/distro.bash index c1637e7b2..9f6789a33 100644 --- a/demo/lib/distro.bash +++ b/demo/lib/distro.bash @@ -285,10 +285,18 @@ debian-install-k8s() { _k8s=$COMMAND_OUTPUT fi echo "installing Kubernetes v${_k8s}" - vm-command "curl -fsSL https://pkgs.k8s.io/core:/stable:/v${_k8s}/deb/Release.key | sudo gpg --dearmor --batch --yes -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg" || \ + vm-command "curl -fsSL https://pkgs.k8s.io/core:/stable:/v${_k8s}/deb/Release.key -o /tmp/Release.key" || \ command-error "failed to download Kubernetes v${_k8s} key" - vm-command "echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v${_k8s}/deb/ /' > /etc/apt/sources.list.d/kubernetes.list && apt update" || \ - command-error "failed to add Kubernetes v${_k8s} repo" + + if vm-command "command -v apt-key >/dev/null"; then + vm-command "sudo apt-key add /tmp/Release.key" + vm-command "echo 'deb https://pkgs.k8s.io/core:/stable:/v${_k8s}/deb/ /' > /etc/apt/sources.list.d/kubernetes.list && apt update" || \ + command-error "failed to add Kubernetes v${_k8s} repo" + else + vm-command "sudo gpg --dearmor --batch --yes -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg /tmp/Release.key" + vm-command "echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v${_k8s}/deb/ /' > /etc/apt/sources.list.d/kubernetes.list && apt update" || \ + command-error "failed to add Kubernetes v${_k8s} repo" + fi debian-install-pkg "kubeadm" "kubelet" "kubectl" }