From a8629bc74cc17158ee3c5b06e771f84dda5585c4 Mon Sep 17 00:00:00 2001 From: Muhammad Adil Ghaffar Date: Thu, 1 Aug 2024 14:59:47 +0300 Subject: [PATCH 1/2] Bump k8s to v1.31.0-rc.0 Signed-off-by: Muhammad Adil Ghaffar --- config/crd/patches/webhook_in_metal3clusters.yaml | 3 --- .../crd/patches/webhook_in_metal3dataclaims.yaml | 3 --- config/crd/patches/webhook_in_metal3datas.yaml | 3 --- .../patches/webhook_in_metal3datatemplates.yaml | 3 --- config/crd/patches/webhook_in_metal3machines.yaml | 3 --- .../patches/webhook_in_metal3machinetemplates.yaml | 3 --- .../crd/patches/webhook_in_metal3remediations.yaml | 3 --- .../webhook_in_metal3remediationtemplates.yaml | 3 --- docs/api.md | 14 +++++++------- docs/architecture.md | 2 +- docs/dev-setup.md | 2 +- examples/generate.sh | 6 +++--- hack/ensure-kubectl.sh | 2 +- hack/gen_tilt_settings.sh | 2 +- scripts/environment.sh | 4 ++-- test/e2e/config/e2e_conf.yaml | 2 +- 16 files changed, 17 insertions(+), 41 deletions(-) diff --git a/config/crd/patches/webhook_in_metal3clusters.yaml b/config/crd/patches/webhook_in_metal3clusters.yaml index da9789ddd8..ab75e23358 100644 --- a/config/crd/patches/webhook_in_metal3clusters.yaml +++ b/config/crd/patches/webhook_in_metal3clusters.yaml @@ -10,9 +10,6 @@ spec: webhook: conversionReviewVersions: ["v1", "v1beta1"] clientConfig: - # this is "\n" used as a placeholder, otherwise it will be rejected by the apiserver for being blank, - # but we're going to set it later using the cert-manager (or potentially a patch if not using cert-manager) - caBundle: Cg== service: namespace: system name: webhook-service diff --git a/config/crd/patches/webhook_in_metal3dataclaims.yaml b/config/crd/patches/webhook_in_metal3dataclaims.yaml index ac2e73e3bf..d07f2a2542 100644 --- a/config/crd/patches/webhook_in_metal3dataclaims.yaml +++ b/config/crd/patches/webhook_in_metal3dataclaims.yaml @@ -10,9 +10,6 @@ spec: webhook: conversionReviewVersions: ["v1", "v1beta1"] clientConfig: - # this is "\n" used as a placeholder, otherwise it will be rejected by the apiserver for being blank, - # but we're going to set it later using the cert-manager (or potentially a patch if not using cert-manager) - caBundle: Cg== service: namespace: system name: webhook-service diff --git a/config/crd/patches/webhook_in_metal3datas.yaml b/config/crd/patches/webhook_in_metal3datas.yaml index 5ecf4e893a..ce6fd036d4 100644 --- a/config/crd/patches/webhook_in_metal3datas.yaml +++ b/config/crd/patches/webhook_in_metal3datas.yaml @@ -10,9 +10,6 @@ spec: webhook: conversionReviewVersions: ["v1", "v1beta1"] clientConfig: - # this is "\n" used as a placeholder, otherwise it will be rejected by the apiserver for being blank, - # but we're going to set it later using the cert-manager (or potentially a patch if not using cert-manager) - caBundle: Cg== service: namespace: system name: webhook-service diff --git a/config/crd/patches/webhook_in_metal3datatemplates.yaml b/config/crd/patches/webhook_in_metal3datatemplates.yaml index eb65c21d8b..81d1660e7a 100644 --- a/config/crd/patches/webhook_in_metal3datatemplates.yaml +++ b/config/crd/patches/webhook_in_metal3datatemplates.yaml @@ -10,9 +10,6 @@ spec: webhook: conversionReviewVersions: ["v1", "v1beta1"] clientConfig: - # this is "\n" used as a placeholder, otherwise it will be rejected by the apiserver for being blank, - # but we're going to set it later using the cert-manager (or potentially a patch if not using cert-manager) - caBundle: Cg== service: namespace: system name: webhook-service diff --git a/config/crd/patches/webhook_in_metal3machines.yaml b/config/crd/patches/webhook_in_metal3machines.yaml index 7097af2675..5565e821d9 100644 --- a/config/crd/patches/webhook_in_metal3machines.yaml +++ b/config/crd/patches/webhook_in_metal3machines.yaml @@ -10,9 +10,6 @@ spec: webhook: conversionReviewVersions: ["v1", "v1beta1"] clientConfig: - # this is "\n" used as a placeholder, otherwise it will be rejected by the apiserver for being blank, - # but we're going to set it later using the cert-manager (or potentially a patch if not using cert-manager) - caBundle: Cg== service: namespace: system name: webhook-service diff --git a/config/crd/patches/webhook_in_metal3machinetemplates.yaml b/config/crd/patches/webhook_in_metal3machinetemplates.yaml index 100c910507..5f37759af0 100644 --- a/config/crd/patches/webhook_in_metal3machinetemplates.yaml +++ b/config/crd/patches/webhook_in_metal3machinetemplates.yaml @@ -10,9 +10,6 @@ spec: webhook: conversionReviewVersions: ["v1", "v1beta1"] clientConfig: - # this is "\n" used as a placeholder, otherwise it will be rejected by the apiserver for being blank, - # but we're going to set it later using the cert-manager (or potentially a patch if not using cert-manager) - caBundle: Cg== service: namespace: system name: webhook-service diff --git a/config/crd/patches/webhook_in_metal3remediations.yaml b/config/crd/patches/webhook_in_metal3remediations.yaml index 802845fc0a..143fec23a5 100644 --- a/config/crd/patches/webhook_in_metal3remediations.yaml +++ b/config/crd/patches/webhook_in_metal3remediations.yaml @@ -10,9 +10,6 @@ spec: webhook: conversionReviewVersions: ["v1", "v1beta1"] clientConfig: - # this is "\n" used as a placeholder, otherwise it will be rejected by the apiserver for being blank, - # but we're going to set it later using the cert-manager (or potentially a patch if not using cert-manager) - caBundle: Cg== service: namespace: system name: webhook-service diff --git a/config/crd/patches/webhook_in_metal3remediationtemplates.yaml b/config/crd/patches/webhook_in_metal3remediationtemplates.yaml index 75d07e7f58..36c2a10267 100644 --- a/config/crd/patches/webhook_in_metal3remediationtemplates.yaml +++ b/config/crd/patches/webhook_in_metal3remediationtemplates.yaml @@ -10,9 +10,6 @@ spec: webhook: conversionReviewVersions: ["v1", "v1beta1"] clientConfig: - # this is "\n" used as a placeholder, otherwise it will be rejected by the apiserver for being blank, - # but we're going to set it later using the cert-manager (or potentially a patch if not using cert-manager) - caBundle: Cg== service: namespace: system name: webhook-service diff --git a/docs/api.md b/docs/api.md index 182bed3057..788ff60024 100644 --- a/docs/api.md +++ b/docs/api.md @@ -127,7 +127,7 @@ spec: rollingUpdate: maxSurge: 1 type: RollingUpdate - version: v1.30.0 + version: v1.31.0-rc.0 kubeadmConfigSpec: joinConfiguration: controlPlane: {} @@ -243,7 +243,7 @@ spec: namespace: metal3 nodeDrainTimeout: 0s providerID: metal3://68be298f-ed11-439e-9d51-6c5260faede6 - version: v1.30.0 + version: v1.31.0-rc.0 ``` ## Metal3Machine @@ -413,10 +413,10 @@ metadata: spec: automatedCleaningMode: metadata image: - checksum: http://172.22.0.1/images/UBUNTU_22.04_NODE_IMAGE_K8S_v1.30.0-raw.img.sha256sum + checksum: http://172.22.0.1/images/UBUNTU_22.04_NODE_IMAGE_K8S_v1.31.0-rc.0-raw.img.sha256sum checksumType: sha256 format: raw - url: http://172.22.0.1/images/UBUNTU_22.04_NODE_IMAGE_K8S_v1.30.0-raw.img + url: http://172.22.0.1/images/UBUNTU_22.04_NODE_IMAGE_K8S_v1.31.0-rc.0-raw.img hostSelector: matchLabels: key1: value1 @@ -473,7 +473,7 @@ spec: name: md-0 apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 kind: Metal3MachineTemplate - version: v1.30.0 + version: v1.31.0-rc.0 ``` ## KubeadmConfigTemplate @@ -557,10 +557,10 @@ spec: spec: automatedCleaningMode: metadata image: - checksum: http://172.22.0.1/images/UBUNTU_22.04_NODE_IMAGE_K8S_v1.30.0-raw.img.sha256sum + checksum: http://172.22.0.1/images/UBUNTU_22.04_NODE_IMAGE_K8S_v1.31.0-rc.0-raw.img.sha256sum checksumType: sha256 format: raw - url: http://172.22.0.1/images/UBUNTU_22.04_NODE_IMAGE_K8S_v1.30.0-raw.img + url: http://172.22.0.1/images/UBUNTU_22.04_NODE_IMAGE_K8S_v1.31.0-rc.0-raw.img hostSelector: matchLabels: key1: value1 diff --git a/docs/architecture.md b/docs/architecture.md index 0f3a9663b8..558e603c2a 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -404,7 +404,7 @@ spec: etcd: {} imageRepository: "" kind: ClusterConfiguration - kubernetesVersion: v1.30.0 + kubernetesVersion: v1.31.0-rc.0 networking: dnsDomain: cluster.local podSubnet: 192.168.0.0/18 diff --git a/docs/dev-setup.md b/docs/dev-setup.md index fd499a13e9..28a546d939 100644 --- a/docs/dev-setup.md +++ b/docs/dev-setup.md @@ -287,7 +287,7 @@ Please note, the precedence of variables is as follows: }, "metadata": {, "CONTROL_PLANE_MACHINE_COUNT": "1", - "KUBERNETES_VERSION": "v1.30.0", + "KUBERNETES_VERSION": "v1.31.0-rc.0", "WORKER_MACHINE_COUNT": "2", } } diff --git a/examples/generate.sh b/examples/generate.sh index 964ac6f942..91b9399520 100755 --- a/examples/generate.sh +++ b/examples/generate.sh @@ -24,11 +24,11 @@ KUSTOMIZE="${SOURCE_DIR}/../hack/tools/bin/kustomize" # Cluster. export CLUSTER_NAME="${CLUSTER_NAME:-test1}" -export KUBERNETES_VERSION="${KUBERNETES_VERSION:-v1.30.0}" +export KUBERNETES_VERSION="${KUBERNETES_VERSION:-v1.31.0-rc.0}" export CLUSTER_APIENDPOINT_HOST="${CLUSTER_APIENDPOINT_HOST:-192.168.111.249}" export CLUSTER_APIENDPOINT_PORT="${CLUSTER_APIENDPOINT_PORT:-6443}" -export IMAGE_URL="${IMAGE_URL:-http://172.22.0.1/images/UBUNTU_22.04_NODE_IMAGE_K8S_v1.30.0-raw.img}" -export IMAGE_CHECKSUM="${IMAGE_CHECKSUM:-http://172.22.0.1/images/UBUNTU_22.04_NODE_IMAGE_K8S_v1.30.0-raw.img.sha256sum}" +export IMAGE_URL="${IMAGE_URL:-http://172.22.0.1/images/UBUNTU_22.04_NODE_IMAGE_K8S_v1.31.0-rc.0-raw.img}" +export IMAGE_CHECKSUM="${IMAGE_CHECKSUM:-http://172.22.0.1/images/UBUNTU_22.04_NODE_IMAGE_K8S_v1.31.0-rc.0-raw.img.sha256sum}" export IMAGE_CHECKSUM_TYPE="${IMAGE_CHECKSUM_TYPE:-sha256}" export IMAGE_FORMAT="${IMAGE_FORMAT:-raw}" diff --git a/hack/ensure-kubectl.sh b/hack/ensure-kubectl.sh index 39b4f53528..aa26d8a1b0 100755 --- a/hack/ensure-kubectl.sh +++ b/hack/ensure-kubectl.sh @@ -19,7 +19,7 @@ set -o nounset set -o pipefail GOPATH_BIN="$(go env GOPATH)/bin/" -MINIMUM_KUBECTL_VERSION=${KUBERNETES_VERSION:-"v1.30.0"} +MINIMUM_KUBECTL_VERSION=${KUBERNETES_VERSION:-"v1.31.0-rc.0"} # Ensure the kubectl tool exists and is a viable version, or installs it verify_kubectl_version() diff --git a/hack/gen_tilt_settings.sh b/hack/gen_tilt_settings.sh index 918a486940..031cb5ee64 100755 --- a/hack/gen_tilt_settings.sh +++ b/hack/gen_tilt_settings.sh @@ -63,7 +63,7 @@ cat <tilt-settings.json { "capi_version": "${CAPIRELEASE}", "cert_manager_version": "v1.12.3", - "kubernetes_version": "${KUBERNETES_VERSION:-v1.30.0}" + "kubernetes_version": "${KUBERNETES_VERSION:-v1.31.0-rc.0}" } EOF fi diff --git a/scripts/environment.sh b/scripts/environment.sh index 8f01eae6ac..ce6859e605 100644 --- a/scripts/environment.sh +++ b/scripts/environment.sh @@ -48,8 +48,8 @@ else export EPHEMERAL_CLUSTER="minikube" fi -export FROM_K8S_VERSION=${FROM_K8S_VERSION:-"v1.29.0"} -export KUBERNETES_VERSION=${KUBERNETES_VERSION:-"v1.30.0"} +export FROM_K8S_VERSION=${FROM_K8S_VERSION:-"v1.30.0"} +export KUBERNETES_VERSION=${KUBERNETES_VERSION:-"v1.31.0-rc.0"} # Can be overriden from jjbs export CAPI_VERSION=${CAPI_VERSION:-"v1beta1"} diff --git a/test/e2e/config/e2e_conf.yaml b/test/e2e/config/e2e_conf.yaml index 03d8fb91e3..420ec3b6b5 100644 --- a/test/e2e/config/e2e_conf.yaml +++ b/test/e2e/config/e2e_conf.yaml @@ -162,7 +162,7 @@ providers: variables: CNI: "/tmp/calico.yaml" - KUBERNETES_VERSION: "v1.30.0" + KUBERNETES_VERSION: "v1.31.0-rc.0" CONTROL_PLANE_MACHINE_COUNT: 3 WORKER_MACHINE_COUNT: 1 APIVersion: "infrastructure.cluster.x-k8s.io/${CAPM3_VERSION}" From 5ee13b200e191399a761685ce454fe649f7d3a15 Mon Sep 17 00:00:00 2001 From: Muhammad Adil Ghaffar Date: Fri, 2 Aug 2024 15:00:18 +0300 Subject: [PATCH 2/2] Bump k8s to v1.31.0 and drop caBundle from CRDs to support Kubernetes 1.31 Signed-off-by: Muhammad Adil Ghaffar --- docs/api.md | 14 ++++----- docs/architecture.md | 2 +- docs/dev-setup.md | 2 +- examples/generate.sh | 6 ++-- hack/ensure-kubectl.sh | 2 +- hack/gen_tilt_settings.sh | 2 +- scripts/environment.sh | 2 +- test/e2e/common.go | 19 +++++++++++++ test/e2e/config/e2e_conf.yaml | 2 +- test/e2e/ip_reuse.go | 44 +++++++++++++++++------------ test/e2e/node_reuse.go | 23 ++------------- test/e2e/upgrade_kubernetes_test.go | 4 +-- 12 files changed, 65 insertions(+), 57 deletions(-) diff --git a/docs/api.md b/docs/api.md index 788ff60024..f648b32a5e 100644 --- a/docs/api.md +++ b/docs/api.md @@ -127,7 +127,7 @@ spec: rollingUpdate: maxSurge: 1 type: RollingUpdate - version: v1.31.0-rc.0 + version: v1.31.0 kubeadmConfigSpec: joinConfiguration: controlPlane: {} @@ -243,7 +243,7 @@ spec: namespace: metal3 nodeDrainTimeout: 0s providerID: metal3://68be298f-ed11-439e-9d51-6c5260faede6 - version: v1.31.0-rc.0 + version: v1.31.0 ``` ## Metal3Machine @@ -413,10 +413,10 @@ metadata: spec: automatedCleaningMode: metadata image: - checksum: http://172.22.0.1/images/UBUNTU_22.04_NODE_IMAGE_K8S_v1.31.0-rc.0-raw.img.sha256sum + checksum: http://172.22.0.1/images/UBUNTU_22.04_NODE_IMAGE_K8S_v1.31.0-raw.img.sha256sum checksumType: sha256 format: raw - url: http://172.22.0.1/images/UBUNTU_22.04_NODE_IMAGE_K8S_v1.31.0-rc.0-raw.img + url: http://172.22.0.1/images/UBUNTU_22.04_NODE_IMAGE_K8S_v1.31.0-raw.img hostSelector: matchLabels: key1: value1 @@ -473,7 +473,7 @@ spec: name: md-0 apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 kind: Metal3MachineTemplate - version: v1.31.0-rc.0 + version: v1.31.0 ``` ## KubeadmConfigTemplate @@ -557,10 +557,10 @@ spec: spec: automatedCleaningMode: metadata image: - checksum: http://172.22.0.1/images/UBUNTU_22.04_NODE_IMAGE_K8S_v1.31.0-rc.0-raw.img.sha256sum + checksum: http://172.22.0.1/images/UBUNTU_22.04_NODE_IMAGE_K8S_v1.31.0-raw.img.sha256sum checksumType: sha256 format: raw - url: http://172.22.0.1/images/UBUNTU_22.04_NODE_IMAGE_K8S_v1.31.0-rc.0-raw.img + url: http://172.22.0.1/images/UBUNTU_22.04_NODE_IMAGE_K8S_v1.31.0-raw.img hostSelector: matchLabels: key1: value1 diff --git a/docs/architecture.md b/docs/architecture.md index 558e603c2a..fc35b926a8 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -404,7 +404,7 @@ spec: etcd: {} imageRepository: "" kind: ClusterConfiguration - kubernetesVersion: v1.31.0-rc.0 + kubernetesVersion: v1.31.0 networking: dnsDomain: cluster.local podSubnet: 192.168.0.0/18 diff --git a/docs/dev-setup.md b/docs/dev-setup.md index 28a546d939..e246d784bb 100644 --- a/docs/dev-setup.md +++ b/docs/dev-setup.md @@ -287,7 +287,7 @@ Please note, the precedence of variables is as follows: }, "metadata": {, "CONTROL_PLANE_MACHINE_COUNT": "1", - "KUBERNETES_VERSION": "v1.31.0-rc.0", + "KUBERNETES_VERSION": "v1.31.0", "WORKER_MACHINE_COUNT": "2", } } diff --git a/examples/generate.sh b/examples/generate.sh index 91b9399520..0144952e40 100755 --- a/examples/generate.sh +++ b/examples/generate.sh @@ -24,11 +24,11 @@ KUSTOMIZE="${SOURCE_DIR}/../hack/tools/bin/kustomize" # Cluster. export CLUSTER_NAME="${CLUSTER_NAME:-test1}" -export KUBERNETES_VERSION="${KUBERNETES_VERSION:-v1.31.0-rc.0}" +export KUBERNETES_VERSION="${KUBERNETES_VERSION:-v1.31.0}" export CLUSTER_APIENDPOINT_HOST="${CLUSTER_APIENDPOINT_HOST:-192.168.111.249}" export CLUSTER_APIENDPOINT_PORT="${CLUSTER_APIENDPOINT_PORT:-6443}" -export IMAGE_URL="${IMAGE_URL:-http://172.22.0.1/images/UBUNTU_22.04_NODE_IMAGE_K8S_v1.31.0-rc.0-raw.img}" -export IMAGE_CHECKSUM="${IMAGE_CHECKSUM:-http://172.22.0.1/images/UBUNTU_22.04_NODE_IMAGE_K8S_v1.31.0-rc.0-raw.img.sha256sum}" +export IMAGE_URL="${IMAGE_URL:-http://172.22.0.1/images/UBUNTU_22.04_NODE_IMAGE_K8S_v1.31.0-raw.img}" +export IMAGE_CHECKSUM="${IMAGE_CHECKSUM:-http://172.22.0.1/images/UBUNTU_22.04_NODE_IMAGE_K8S_v1.31.0-raw.img.sha256sum}" export IMAGE_CHECKSUM_TYPE="${IMAGE_CHECKSUM_TYPE:-sha256}" export IMAGE_FORMAT="${IMAGE_FORMAT:-raw}" diff --git a/hack/ensure-kubectl.sh b/hack/ensure-kubectl.sh index aa26d8a1b0..ff6c7507b9 100755 --- a/hack/ensure-kubectl.sh +++ b/hack/ensure-kubectl.sh @@ -19,7 +19,7 @@ set -o nounset set -o pipefail GOPATH_BIN="$(go env GOPATH)/bin/" -MINIMUM_KUBECTL_VERSION=${KUBERNETES_VERSION:-"v1.31.0-rc.0"} +MINIMUM_KUBECTL_VERSION=${KUBERNETES_VERSION:-"v1.31.0"} # Ensure the kubectl tool exists and is a viable version, or installs it verify_kubectl_version() diff --git a/hack/gen_tilt_settings.sh b/hack/gen_tilt_settings.sh index 031cb5ee64..003a4e3399 100755 --- a/hack/gen_tilt_settings.sh +++ b/hack/gen_tilt_settings.sh @@ -63,7 +63,7 @@ cat <tilt-settings.json { "capi_version": "${CAPIRELEASE}", "cert_manager_version": "v1.12.3", - "kubernetes_version": "${KUBERNETES_VERSION:-v1.31.0-rc.0}" + "kubernetes_version": "${KUBERNETES_VERSION:-v1.31.0}" } EOF fi diff --git a/scripts/environment.sh b/scripts/environment.sh index ce6859e605..7508dd5b12 100644 --- a/scripts/environment.sh +++ b/scripts/environment.sh @@ -49,7 +49,7 @@ else fi export FROM_K8S_VERSION=${FROM_K8S_VERSION:-"v1.30.0"} -export KUBERNETES_VERSION=${KUBERNETES_VERSION:-"v1.31.0-rc.0"} +export KUBERNETES_VERSION=${KUBERNETES_VERSION:-"v1.31.0"} # Can be overriden from jjbs export CAPI_VERSION=${CAPI_VERSION:-"v1beta1"} diff --git a/test/e2e/common.go b/test/e2e/common.go index 4fe59da41a..a472e68057 100644 --- a/test/e2e/common.go +++ b/test/e2e/common.go @@ -417,6 +417,25 @@ func ListNodes(ctx context.Context, c client.Client) { logTable("Listing Nodes", rows) } +func CreateNewM3MachineTemplate(ctx context.Context, namespace string, newM3MachineTemplateName string, m3MachineTemplateName string, clusterClient client.Client, imageURL string, imageChecksum string) { + checksumType := "sha256" + imageFormat := "raw" + + m3MachineTemplate := infrav1.Metal3MachineTemplate{} + Expect(clusterClient.Get(ctx, client.ObjectKey{Namespace: namespace, Name: m3MachineTemplateName}, &m3MachineTemplate)).To(Succeed()) + + newM3MachineTemplate := m3MachineTemplate.DeepCopy() + cleanObjectMeta(&newM3MachineTemplate.ObjectMeta) + + newM3MachineTemplate.Spec.Template.Spec.Image.URL = imageURL + newM3MachineTemplate.Spec.Template.Spec.Image.Checksum = imageChecksum + newM3MachineTemplate.Spec.Template.Spec.Image.DiskFormat = &imageFormat + newM3MachineTemplate.Spec.Template.Spec.Image.ChecksumType = &checksumType + newM3MachineTemplate.ObjectMeta.Name = newM3MachineTemplateName + + Expect(clusterClient.Create(ctx, newM3MachineTemplate)).To(Succeed(), "Failed to create new Metal3MachineTemplate") +} + type WaitForNumInput struct { Client client.Client Options []client.ListOption diff --git a/test/e2e/config/e2e_conf.yaml b/test/e2e/config/e2e_conf.yaml index 420ec3b6b5..03d8fb91e3 100644 --- a/test/e2e/config/e2e_conf.yaml +++ b/test/e2e/config/e2e_conf.yaml @@ -162,7 +162,7 @@ providers: variables: CNI: "/tmp/calico.yaml" - KUBERNETES_VERSION: "v1.31.0-rc.0" + KUBERNETES_VERSION: "v1.30.0" CONTROL_PLANE_MACHINE_COUNT: 3 WORKER_MACHINE_COUNT: 1 APIVersion: "infrastructure.cluster.x-k8s.io/${CAPM3_VERSION}" diff --git a/test/e2e/ip_reuse.go b/test/e2e/ip_reuse.go index a3d6e2b499..e9e11250ee 100644 --- a/test/e2e/ip_reuse.go +++ b/test/e2e/ip_reuse.go @@ -8,7 +8,6 @@ import ( bmov1alpha1 "github.com/metal3-io/baremetal-operator/apis/metal3.io/v1alpha1" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "k8s.io/apimachinery/pkg/types" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" "sigs.k8s.io/cluster-api/test/framework" "sigs.k8s.io/cluster-api/test/framework/clusterctl" @@ -116,24 +115,23 @@ func IPReuse(ctx context.Context, inputGetter func() IPReuseInput) { Expect(machineDeployments).To(HaveLen(1), "Expected exactly 1 MachineDeployment") md := machineDeployments[0] + // Download node image + Byf("Download image %s", kubernetesVersion) + imageURL, imageChecksum := EnsureImage(kubernetesVersion) + + By("Create new worker Metal3MachineTemplate with upgraded image to boot") + m3MachineTemplateName := md.Spec.Template.Spec.InfrastructureRef.Name + newM3MachineTemplateName := fmt.Sprintf("%s-new", m3MachineTemplateName) + CreateNewM3MachineTemplate(ctx, input.Namespace, newM3MachineTemplateName, m3MachineTemplateName, managementClusterClient, imageURL, imageChecksum) + Byf("Update MachineDeployment maxUnavailable to number of workers and k8s version from %s to %s", fromK8sVersion, kubernetesVersion) - patch := []byte(fmt.Sprintf(`{ - "spec": { - "strategy": { - "rollingUpdate": { - "maxSurge": 0, - "maxUnavailable": 3 - } - }, - "template": { - "spec": { - "version": "%s" - } - } - } - }`, kubernetesVersion)) - err = managementClusterClient.Patch(ctx, md, client.RawPatch(types.MergePatchType, patch)) - Expect(err).ToNot(HaveOccurred(), "Failed to patch MachineDeployment") + helper, err := patch.NewHelper(md, managementClusterClient) + Expect(err).NotTo(HaveOccurred()) + md.Spec.Template.Spec.InfrastructureRef.Name = newM3MachineTemplateName + md.Spec.Template.Spec.Version = &kubernetesVersion + md.Spec.Strategy.RollingUpdate.MaxSurge.IntVal = 0 + md.Spec.Strategy.RollingUpdate.MaxUnavailable.IntVal = 3 + Expect(helper.Patch(ctx, md)).To(Succeed()) Byf("Wait until %d BMH(s) in deprovisioning state", 3) WaitForNumBmhInState(ctx, bmov1alpha1.StateDeprovisioning, WaitForNumInput{ @@ -143,6 +141,11 @@ func IPReuse(ctx context.Context, inputGetter func() IPReuseInput) { Intervals: input.E2EConfig.GetIntervals(input.SpecName, "wait-bmh-deprovisioning"), }) + ListBareMetalHosts(ctx, managementClusterClient, client.InNamespace(input.Namespace)) + ListMetal3Machines(ctx, managementClusterClient, client.InNamespace(input.Namespace)) + ListMachines(ctx, managementClusterClient, client.InNamespace(input.Namespace)) + ListNodes(ctx, targetClusterClient) + Byf("Wait until all %d machine(s) become(s) running", 4) WaitForNumMachinesInState(ctx, clusterv1.MachinePhaseRunning, WaitForNumInput{ Client: managementClusterClient, @@ -151,6 +154,11 @@ func IPReuse(ctx context.Context, inputGetter func() IPReuseInput) { Intervals: input.E2EConfig.GetIntervals(input.SpecName, "wait-machine-running"), }) + ListBareMetalHosts(ctx, managementClusterClient, client.InNamespace(input.Namespace)) + ListMetal3Machines(ctx, managementClusterClient, client.InNamespace(input.Namespace)) + ListMachines(ctx, managementClusterClient, client.InNamespace(input.Namespace)) + ListNodes(ctx, targetClusterClient) + By("Get the IPPools in the cluster") baremetalv4Pool, provisioningPool = GetIPPools(ctx, managementClusterClient, input.ClusterName, input.Namespace) Expect(baremetalv4Pool).To(HaveLen(1)) diff --git a/test/e2e/node_reuse.go b/test/e2e/node_reuse.go index d26dcaf952..9272a44034 100644 --- a/test/e2e/node_reuse.go +++ b/test/e2e/node_reuse.go @@ -108,7 +108,7 @@ func nodeReuse(ctx context.Context, inputGetter func() NodeReuseInput) { m3MachineTemplateName := fmt.Sprintf("%s-controlplane", input.ClusterName) updateNodeReuse(ctx, input.Namespace, true, m3MachineTemplateName, managementClusterClient) newM3MachineTemplateName := fmt.Sprintf("%s-new-controlplane", input.ClusterName) - createNewM3MachineTemplate(ctx, input.Namespace, newM3MachineTemplateName, m3MachineTemplateName, managementClusterClient, imageURL, imageChecksum) + CreateNewM3MachineTemplate(ctx, input.Namespace, newM3MachineTemplateName, m3MachineTemplateName, managementClusterClient, imageURL, imageChecksum) Byf("Update KCP to upgrade k8s version and binaries from %s to %s [node_reuse]", kubernetesVersion, upgradedK8sVersion) kcpObj := framework.GetKubeadmControlPlaneByCluster(ctx, framework.GetKubeadmControlPlaneByClusterInput{ @@ -330,7 +330,7 @@ func nodeReuse(ctx context.Context, inputGetter func() NodeReuseInput) { By("Set nodeReuse field to 'True' and create new Metal3MachineTemplate for MD with upgraded image to boot [node_reuse]") updateNodeReuse(ctx, input.Namespace, true, m3MachineTemplateName, managementClusterClient) newM3MachineTemplateName = fmt.Sprintf("%s-new-workers", input.ClusterName) - createNewM3MachineTemplate(ctx, input.Namespace, newM3MachineTemplateName, m3MachineTemplateName, managementClusterClient, imageURL, imageChecksum) + CreateNewM3MachineTemplate(ctx, input.Namespace, newM3MachineTemplateName, m3MachineTemplateName, managementClusterClient, imageURL, imageChecksum) Byf("Update MD to upgrade k8s version and binaries from %s to %s", kubernetesVersion, upgradedK8sVersion) // Note: We have only 4 nodes (3 control-plane and 1 worker) so we @@ -536,22 +536,3 @@ func deleteTaint(taints []corev1.Taint, taintsToDelete []corev1.Taint) ([]corev1 } return newTaints, deleted } - -func createNewM3MachineTemplate(ctx context.Context, namespace string, newM3MachineTemplateName string, m3MachineTemplateName string, clusterClient client.Client, imageURL string, imageChecksum string) { - checksumType := "sha256" - imageFormat := "raw" - - m3MachineTemplate := infrav1.Metal3MachineTemplate{} - Expect(clusterClient.Get(ctx, client.ObjectKey{Namespace: namespace, Name: m3MachineTemplateName}, &m3MachineTemplate)).To(Succeed()) - - newM3MachineTemplate := m3MachineTemplate.DeepCopy() - cleanObjectMeta(&newM3MachineTemplate.ObjectMeta) - - newM3MachineTemplate.Spec.Template.Spec.Image.URL = imageURL - newM3MachineTemplate.Spec.Template.Spec.Image.Checksum = imageChecksum - newM3MachineTemplate.Spec.Template.Spec.Image.DiskFormat = &imageFormat - newM3MachineTemplate.Spec.Template.Spec.Image.ChecksumType = &checksumType - newM3MachineTemplate.ObjectMeta.Name = newM3MachineTemplateName - - Expect(clusterClient.Create(ctx, newM3MachineTemplate)).To(Succeed(), "Failed to create new Metal3MachineTemplate") -} diff --git a/test/e2e/upgrade_kubernetes_test.go b/test/e2e/upgrade_kubernetes_test.go index ce4fa55145..e2b2d1e9af 100644 --- a/test/e2e/upgrade_kubernetes_test.go +++ b/test/e2e/upgrade_kubernetes_test.go @@ -108,7 +108,7 @@ func upgradeKubernetes(ctx context.Context, inputGetter func() upgradeKubernetes By("Create new KCP Metal3MachineTemplate with upgraded image to boot") m3MachineTemplateName := fmt.Sprintf("%s-controlplane", clusterName) newM3MachineTemplateName := fmt.Sprintf("%s-new-controlplane", clusterName) - createNewM3MachineTemplate(ctx, namespace, newM3MachineTemplateName, m3MachineTemplateName, clusterClient, imageURL, imageChecksum) + CreateNewM3MachineTemplate(ctx, namespace, newM3MachineTemplateName, m3MachineTemplateName, clusterClient, imageURL, imageChecksum) Byf("Update KCP to upgrade k8s version and binaries from %s to %s", kubernetesVersion, upgradedK8sVersion) kcpObj := framework.GetKubeadmControlPlaneByCluster(ctx, framework.GetKubeadmControlPlaneByClusterInput{ @@ -177,7 +177,7 @@ func upgradeKubernetes(ctx context.Context, inputGetter func() upgradeKubernetes By("Create new Metal3MachineTemplate for MD with upgraded image to boot") m3MachineTemplateName = fmt.Sprintf("%s-workers", clusterName) newM3MachineTemplateName = fmt.Sprintf("%s-new-workers", clusterName) - createNewM3MachineTemplate(ctx, namespace, newM3MachineTemplateName, m3MachineTemplateName, clusterClient, imageURL, imageChecksum) + CreateNewM3MachineTemplate(ctx, namespace, newM3MachineTemplateName, m3MachineTemplateName, clusterClient, imageURL, imageChecksum) Byf("Update MD to upgrade k8s version and binaries from %s to %s", kubernetesVersion, upgradedK8sVersion) helper, err = patch.NewHelper(machineDeploy, clusterClient)