From 8d6ce8ce4dca80600184f2fc9736762c41fb48cc Mon Sep 17 00:00:00 2001 From: Karol Szwaj Date: Mon, 11 Mar 2024 13:34:33 +0100 Subject: [PATCH 1/6] 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 d146ff211..82d5a0666 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/6] 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 82d5a0666..7788da7c2 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 dc2dc3f39eba9eb3929406294331f99455dd1f50 Mon Sep 17 00:00:00 2001 From: Karol Szwaj Date: Mon, 11 Mar 2024 14:27:20 +0100 Subject: [PATCH 3/6] 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 98fc1ca12..8fe1c2287 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/6] 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 7788da7c2..8c7a46499 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 }}-*" {{- if or .FORCE .UPGRADE }} diff --git a/pkg/scripts/testdata/TestKubeadmDebian-cilium_cluster.golden b/pkg/scripts/testdata/TestKubeadmDebian-cilium_cluster.golden index 8fe1c2287..4d9422962 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/6] 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 8c7a46499..f00403094 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/6] 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 f00403094..5e171ac00 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 4eb8dec8d..ac78bc1fe 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 f17504433..69810cc25 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 4eb8dec8d..ac78bc1fe 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 69a40a979..56ec4a7ea 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 fc4d06804..ba0d3de93 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 4d3166507..378a179ac 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