From 9ad9268157b1d6a1ccf66f176ad0f29a8f2e5526 Mon Sep 17 00:00:00 2001 From: Karol Szwaj Date: Mon, 11 Mar 2024 13:34:33 +0100 Subject: [PATCH 1/7] fix: debian apt-get update running before configuring repositories Signed-off-by: Karol Szwaj --- pkg/scripts/os_debian.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/pkg/scripts/os_debian.go b/pkg/scripts/os_debian.go index 044b40e1a..d45911b59 100644 --- a/pkg/scripts/os_debian.go +++ b/pkg/scripts/os_debian.go @@ -33,6 +33,16 @@ source /etc/kubeone/proxy-env {{ template "sysctl-k8s" . }} {{ template "journald-config" }} +{{- if .CONFIGURE_REPOSITORIES }} +sudo install -m 0755 -d /etc/apt/keyrings + +curl -fsSL https://pkgs.k8s.io/core:/stable:/{{ .KUBERNETES_MAJOR_MINOR }}/deb/Release.key | sudo gpg --dearmor --yes -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg + +echo "deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/{{ .KUBERNETES_MAJOR_MINOR }}/deb/ /" | sudo tee /etc/apt/sources.list.d/kubernetes.list + +sudo apt-get update +{{- end }} + sudo mkdir -p /etc/apt/apt.conf.d cat < Date: Mon, 11 Mar 2024 13:49:37 +0100 Subject: [PATCH 2/7] remove additional apt-get update Signed-off-by: Karol Szwaj --- pkg/scripts/os_debian.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/pkg/scripts/os_debian.go b/pkg/scripts/os_debian.go index d45911b59..0f44d1c81 100644 --- a/pkg/scripts/os_debian.go +++ b/pkg/scripts/os_debian.go @@ -39,8 +39,6 @@ sudo install -m 0755 -d /etc/apt/keyrings curl -fsSL https://pkgs.k8s.io/core:/stable:/{{ .KUBERNETES_MAJOR_MINOR }}/deb/Release.key | sudo gpg --dearmor --yes -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg echo "deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/{{ .KUBERNETES_MAJOR_MINOR }}/deb/ /" | sudo tee /etc/apt/sources.list.d/kubernetes.list - -sudo apt-get update {{- end }} sudo mkdir -p /etc/apt/apt.conf.d From 382828c30f0bb202947eaade724ef9712b41cad0 Mon Sep 17 00:00:00 2001 From: Karol Szwaj Date: Mon, 11 Mar 2024 14:27:20 +0100 Subject: [PATCH 3/7] update testdata Signed-off-by: Karol Szwaj --- .../testdata/TestKubeadmDebian-cilium_cluster.golden | 12 +++++------- .../TestKubeadmDebian-nutanix_cluster.golden | 12 +++++------- .../TestKubeadmDebian-with_containerd.golden | 12 +++++------- ...ian-with_containerd_with_insecure_registry.golden | 12 +++++------- .../testdata/TestUpgradeKubeadmAndCNIDebian.golden | 12 +++++------- .../TestUpgradeKubeletAndKubectlDebian.golden | 12 +++++------- 6 files changed, 30 insertions(+), 42 deletions(-) diff --git a/pkg/scripts/testdata/TestKubeadmDebian-cilium_cluster.golden b/pkg/scripts/testdata/TestKubeadmDebian-cilium_cluster.golden index dccee3833..264b189c2 100644 --- a/pkg/scripts/testdata/TestKubeadmDebian-cilium_cluster.golden +++ b/pkg/scripts/testdata/TestKubeadmDebian-cilium_cluster.golden @@ -42,6 +42,11 @@ SystemMaxUse=5G EOF sudo systemctl force-reload systemd-journald +sudo install -m 0755 -d /etc/apt/keyrings + +curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.26/deb/Release.key | sudo gpg --dearmor --yes -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg + +echo "deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.26/deb/ /" | sudo tee /etc/apt/sources.list.d/kubernetes.list sudo mkdir -p /etc/apt/apt.conf.d cat < Date: Tue, 12 Mar 2024 13:26:17 +0100 Subject: [PATCH 4/7] remove old kubernetes.list from apt sources Signed-off-by: Karol Szwaj --- pkg/scripts/os_debian.go | 20 ++++++++++++++----- .../TestKubeadmDebian-cilium_cluster.golden | 16 +++++++++++---- .../TestKubeadmDebian-nutanix_cluster.golden | 16 +++++++++++---- .../TestKubeadmDebian-with_containerd.golden | 16 +++++++++++---- ...h_containerd_with_insecure_registry.golden | 16 +++++++++++---- .../TestUpgradeKubeadmAndCNIDebian.golden | 16 +++++++++++---- .../TestUpgradeKubeletAndKubectlDebian.golden | 16 +++++++++++---- 7 files changed, 87 insertions(+), 29 deletions(-) diff --git a/pkg/scripts/os_debian.go b/pkg/scripts/os_debian.go index 0f44d1c81..34cb32138 100644 --- a/pkg/scripts/os_debian.go +++ b/pkg/scripts/os_debian.go @@ -33,12 +33,12 @@ source /etc/kubeone/proxy-env {{ template "sysctl-k8s" . }} {{ template "journald-config" }} +# Removing old Kubernertes repositories from apt sources is needed when upgrading from older Kubeone versions, +# otherwise, apt-get update will fail to upgrade the packages. {{- if .CONFIGURE_REPOSITORIES }} -sudo install -m 0755 -d /etc/apt/keyrings - -curl -fsSL https://pkgs.k8s.io/core:/stable:/{{ .KUBERNETES_MAJOR_MINOR }}/deb/Release.key | sudo gpg --dearmor --yes -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg - -echo "deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/{{ .KUBERNETES_MAJOR_MINOR }}/deb/ /" | sudo tee /etc/apt/sources.list.d/kubernetes.list +if sudo grep -q "deb http://apt.kubernetes.io/ kubernetes-xenial main" /etc/apt/sources.list.d/kubernetes.list; then + rm -f /etc/apt/sources.list.d/kubernetes.list +fi {{- end }} sudo mkdir -p /etc/apt/apt.conf.d @@ -68,6 +68,16 @@ sudo DEBIAN_FRONTEND=noninteractive apt-get install --option "Dpkg::Options::=-- sudo systemctl enable --now iscsid {{- end }} +{{- if .CONFIGURE_REPOSITORIES }} +sudo install -m 0755 -d /etc/apt/keyrings + +curl -fsSL https://pkgs.k8s.io/core:/stable:/{{ .KUBERNETES_MAJOR_MINOR }}/deb/Release.key | sudo gpg --dearmor --yes -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg + +echo "deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/{{ .KUBERNETES_MAJOR_MINOR }}/deb/ /" | sudo tee /etc/apt/sources.list.d/kubernetes.list + +sudo apt-get update +{{- end }} + kube_ver="{{ .KUBERNETES_VERSION }}-*" cni_ver="{{ .KUBERNETES_CNI_VERSION }}-*" cri_ver="{{ .CRITOOLS_VERSION }}-*" diff --git a/pkg/scripts/testdata/TestKubeadmDebian-cilium_cluster.golden b/pkg/scripts/testdata/TestKubeadmDebian-cilium_cluster.golden index 264b189c2..79f70e50d 100644 --- a/pkg/scripts/testdata/TestKubeadmDebian-cilium_cluster.golden +++ b/pkg/scripts/testdata/TestKubeadmDebian-cilium_cluster.golden @@ -42,11 +42,12 @@ SystemMaxUse=5G EOF sudo systemctl force-reload systemd-journald -sudo install -m 0755 -d /etc/apt/keyrings - -curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.26/deb/Release.key | sudo gpg --dearmor --yes -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg -echo "deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.26/deb/ /" | sudo tee /etc/apt/sources.list.d/kubernetes.list +# Removing old Kubernertes repositories from apt sources is needed when upgrading from older Kubeone versions, +# otherwise, apt-get update will fail to upgrade the packages. +if sudo grep -q "deb http://apt.kubernetes.io/ kubernetes-xenial main" /etc/apt/sources.list.d/kubernetes.list; then + rm -f /etc/apt/sources.list.d/kubernetes.list +fi sudo mkdir -p /etc/apt/apt.conf.d cat < Date: Tue, 12 Mar 2024 13:30:42 +0100 Subject: [PATCH 5/7] remove old kubernetes.list from apt sources Signed-off-by: Karol Szwaj --- pkg/scripts/os_debian.go | 16 ++++++++-------- .../TestKubeadmDebian-cilium_cluster.golden | 12 ++++++------ .../TestKubeadmDebian-nutanix_cluster.golden | 12 ++++++------ .../TestKubeadmDebian-with_containerd.golden | 12 ++++++------ ...with_containerd_with_insecure_registry.golden | 12 ++++++------ .../TestUpgradeKubeadmAndCNIDebian.golden | 12 ++++++------ .../TestUpgradeKubeletAndKubectlDebian.golden | 12 ++++++------ 7 files changed, 44 insertions(+), 44 deletions(-) diff --git a/pkg/scripts/os_debian.go b/pkg/scripts/os_debian.go index 34cb32138..6ba10053b 100644 --- a/pkg/scripts/os_debian.go +++ b/pkg/scripts/os_debian.go @@ -33,14 +33,6 @@ source /etc/kubeone/proxy-env {{ template "sysctl-k8s" . }} {{ template "journald-config" }} -# Removing old Kubernertes repositories from apt sources is needed when upgrading from older Kubeone versions, -# otherwise, apt-get update will fail to upgrade the packages. -{{- if .CONFIGURE_REPOSITORIES }} -if sudo grep -q "deb http://apt.kubernetes.io/ kubernetes-xenial main" /etc/apt/sources.list.d/kubernetes.list; then - rm -f /etc/apt/sources.list.d/kubernetes.list -fi -{{- end }} - sudo mkdir -p /etc/apt/apt.conf.d cat < Date: Tue, 12 Mar 2024 13:40:17 +0100 Subject: [PATCH 6/7] fix typos Signed-off-by: Karol Szwaj --- pkg/scripts/os_debian.go | 2 +- pkg/scripts/testdata/TestKubeadmDebian-cilium_cluster.golden | 2 +- pkg/scripts/testdata/TestKubeadmDebian-nutanix_cluster.golden | 2 +- pkg/scripts/testdata/TestKubeadmDebian-with_containerd.golden | 2 +- ...tKubeadmDebian-with_containerd_with_insecure_registry.golden | 2 +- pkg/scripts/testdata/TestUpgradeKubeadmAndCNIDebian.golden | 2 +- pkg/scripts/testdata/TestUpgradeKubeletAndKubectlDebian.golden | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pkg/scripts/os_debian.go b/pkg/scripts/os_debian.go index 6ba10053b..ff2b37e4e 100644 --- a/pkg/scripts/os_debian.go +++ b/pkg/scripts/os_debian.go @@ -43,7 +43,7 @@ Acquire::http::Proxy "{{ .HTTP_PROXY }}"; {{- end }} EOF -# Removing old Kubernertes repositories from apt sources is needed when upgrading from older Kubeone versions, +# Removing deprecated Kubernetes repositories from apt sources is needed when upgrading from older KubeOne versions, # otherwise, apt-get update will fail to upgrade the packages. {{- if .CONFIGURE_REPOSITORIES }} if sudo grep -q "deb http://apt.kubernetes.io/ kubernetes-xenial main" /etc/apt/sources.list.d/kubernetes.list; then diff --git a/pkg/scripts/testdata/TestKubeadmDebian-cilium_cluster.golden b/pkg/scripts/testdata/TestKubeadmDebian-cilium_cluster.golden index 2efffdc2a..8737717c9 100644 --- a/pkg/scripts/testdata/TestKubeadmDebian-cilium_cluster.golden +++ b/pkg/scripts/testdata/TestKubeadmDebian-cilium_cluster.golden @@ -49,7 +49,7 @@ Acquire::https::Proxy "http://https.proxy"; Acquire::http::Proxy "http://http.proxy"; EOF -# Removing old Kubernertes repositories from apt sources is needed when upgrading from older Kubeone versions, +# Removing deprecated Kubernetes repositories from apt sources is needed when upgrading from older KubeOne versions, # otherwise, apt-get update will fail to upgrade the packages. if sudo grep -q "deb http://apt.kubernetes.io/ kubernetes-xenial main" /etc/apt/sources.list.d/kubernetes.list; then rm -f /etc/apt/sources.list.d/kubernetes.list diff --git a/pkg/scripts/testdata/TestKubeadmDebian-nutanix_cluster.golden b/pkg/scripts/testdata/TestKubeadmDebian-nutanix_cluster.golden index fe26dc9d9..d8ad39a39 100644 --- a/pkg/scripts/testdata/TestKubeadmDebian-nutanix_cluster.golden +++ b/pkg/scripts/testdata/TestKubeadmDebian-nutanix_cluster.golden @@ -49,7 +49,7 @@ Acquire::https::Proxy "http://https.proxy"; Acquire::http::Proxy "http://http.proxy"; EOF -# Removing old Kubernertes repositories from apt sources is needed when upgrading from older Kubeone versions, +# Removing deprecated Kubernetes repositories from apt sources is needed when upgrading from older KubeOne versions, # otherwise, apt-get update will fail to upgrade the packages. if sudo grep -q "deb http://apt.kubernetes.io/ kubernetes-xenial main" /etc/apt/sources.list.d/kubernetes.list; then rm -f /etc/apt/sources.list.d/kubernetes.list diff --git a/pkg/scripts/testdata/TestKubeadmDebian-with_containerd.golden b/pkg/scripts/testdata/TestKubeadmDebian-with_containerd.golden index a179f5c43..843bfcb34 100644 --- a/pkg/scripts/testdata/TestKubeadmDebian-with_containerd.golden +++ b/pkg/scripts/testdata/TestKubeadmDebian-with_containerd.golden @@ -49,7 +49,7 @@ Acquire::https::Proxy "http://https.proxy"; Acquire::http::Proxy "http://http.proxy"; EOF -# Removing old Kubernertes repositories from apt sources is needed when upgrading from older Kubeone versions, +# Removing deprecated Kubernetes repositories from apt sources is needed when upgrading from older KubeOne versions, # otherwise, apt-get update will fail to upgrade the packages. if sudo grep -q "deb http://apt.kubernetes.io/ kubernetes-xenial main" /etc/apt/sources.list.d/kubernetes.list; then rm -f /etc/apt/sources.list.d/kubernetes.list diff --git a/pkg/scripts/testdata/TestKubeadmDebian-with_containerd_with_insecure_registry.golden b/pkg/scripts/testdata/TestKubeadmDebian-with_containerd_with_insecure_registry.golden index 641849356..0fd93898e 100644 --- a/pkg/scripts/testdata/TestKubeadmDebian-with_containerd_with_insecure_registry.golden +++ b/pkg/scripts/testdata/TestKubeadmDebian-with_containerd_with_insecure_registry.golden @@ -49,7 +49,7 @@ Acquire::https::Proxy "http://https.proxy"; Acquire::http::Proxy "http://http.proxy"; EOF -# Removing old Kubernertes repositories from apt sources is needed when upgrading from older Kubeone versions, +# Removing deprecated Kubernetes repositories from apt sources is needed when upgrading from older KubeOne versions, # otherwise, apt-get update will fail to upgrade the packages. if sudo grep -q "deb http://apt.kubernetes.io/ kubernetes-xenial main" /etc/apt/sources.list.d/kubernetes.list; then rm -f /etc/apt/sources.list.d/kubernetes.list diff --git a/pkg/scripts/testdata/TestUpgradeKubeadmAndCNIDebian.golden b/pkg/scripts/testdata/TestUpgradeKubeadmAndCNIDebian.golden index e9a266e5d..168437fd7 100644 --- a/pkg/scripts/testdata/TestUpgradeKubeadmAndCNIDebian.golden +++ b/pkg/scripts/testdata/TestUpgradeKubeadmAndCNIDebian.golden @@ -49,7 +49,7 @@ Acquire::https::Proxy "http://https.proxy"; Acquire::http::Proxy "http://http.proxy"; EOF -# Removing old Kubernertes repositories from apt sources is needed when upgrading from older Kubeone versions, +# Removing deprecated Kubernetes repositories from apt sources is needed when upgrading from older KubeOne versions, # otherwise, apt-get update will fail to upgrade the packages. if sudo grep -q "deb http://apt.kubernetes.io/ kubernetes-xenial main" /etc/apt/sources.list.d/kubernetes.list; then rm -f /etc/apt/sources.list.d/kubernetes.list diff --git a/pkg/scripts/testdata/TestUpgradeKubeletAndKubectlDebian.golden b/pkg/scripts/testdata/TestUpgradeKubeletAndKubectlDebian.golden index 8ebe5c6d1..36a06e1a0 100644 --- a/pkg/scripts/testdata/TestUpgradeKubeletAndKubectlDebian.golden +++ b/pkg/scripts/testdata/TestUpgradeKubeletAndKubectlDebian.golden @@ -49,7 +49,7 @@ Acquire::https::Proxy "http://https.proxy"; Acquire::http::Proxy "http://http.proxy"; EOF -# Removing old Kubernertes repositories from apt sources is needed when upgrading from older Kubeone versions, +# Removing deprecated Kubernetes repositories from apt sources is needed when upgrading from older KubeOne versions, # otherwise, apt-get update will fail to upgrade the packages. if sudo grep -q "deb http://apt.kubernetes.io/ kubernetes-xenial main" /etc/apt/sources.list.d/kubernetes.list; then rm -f /etc/apt/sources.list.d/kubernetes.list From a2a725b0fab59155e71a3ac31103fe8b236b95eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20Mudrini=C4=87?= Date: Wed, 13 Mar 2024 15:43:32 +0100 Subject: [PATCH 7/7] Update fixtures MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marko Mudrinić --- .../testdata/TestKubeadmDebian-overwrite_registry.golden | 6 ++++++ .../TestKubeadmDebian-overwrite_registry_insecure.golden | 6 ++++++ pkg/scripts/testdata/TestKubeadmDebian-simple.golden | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/pkg/scripts/testdata/TestKubeadmDebian-overwrite_registry.golden b/pkg/scripts/testdata/TestKubeadmDebian-overwrite_registry.golden index cb4d93543..d61629090 100644 --- a/pkg/scripts/testdata/TestKubeadmDebian-overwrite_registry.golden +++ b/pkg/scripts/testdata/TestKubeadmDebian-overwrite_registry.golden @@ -49,6 +49,12 @@ Acquire::https::Proxy "http://https.proxy"; Acquire::http::Proxy "http://http.proxy"; EOF +# Removing deprecated Kubernetes repositories from apt sources is needed when upgrading from older KubeOne versions, +# otherwise, apt-get update will fail to upgrade the packages. +if sudo grep -q "deb http://apt.kubernetes.io/ kubernetes-xenial main" /etc/apt/sources.list.d/kubernetes.list; then + rm -f /etc/apt/sources.list.d/kubernetes.list +fi + sudo apt-get update sudo DEBIAN_FRONTEND=noninteractive apt-get install --option "Dpkg::Options::=--force-confold" -y --no-install-recommends \ apt-transport-https \ diff --git a/pkg/scripts/testdata/TestKubeadmDebian-overwrite_registry_insecure.golden b/pkg/scripts/testdata/TestKubeadmDebian-overwrite_registry_insecure.golden index be3960538..b1648f57e 100644 --- a/pkg/scripts/testdata/TestKubeadmDebian-overwrite_registry_insecure.golden +++ b/pkg/scripts/testdata/TestKubeadmDebian-overwrite_registry_insecure.golden @@ -49,6 +49,12 @@ Acquire::https::Proxy "http://https.proxy"; Acquire::http::Proxy "http://http.proxy"; EOF +# Removing deprecated Kubernetes repositories from apt sources is needed when upgrading from older KubeOne versions, +# otherwise, apt-get update will fail to upgrade the packages. +if sudo grep -q "deb http://apt.kubernetes.io/ kubernetes-xenial main" /etc/apt/sources.list.d/kubernetes.list; then + rm -f /etc/apt/sources.list.d/kubernetes.list +fi + sudo apt-get update sudo DEBIAN_FRONTEND=noninteractive apt-get install --option "Dpkg::Options::=--force-confold" -y --no-install-recommends \ apt-transport-https \ diff --git a/pkg/scripts/testdata/TestKubeadmDebian-simple.golden b/pkg/scripts/testdata/TestKubeadmDebian-simple.golden index cb4d93543..d61629090 100644 --- a/pkg/scripts/testdata/TestKubeadmDebian-simple.golden +++ b/pkg/scripts/testdata/TestKubeadmDebian-simple.golden @@ -49,6 +49,12 @@ Acquire::https::Proxy "http://https.proxy"; Acquire::http::Proxy "http://http.proxy"; EOF +# Removing deprecated Kubernetes repositories from apt sources is needed when upgrading from older KubeOne versions, +# otherwise, apt-get update will fail to upgrade the packages. +if sudo grep -q "deb http://apt.kubernetes.io/ kubernetes-xenial main" /etc/apt/sources.list.d/kubernetes.list; then + rm -f /etc/apt/sources.list.d/kubernetes.list +fi + sudo apt-get update sudo DEBIAN_FRONTEND=noninteractive apt-get install --option "Dpkg::Options::=--force-confold" -y --no-install-recommends \ apt-transport-https \